Interface FunctionWithExceptions<T,R,E extends Exception>

Type Parameters:
T - the argument being passed to the function.
R - the result of the function.
E - the Exception thrown by the function.
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 FunctionWithExceptions<T,R,E extends Exception>
Functional interface used to wrap lambdas to add support for Exception handling.
  • Method Details

    • apply

      R apply(T t) throws E
      Calls the function.
      Parameters:
      t - the argument being passed to the function.
      Returns:
      the result of the function.
      Throws:
      E - in case of Exception.
    • rethrowFunction

      static <T, R, E extends Exception> Function<T,R> rethrowFunction(FunctionWithExceptions<T,R,E> function) throws E
      Applies the function.
      Parameters:
      function - the function to apply.
      Returns:
      the result of the function.
      Throws:
      E - in case of Exception.
    • uncheck

      static <T, R, E extends Exception> R uncheck(FunctionWithExceptions<T,R,E> function, T t)
      Applies the function.
      Parameters:
      function - the function to apply.
      t - the parameter of the function.
      Returns:
      the result of the function.
    • throwAsUnchecked

      static <E extends Throwable> void throwAsUnchecked(Exception exception) throws E
      Wrapper for Exception handling.
      Parameters:
      exception - the original Exception.
      Throws:
      E - , the Exception cast to the class we wish to return.