Interface FunctionWithExceptions<T,​R,​E extends java.lang.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 java.lang.Exception>
    Functional interface used to wrap lambdas to add support for Exception handling.
    • Method Detail

      • apply

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

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

        static <T,​R,​E extends java.lang.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 java.lang.Throwable> void throwAsUnchecked​(java.lang.Exception exception)
                                                              throws E extends java.lang.Throwable
        Wrapper for Exception handling.
        Parameters:
        exception - the original Exception.
        Throws:
        E - , the Exception cast to the class we wish to return.
        E extends java.lang.Throwable