- Type Parameters:
T
- The type of the input valueR
- The type of the output result
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface for mapping a value to a result.
This function is a more friendly variant of
The main use case is to map a value to a result that may contain an error.
This function is a more friendly variant of
Function<T, Result<R>>
.The main use case is to map a value to a result that may contain an error.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
R> @NotNull ResultingFunction <T, R> Creates a new resulting function that applies the given function to the value.
The output result is a success result with the output of the function as value.static <T,
R> @NotNull ResultingFunction <T, R> throwable
(@NotNull ThrowableFunction<T, R, ? extends Throwable> function) Creates a new resulting function that applies the given throwable function to the value.
If the function throws an exception, the output result is an error with the exception message.
In all other cases, the output result is a success result with the output of the function as value.
-
Method Details
-
direct
@NotNull static <T,R> @NotNull ResultingFunction<T,R> direct(@NotNull @NotNull Function<T, R> function) Creates a new resulting function that applies the given function to the value.
The output result is a success result with the output of the function as value.- Type Parameters:
T
- The type of the input valueR
- The type of the output result- Parameters:
function
- The function to apply to the value- Returns:
- The resulting function
- Throws:
NullPointerException
- If the function is null
-
throwable
@NotNull static <T,R> @NotNull ResultingFunction<T,R> throwable(@NotNull @NotNull ThrowableFunction<T, R, ? extends Throwable> function) Creates a new resulting function that applies the given throwable function to the value.
If the function throws an exception, the output result is an error with the exception message.
In all other cases, the output result is a success result with the output of the function as value.- Type Parameters:
T
- The type of the input valueR
- The type of the output result- Parameters:
function
- The throwable function to apply to the value- Returns:
- The resulting function
- Throws:
NullPointerException
- If the throwable function is null
-
apply
-