io.smallrye.faulttolerance.rxjava3.impl.CompletableSupport Maven / Gradle / Ivy
The newest version!
package io.smallrye.faulttolerance.rxjava3.impl;
import java.util.concurrent.CompletionStage;
import io.reactivex.rxjava3.core.Completable;
import io.smallrye.faulttolerance.core.invocation.AsyncSupport;
import io.smallrye.faulttolerance.core.invocation.Invoker;
public class CompletableSupport implements AsyncSupport {
@Override
public String mustDescription() {
return "return " + Completable.class.getSimpleName();
}
@Override
public String doesDescription() {
return "returns " + Completable.class.getSimpleName();
}
@Override
public boolean applies(Class>[] parameterTypes, Class> returnType) {
return Completable.class.equals(returnType);
}
@Override
public Completable createComplete(T value) {
return Completable.complete();
}
@Override
public CompletionStage toCompletionStage(Invoker invoker) throws Exception {
return invoker.proceed().toCompletionStage(null);
}
@Override
public Completable fromCompletionStage(Invoker> invoker) {
return Completable.defer(() -> Completable.fromCompletionStage(invoker.proceed()));
}
@Override
public CompletionStage fallbackResultToCompletionStage(Completable completable) {
return completable.toCompletionStage(null);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy