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