Class VavrCheckedFunctionUtils

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

public class VavrCheckedFunctionUtils extends 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,Throwable,R> handler)
    Returns a composed function that first applies the function and then applies BiFunction after to the result.
    static <T> io.vavr.CheckedFunction0<T>
    recover(io.vavr.CheckedFunction0<T> function, io.vavr.CheckedFunction1<Throwable,T> exceptionHandler)
    Returns a composed function that first executes the function and optionally recovers from an exception.
    static <X extends Throwable, T>
    io.vavr.CheckedFunction0<T>
    recover(io.vavr.CheckedFunction0<T> function, Class<X> exceptionType, io.vavr.CheckedFunction1<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, 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, List<Class<? extends Throwable>> exceptionTypes, io.vavr.CheckedFunction1<Throwable,T> exceptionHandler)
    Returns a composed function that first executes the function and optionally recovers from an exception.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • recover

      public static <T> io.vavr.CheckedFunction0<T> recover(io.vavr.CheckedFunction0<T> function, io.vavr.CheckedFunction1<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 exception
      exceptionHandler - 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,Throwable,R> handler)
      Returns a composed function that first applies the function and then applies BiFunction after to the result.
      Type Parameters:
      T - return type of callable
      R - return type of handler
      Parameters:
      function - the function
      handler - 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, 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 function
      resultPredicate - the result predicate
      resultHandler - 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, List<Class<? extends Throwable>> exceptionTypes, io.vavr.CheckedFunction1<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 exception
      exceptionTypes - the specific exception types that should be recovered
      exceptionHandler - the exception handler
      Returns:
      a function composed of supplier and exceptionHandler
    • recover

      public static <X extends Throwable, T> io.vavr.CheckedFunction0<T> recover(io.vavr.CheckedFunction0<T> function, Class<X> exceptionType, io.vavr.CheckedFunction1<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 exception
      exceptionType - the specific exception type that should be recovered
      exceptionHandler - the exception handler
      Returns:
      a function composed of callable and exceptionHandler