Class CheckedFunctionUtils

java.lang.Object
io.github.resilience4j.core.CheckedFunctionUtils

public class CheckedFunctionUtils extends Object
  • 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 exception
      exceptionHandler - 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 BiFunction after to the result.
      Type Parameters:
      T - return type of callable
      R - return type of handler
      Parameters:
      supplier - the supplier
      handler - 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 supplier
      resultPredicate - the result predicate
      resultHandler - 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 exception
      exceptionTypes - the specific exception types that should be recovered
      exceptionHandler - 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 exception
      exceptionType - the specific exception type that should be recovered
      exceptionHandler - the exception handler
      Returns:
      a supplier composed of callable and exceptionHandler