Package com.pivovarit.function
Interface ThrowingFunction<T,R,E extends Exception>
- Type Parameters:
T- the type of the input to the functionR- the type of the result of the functionE- the type of the thrown checked exception
- All Known Subinterfaces:
ThrowingUnaryOperator<T,E>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a function that accepts one argument and returns a value;
Function might throw a checked exception instance.
- Author:
- Grzegorz Piwowarek
-
Method Summary
Modifier and TypeMethodDescriptiondefault <V> ThrowingFunction<T, V, E> andThen(ThrowingFunction<? super R, ? extends V, ? extends E> after) default <V> ThrowingFunction<V, R, E> compose(ThrowingFunction<? super V, ? extends T, ? extends E> before) lift()lifted(ThrowingFunction<T, R, ?> f) Returns a new Function instance which wraps a result of the given function in an Optional, returning an empty Optional in case of a checked exceptionstatic <T1,R> Function <T1, R> sneaky(ThrowingFunction<? super T1, ? extends R, ?> function) Returns a new Function instance which rethrows the checked exception using the Sneaky Throws patternuncheck()static <T,R> Function <T, R> unchecked(ThrowingFunction<T, R, ?> f) Returns a new Function instance which rethrows the checked exception using the Sneaky Throws pattern
-
Method Details
-
apply
- Throws:
E
-
lifted
Returns a new Function instance which wraps a result of the given function in an Optional, returning an empty Optional in case of a checked exception- Type Parameters:
T- type of the argument to the functionR- type of the result of the function- Parameters:
f- operation throwing checked exception- Returns:
- a Function that returns the result of the given function as an Optional instance.
-
unchecked
Returns a new Function instance which rethrows the checked exception using the Sneaky Throws pattern- Type Parameters:
T- type of the argument to the functionR- type of the result of the function- Parameters:
f- operation throwing checked exception- Returns:
- Function instance that rethrows the checked exception using the Sneaky Throws pattern
-
sneaky
Returns a new Function instance which rethrows the checked exception using the Sneaky Throws pattern- Type Parameters:
T1- type of the argument to the functionR- type of the result of the function- Parameters:
function- operation throwing checked exception- Returns:
- Function instance that rethrows the checked exception using the Sneaky Throws pattern
-
compose
default <V> ThrowingFunction<V,R, composeE> (ThrowingFunction<? super V, ? extends T, ? extends E> before) -
andThen
default <V> ThrowingFunction<T,V, andThenE> (ThrowingFunction<? super R, ? extends V, ? extends E> after) -
lift
-
uncheck
-