Interface ThrowingFunction<T,R>
- Type Parameters:
T- type of the input elementR- type of the result element
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
This functional interface allows to not catch an Exception in a
lambda expression : use it at your own risk, the exception
becomes unchecked.
It is recommended to use it only in a method that can throw the
Exception type that is unchecked. So the exception can be
checked when using the method.
Source : http://4comprehension.com/sneakily-throwing-exceptions-in-lambda-expressions-in-java/
- Author:
- Guillaume Pérution-Kihli
-
Method Summary
Modifier and TypeMethodDescriptionApplies this function.static <T extends Exception, R>
RRethrows the given exception without declaring it.static <T,R> Function <T, R> unchecked(ThrowingFunction<T, R> f) Wraps a throwing function into a standard unchecked function.
-
Method Details
-
apply
-
sneakyThrow
-
unchecked
Wraps a throwing function into a standard unchecked function.- Type Parameters:
T- input typeR- result type- Parameters:
f- the function to wrap- Returns:
- a standard function rethrowing checked exceptions unchecked
-