Package io.github.resilience4j.core
Class CheckedFunctionUtils
java.lang.Object
io.github.resilience4j.core.CheckedFunctionUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,R> CheckedSupplier<R> andThen(CheckedSupplier<T> supplier, CheckedBiFunction<T, Throwable, R> handler) Returns a composed supplier that first applies the supplier and then applies BiFunctionafterto the result.static <T> CheckedSupplier<T>recover(CheckedSupplier<T> supplier, CheckedFunction<Throwable, T> exceptionHandler) Returns a composed supplier that first executes the supplier and optionally recovers from an exception.static <X extends Throwable,T>
CheckedSupplier<T>recover(CheckedSupplier<T> supplier, Class<X> exceptionType, CheckedFunction<Throwable, T> exceptionHandler) Returns a composed supplier that first executes the supplier and optionally recovers from an exception.static <T> CheckedSupplier<T>recover(CheckedSupplier<T> supplier, Predicate<T> resultPredicate, CheckedFunction<T, T> resultHandler) Returns a composed supplier that first executes the supplier and optionally recovers from a specific result.static <T> CheckedSupplier<T>recover(CheckedSupplier<T> supplier, List<Class<? extends Throwable>> exceptionTypes, CheckedFunction<Throwable, T> exceptionHandler) Returns a composed supplier that first executes the supplier and optionally recovers from an exception.
-
Method Details
-
recover
public static <T> CheckedSupplier<T> recover(CheckedSupplier<T> supplier, CheckedFunction<Throwable, T> exceptionHandler) Returns a composed supplier that first executes the supplier and optionally recovers from an exception.- Type Parameters:
T- return type of after- Parameters:
supplier- the supplier which should be recovered from a certain exceptionexceptionHandler- the exception handler- Returns:
- a supplier composed of callable and exceptionHandler
-
andThen
public static <T,R> CheckedSupplier<R> andThen(CheckedSupplier<T> supplier, CheckedBiFunction<T, Throwable, R> handler) Returns a composed supplier that first applies the supplier and then applies BiFunctionafterto the result.- Type Parameters:
T- return type of callableR- return type of handler- Parameters:
supplier- the supplierhandler- the supplier applied after callable- Returns:
- a supplier composed of supplier and handler
-
recover
public static <T> CheckedSupplier<T> recover(CheckedSupplier<T> supplier, Predicate<T> resultPredicate, CheckedFunction<T, T> resultHandler) Returns a composed supplier that first executes the supplier and optionally recovers from a specific result.- Type Parameters:
T- return type of after- Parameters:
supplier- the supplierresultPredicate- the result predicateresultHandler- the result handler- Returns:
- a supplier composed of supplier and exceptionHandler
-
recover
public static <T> CheckedSupplier<T> recover(CheckedSupplier<T> supplier, List<Class<? extends Throwable>> exceptionTypes, CheckedFunction<Throwable, T> exceptionHandler) Returns a composed supplier that first executes the supplier and optionally recovers from an exception.- Type Parameters:
T- return type of after- Parameters:
supplier- the supplier which should be recovered from a certain exceptionexceptionTypes- the specific exception types that should be recoveredexceptionHandler- the exception handler- Returns:
- a supplier composed of supplier and exceptionHandler
-
recover
public static <X extends Throwable,T> CheckedSupplier<T> recover(CheckedSupplier<T> supplier, Class<X> exceptionType, CheckedFunction<Throwable, T> exceptionHandler) Returns a composed supplier that first executes the supplier and optionally recovers from an exception.- Type Parameters:
T- return type of after- Parameters:
supplier- the supplier which should be recovered from a certain exceptionexceptionType- the specific exception type that should be recoveredexceptionHandler- the exception handler- Returns:
- a supplier composed of callable and exceptionHandler
-