Interface FunctionEx<T,R>

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface FunctionEx<T,R>
Represents a Function capable of throwing exceptions
  • Method Details

    • apply

      R apply(T t) throws Exception
      Throws:
      Exception
    • of

      static <T, R> FunctionEx<T,R> of(Function<T,R> fn)
      Creates a FunctionEx out of Function

      If given function throws UncheckedException, its cause will be propagated

      Parameters:
      fn - original Function
      Returns:
      a function capable of throwing exceptions
    • uncheckedOf

      static <T, R> Function<T,R> uncheckedOf(FunctionEx<T,R> checkedFn)
      Creates a Function out of FunctionEx

      If given function throws a checked exception, it will be wrapped into UncheckedException and rethrown

      Unchecked exceptions will be handled by thread's FatalErrorHandler

      Parameters:
      checkedFn - original FunctionEx
      Returns:
      a function
    • identity

      static <T> FunctionEx<T,T> identity()
      A function that returns passed value as is. Does not throw any exception