Top Constructors Methods
io.github.resilience4j.core

public Class CompletionStageUtils

extends Object
Class Inheritance
Imports
java.util.List, java.util.concurrent.CompletableFuture, .CompletionException, .CompletionStage, .ExecutionException, java.util.function.*

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
return type of after
T
, R>
Supplier<CompletionStage<R>>

Returns:

a function composed of supplier and handler
andThen
(Supplier<CompletionStage<T>>
the CompletionStage supplier
completionStageSupplier
,
BiFunction<T, Throwable, R>
the function applied after supplier
handler
)

Returns a composed CompletionStage that first applies the CompletionStage and then applies BiFunction after to the result.

public static <T> CompletionStage<T>

Returns:

a CompletionStage that is recovered from any exception.
recover
(CompletionStage<T>
the completionStage which should be recovered from any exception
completionStage
,
Function<Throwable, T>
the function applied after callable has failed
exceptionHandler
)

Returns a CompletionStage that is recovered from any exception.

public static <T> CompletionStage<T>

Returns:

a CompletionStage that is recovered from a specific exception.
recover
(CompletionStage<T>
the completionStage which should be recovered from a certain exception
completionStage
,
List<Class<? extends Throwable>>
the specific exception types that should be recovered
exceptionTypes
,
Function<Throwable, T>
the function applied after callable has failed
exceptionHandler
)

Returns a CompletionStage that is recovered from a specific exception.

public static <X extends Throwable, T> CompletionStage<T>

Returns:

a CompletionStage that is recovered from a specific exception.
recover
(CompletionStage<T>
the completionStage which should be recovered from a certain exception
completionStage
,
Class<X>
the specific exception type that should be recovered
exceptionType
,
Function<Throwable, T>
the function applied after callable has failed
exceptionHandler
)

Returns a CompletionStage that is recovered from a specific exception.

public static <T> Supplier<CompletionStage<T>>

Returns:

a CompletionStage that is recovered from a specific exception.
recover
(Supplier<CompletionStage<T>>
a supplier of the completionStage which should be recovered from a certain exception
completionStageSupplier
,
Function<Throwable, T>
the function applied after callable has failed
exceptionHandler
)

Returns a decorated CompletionStage that is recovered from a specific exception.

public static <T, X extends Throwable> Supplier<CompletionStage<T>>

Returns:

a CompletionStage that is recovered from a specific exception.
recover
(Supplier<CompletionStage<T>>
a supplier of the completionStage which should be recovered from a certain exception
completionStageSupplier
,
Class<X>
the specific exception type that should be recovered
exceptionType
,
Function<Throwable, T>
the function applied after callable has failed
exceptionHandler
)

Returns a decorated CompletionStage that is recovered from a specific exception.

public static <T> Supplier<CompletionStage<T>>

Returns:

a CompletionStage that is recovered from a specific exception.
recover
(Supplier<CompletionStage<T>>
a supplier of the completionStage which should be recovered from a certain exception
completionStageSupplier
,
List<Class<? extends Throwable>>
the specific exception types that should be recovered
exceptionTypes
,
Function<Throwable, T>
the function applied after callable has failed
exceptionHandler
)

Returns a decorated CompletionStage that is recovered from a specific exception.

public static <
return type of after
T
>
CompletionStage<T>

Returns:

a function composed of supplier and exceptionHandler
recover
(CompletionStage<T>
the completionStage which should be recovered from a certain exception
completionStage
,
Predicate<T>
the result predicate
resultPredicate
,
UnaryOperator<T>
the result handler
resultHandler
)

Returns a composed CompletionStage that first executes the CompletionStage and optionally recovers from a specific result.

public static <
return type of after
T
>
Supplier<CompletionStage<T>>

Returns:

a function composed of supplier and exceptionHandler
recover
(Supplier<CompletionStage<T>>
the CompletionStage supplier
completionStageSupplier
,
Predicate<T>
the result predicate
resultPredicate
,
UnaryOperator<T>
the result handler
resultHandler
)

