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

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

package io.smallrye.faulttolerance.rxjava3.impl;

import java.util.concurrent.CompletionStage;

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

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

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

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

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

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

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

    @Override
    public CompletionStage fallbackResultToCompletionStage(Single single) {
        return single.toCompletionStage();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy