Interface SafeFunction<T,R>
- Type Parameters:
T- the type of the inputR- the type of the result
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A
Function that can throw a checked exception.-
Method Summary
Modifier and TypeMethodDescriptionApply the function, possibly throwing an exception.applyCatching(T t) Apply the function, catching any exceptions and wrapping them in aResultTurn thisSafeFunctioninto aFunctionthat sneaky throws any exceptions.static <T,R> SafeFunction <T, R> constant(R r) ASafeFunctionthat always returns the same value, ignoring the input.static <T,R> SafeFunction <T, R> Wrap aFunctionin aSafeFunction
-
Method Details
-
constant
ASafeFunctionthat always returns the same value, ignoring the input.- Type Parameters:
T- the type of the inputR- the type of the result- Parameters:
r- the value to return- Returns:
- a
SafeFunctionthat always returns the given value
-
of
Wrap aFunctionin aSafeFunction- Type Parameters:
T- the type of the inputR- the type of the result- Parameters:
function- the function to wrap- Returns:
- a
SafeFunctionthat delegates to the given function
-
apply
-
applyCatching
-
asFunction
-