Returns a composed CompletionStage that first executes the CompletionStage and optionally recovers from a specific result.

private static <T> void
tryRecover(List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler, CompletableFuture<T> promise, Throwable throwable)

private static <X extends Throwable, T> void
tryRecover(Class<X> exceptionType, Function<Throwable, T> exceptionHandler, CompletableFuture<T> promise, Throwable throwable)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CompletionStageUtilsback to summary
private CompletionStageUtils()

Method Detail

andThenback to summary
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 BiFunction after to the result.

Parameters
<T>
return type of after
completionStageSupplier:Supplier<CompletionStage<T>>

the CompletionStage supplier

handler:BiFunction<T, Throwable, R>

the function applied after supplier

Returns:Supplier<CompletionStage<R>>

a function composed of supplier and handler

recoverback to summary
public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler)

Returns a CompletionStage that is recovered from any exception.

Parameters
completionStage:CompletionStage<T>

the completionStage which should be recovered from any exception

exceptionHandler:Function<Throwable, T>

the function applied after callable has failed

Returns:CompletionStage<T>

a CompletionStage that is recovered from any exception.

recoverback to summary
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:CompletionStage<T>

the completionStage which should be recovered from a certain exception

exceptionTypes:List<Class<? extends Throwable>>

the specific exception types that should be recovered

exceptionHandler:Function<Throwable, T>

the function applied after callable has failed

Returns:CompletionStage<T>

a CompletionStage that is recovered from a specific exception.

recoverback to summary
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:CompletionStage<T>

the completionStage which should be recovered from a certain exception

exceptionType:Class<X>

the specific exception type that should be recovered

exceptionHandler:Function<Throwable, T>

the function applied after callable has failed

Returns:CompletionStage<T>

a CompletionStage that is recovered from a specific exception.

recoverback to summary
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:Supplier<CompletionStage<T>>

a supplier of the completionStage which should be recovered from a certain exception

exceptionHandler:Function<Throwable, T>

the function applied after callable has failed

Returns:Supplier<CompletionStage<T>>

a CompletionStage that is recovered from a specific exception.

recoverback to summary
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:Supplier<CompletionStage<T>>

a supplier of the completionStage which should be recovered from a certain exception

exceptionType:Class<X>

the specific exception type that should be recovered

exceptionHandler:Function<Throwable, T>

the function applied after callable has failed

Returns:Supplier<CompletionStage<T>>

a CompletionStage that is recovered from a specific exception.

recoverback to summary
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:Supplier<CompletionStage<T>>

a supplier of the completionStage which should be recovered from a certain exception

exceptionTypes:List<Class<? extends Throwable>>

the specific exception types that should be recovered

exceptionHandler:Function<Throwable, T>

the function applied after callable has failed

Returns:Supplier<CompletionStage<T>>

a CompletionStage that is recovered from a specific exception.

recoverback to summary
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.

Parameters
<T>
return type of after
completionStage:CompletionStage<T>

the completionStage which should be recovered from a certain exception

resultPredicate:Predicate<T>

the result predicate

resultHandler:UnaryOperator<T>

the result handler

Returns:CompletionStage<T>

a function composed of supplier and exceptionHandler

recoverback to summary
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.

Parameters
<T>
return type of after
completionStageSupplier:Supplier<CompletionStage<T>>

the CompletionStage supplier

resultPredicate:Predicate<T>

the result predicate

resultHandler:UnaryOperator<T>

the result handler

Returns:Supplier<CompletionStage<T>>

a function composed of supplier and exceptionHandler

tryRecoverback to summary
private static <T> void tryRecover(List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler, CompletableFuture<T> promise, Throwable throwable)
tryRecoverback to summary
private static <X extends Throwable, T> void tryRecover(Class<X> exceptionType, Function<Throwable, T> exceptionHandler, CompletableFuture<T> promise, Throwable throwable)