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.
Functional interface used to wrap lambdas to add support for Exception handling.
-
Method Summary
Modifier and TypeMethodDescriptionCalls the function.rethrowFunction(FunctionWithExceptions<T, R, E> function) Applies the function.static <E extends Throwable>
voidthrowAsUnchecked(Exception exception) Wrapper for Exception handling.static <T,R, E extends Exception>
Runcheck(FunctionWithExceptions<T, R, E> function, T t) Applies the function.
-
Method Details
-
apply
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, Function<T,E extends Exception> R> rethrowFunction(FunctionWithExceptions<T, R, throws EE> function) Applies the function.- Parameters:
function- the function to apply.- Returns:
- the result of the function.
- Throws:
E- in case of Exception.
-
uncheck
Applies the function.- Parameters:
function- the function to apply.t- the parameter of the function.- Returns:
- the result of the function.
-
throwAsUnchecked
Wrapper for Exception handling.- Parameters:
exception- the original Exception.- Throws:
E- , the Exception cast to the class we wish to return.
-