Package io.github.resilience4j.core
Class CompletionStageUtils
java.lang.Object
io.github.resilience4j.core.CompletionStageUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,R> Supplier<CompletionStage<R>> andThen(Supplier<CompletionStage<T>> completionStageSupplier, BiFunction<T, Throwable, R> handler) Returns a composed CompletionStage that first applies the CompletionStage and then applies BiFunctionafterto the result.static <X extends Throwable,T>
CompletionStage<T>recover(CompletionStage<T> completionStage, Class<X> exceptionType, Function<Throwable, T> exceptionHandler) Returns a CompletionStage that is recovered from a specific exception.static <T> CompletionStage<T>recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler) Returns a CompletionStage that is recovered from any exception.static <T> CompletionStage<T>recover(CompletionStage<T> completionStage, Predicate<T> resultPredicate, UnaryOperator<T> resultHandler) Returns a composed CompletionStage that first executes the CompletionStage and optionally recovers from a specific result.static <T> CompletionStage<T>recover(CompletionStage<T> completionStage, List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler) Returns a CompletionStage that is recovered from a specific exception.static <T,X extends Throwable>
Supplier<CompletionStage<T>>recover(Supplier<CompletionStage<T>> completionStageSupplier, Class<X> exceptionType, Function<Throwable, T> exceptionHandler) Returns a decorated CompletionStage that is recovered from a specific exception.static <T> Supplier<CompletionStage<T>>recover(Supplier<CompletionStage<T>> completionStageSupplier, Function<Throwable, T> exceptionHandler) Returns a decorated CompletionStage that is recovered from a specific exception.static <T> Supplier<CompletionStage<T>>recover(Supplier<CompletionStage<T>> completionStageSupplier, Predicate<T> resultPredicate, UnaryOperator<T> resultHandler) Returns a composed CompletionStage that first executes the CompletionStage and optionally recovers from a specific result.static <T> Supplier<CompletionStage<T>>recover(Supplier<CompletionStage<T>> completionStageSupplier, List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler) Returns a decorated CompletionStage that is recovered from a specific exception.
-
Method Details
-
recover
public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler) Returns a CompletionStage that is recovered from any exception.- Parameters:
completionStage- the completionStage which should be recovered from any exceptionexceptionHandler- the function applied after callable has failed- Returns:
- a CompletionStage that is recovered from any exception.
-
recover
public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler) Returns a CompletionStage that is recovered from a specific exception.- Parameters:
completionStage- the completionStage which should be recovered from a certain exceptionexceptionTypes- the specific exception types that should be recoveredexceptionHandler- the function applied after callable has failed- Returns:
- a CompletionStage that is recovered from a specific exception.
-
recover
public static <X extends Throwable,T> CompletionStage<T> recover(CompletionStage<T> completionStage, Class<X> exceptionType, Function<Throwable, T> exceptionHandler) Returns a CompletionStage that is recovered from a specific exception.- Parameters:
completionStage- the completionStage which should be recovered from a certain exceptionexceptionType- the specific exception type that should be recoveredexceptionHandler- the function applied after callable has failed- Returns:
- a CompletionStage that is recovered from a specific exception.
-
recover
public static <T> Supplier<CompletionStage<T>> recover(Supplier<CompletionStage<T>> completionStageSupplier, Function<Throwable, T> exceptionHandler) Returns a decorated CompletionStage that is recovered from a specific exception.- Parameters:
completionStageSupplier- a supplier of the completionStage which should be recovered from a certain exceptionexceptionHandler- the function applied after callable has failed- Returns:
- a CompletionStage that is recovered from a specific exception.
-
recover
public static <T,X extends Throwable> Supplier<CompletionStage<T>> recover(Supplier<CompletionStage<T>> completionStageSupplier, Class<X> exceptionType, Function<Throwable, T> exceptionHandler) Returns a decorated CompletionStage that is recovered from a specific exception.- Parameters:
completionStageSupplier- a supplier of the completionStage which should be recovered from a certain exceptionexceptionType- the specific exception type that should be recoveredexceptionHandler- the function applied after callable has failed- Returns:
- a CompletionStage that is recovered from a specific exception.
-
recover
public static <T> Supplier<CompletionStage<T>> recover(Supplier<CompletionStage<T>> completionStageSupplier, List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler) Returns a decorated CompletionStage that is recovered from a specific exception.- Parameters:
completionStageSupplier- a supplier of the completionStage which should be recovered from a certain exceptionexceptionTypes- the specific exception types that should be recoveredexceptionHandler- the function applied after callable has failed- Returns:
- a CompletionStage that is recovered from a specific exception.
-
recover
public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, Predicate<T> resultPredicate, UnaryOperator<T> resultHandler) Returns a composed CompletionStage that first executes the CompletionStage and optionally recovers from a specific result.- Type Parameters:
T- return type of after- Parameters:
completionStage- the completionStage which should be recovered from a certain exceptionresultPredicate- the result predicateresultHandler- the result handler- Returns:
- a function composed of supplier and exceptionHandler
-
recover
public static <T> Supplier<CompletionStage<T>> recover(Supplier<CompletionStage<T>> completionStageSupplier, Predicate<T> resultPredicate, UnaryOperator<T> resultHandler) Returns a composed CompletionStage that first executes the CompletionStage and optionally recovers from a specific result.- Type Parameters:
T- return type of after- Parameters:
completionStageSupplier- the CompletionStage supplierresultPredicate- the result predicateresultHandler- the result handler- Returns:
- a function composed of supplier and exceptionHandler
-
andThen
public static <T,R> Supplier<CompletionStage<R>> andThen(Supplier<CompletionStage<T>> completionStageSupplier, BiFunction<T, Throwable, R> handler) Returns a composed CompletionStage that first applies the CompletionStage and then applies BiFunctionafterto the result.- Type Parameters:
T- return type of after- Parameters:
completionStageSupplier- the CompletionStage supplierhandler- the function applied after supplier- Returns:
- a function composed of supplier and handler
-