All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.smallrye.faulttolerance.rxjava3.impl.MaybeSupport Maven / Gradle / Ivy

There is a newer version: 6.4.0
Show newest version
package io.smallrye.faulttolerance.rxjava3.impl;

import java.util.concurrent.CompletionStage;

import io.reactivex.rxjava3.core.Maybe;
import io.smallrye.faulttolerance.core.invocation.AsyncSupport;
import io.smallrye.faulttolerance.core.invocation.Invoker;

public class MaybeSupport implements AsyncSupport> {
    @Override
    public String mustDescription() {
        return "return " + Maybe.class.getSimpleName();
    }

    @Override
    public String doesDescription() {
        return "returns " + Maybe.class.getSimpleName();
    }

    @Override
    public boolean applies(Class[] parameterTypes, Class returnType) {
        return Maybe.class.equals(returnType);
    }

    @Override
    public Maybe createComplete(T value) {
        return Maybe.just(value);
    }

    @Override
    public CompletionStage toCompletionStage(Invoker> invoker) throws Exception {
        return invoker.proceed().toCompletionStage(null);
    }

    @Override
    public Maybe fromCompletionStage(Invoker> invoker) {
        return Maybe.defer(() -> Maybe.fromCompletionStage(invoker.proceed()));
    }

    @Override
    public CompletionStage fallbackResultToCompletionStage(Maybe maybe) {
        return maybe.toCompletionStage(null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy