Interface ThrowingFunction<A,R,T extends Throwable>
- Type Parameters:
A
- The input argument type for the functionR
- The output result type for the functionT
- The type ofThrowable
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.
A better version of Java's
Function
interface that
allows for the functions to throw whatever Throwable
is
specified.- Version:
- 0.1-Alpha-SNAPSHOT
- Author:
- Logan Ferree (Tadukoo)
-
Method Summary
Modifier and TypeMethodDescriptiondefault <S> ThrowingFunction<A,
S, T> andThen
(ThrowingFunction<? super R, ? extends S, ? extends T> after) Creates a ThrowingFunction that runs this ThrowingFunction and puts the result into the given ThrowingFunction.Takes a single argument and returns a result.default <S> ThrowingFunction<S,
R, T> compose
(ThrowingFunction<? super S, ? extends A, ? extends T> before) Creates a ThrowingFunction that runs the given ThrowingFunction and puts the result into this ThrowingFunction.static <A,
T extends Throwable>
ThrowingFunction<A,A, T> identity()
Returns a ThrowingFunction that always returns its input argument
-
Method Details
-
apply
Takes a single argument and returns a result.- Parameters:
a
- The argument- Returns:
- A result
- Throws:
T
- Determined by the function, not required
-
compose
default <S> ThrowingFunction<S,R, composeT> (ThrowingFunction<? super S, ? extends A, ? extends T> before) Creates a ThrowingFunction that runs the given ThrowingFunction and puts the result into this ThrowingFunction.- Type Parameters:
S
- The input type to the composed ThrowingFunction- Parameters:
before
- The ThrowingFunction to run before this one, and put the result into this one- Returns:
- The ThrowingFunction made from composing this one and the given one
-
andThen
default <S> ThrowingFunction<A,S, andThenT> (ThrowingFunction<? super R, ? extends S, ? extends T> after) Creates a ThrowingFunction that runs this ThrowingFunction and puts the result into the given ThrowingFunction.- Type Parameters:
S
- The output type of the 2nd ThrowingFunction- Parameters:
after
- A 2nd ThrowingFunction to put the result of this one into- Returns:
- The ThrowingFunction made from composing this one and the given one
-
identity
Returns a ThrowingFunction that always returns its input argument- Type Parameters:
A
- The type of argumentT
- TheThrowable
being thrown- Returns:
- A ThrowingFunction that always returns its input argument
-