Package io.fluxcapacitor.common
Interface ThrowingFunction<T,R>
- Type Parameters:
T
- the type of the input to the functionR
- the type of the result of 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.
Equivalent of
Function
whose apply(Object)
method may throw a checked
Exception
.
This interface helps to avoid wrapping checked exceptions in runtime exceptions when using functional APIs.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <V> ThrowingFunction
<T, V> andThen
(@NonNull ThrowingFunction<? super R, ? extends V> after) Returns a composed function that first applies this function to its input, and then applies theafter
function to the result.Applies this function to the given argument.default <V> ThrowingFunction
<V, R> compose
(@NonNull ThrowingFunction<? super V, ? extends T> before) Returns a composed function that first applies thebefore
function to its input, and then applies this function to the result.
-
Method Details
-
apply
Applies this function to the given argument.- Parameters:
t
- the function argument- Returns:
- the function result
- Throws:
Exception
- if unable to compute a result
-
compose
default <V> ThrowingFunction<V,R> compose(@NonNull @NonNull ThrowingFunction<? super V, ? extends T> before) Returns a composed function that first applies thebefore
function to its input, and then applies this function to the result.- Type Parameters:
V
- the type of input to thebefore
function, and to the composed function- Parameters:
before
- the function to apply before this function- Returns:
- a composed function that first applies the
before
function and then this function
-
andThen
default <V> ThrowingFunction<T,V> andThen(@NonNull @NonNull ThrowingFunction<? super R, ? extends V> after) Returns a composed function that first applies this function to its input, and then applies theafter
function to the result.- Type Parameters:
V
- the type of output of theafter
function, and of the composed function- Parameters:
after
- the function to apply after this function- Returns:
- a composed function that first applies this function and then the
after
function
-