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 BiFunction after to 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.

    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<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 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,​java.lang.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, 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 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, 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 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 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 exception
      exceptionType - the specific exception type that should be recovered
      exceptionHandler - the exception handler
      Returns:
      a function composed of callable and exceptionHandler