java.util.function.Function<T,R>ThrowingUnaryOperator<T>@FunctionalInterface
public interface ThrowingFunction<T,R>
extends java.util.function.Function<T,R>
ThrowingFunction<String, Integer> parse = Integer::parseInt;
Function<String, Optional<Integer>> safeParse = parse.fallbackTo(string -> null)
.andThen(Optional::ofNullable);
| Modifier and Type | Method | Description |
|---|---|---|
default <V> ThrowingFunction<T,V> |
andThen(ThrowingFunction<? super R,? extends V> after) |
Returns a composed
ThrowingFunction that first applies this function to the argument, and then applies the after function to the result. |
default R |
apply(T argument) |
Applies this function to the given argument.
|
R |
applyThrowing(T argument) |
Applies this function to the given argument.
|
default <V> ThrowingFunction<V,R> |
compose(ThrowingFunction<? super V,? extends T> before) |
Returns a composed
ThrowingFunction that first applies the before function to the argument, and then applies this function to the result. |
default java.util.function.Function<T,R> |
fallbackTo(java.util.function.Function<T,R> fallback) |
Returns a
Function applying the given function to the argument if this function throws an exception. |
default java.util.function.Function<T,R> |
fallbackTo(java.util.function.Function<T,R> fallback,
java.util.function.Consumer<java.lang.Exception> exceptionConsumer) |
Returns a
Function applying the given function to the argument if this function throws an exception. |
default java.util.function.Function<T,R> |
orReturn(R value) |
Returns a
Function returning the given value if this function throws an exception. |
default java.util.function.Function<T,R> |
orReturn(R value,
java.util.function.Consumer<java.lang.Exception> exceptionConsumer) |
Returns a
Function returning the given value if this function throws an exception. |
default ThrowingFunction<T,R> |
orThrow(java.lang.Class<? extends java.lang.RuntimeException> exceptionClass) |
Returns a
ThrowingFunction throwing an exception of the given type if this function throws an exception. |
default ThrowingFunction<T,R> |
orThrow(java.lang.Class<? extends java.lang.RuntimeException> exceptionClass,
java.lang.String message) |
Returns a
ThrowingFunction throwing an exception of the given type if this function throws an exception. |
default ThrowingFunction<T,R> |
orTryWith(ThrowingFunction<? super T,? extends R> other) |
Returns a
ThrowingFunction applying the given function to the argument if this function throws an exception. |
default ThrowingFunction<T,R> |
orTryWith(ThrowingFunction<? super T,? extends R> other,
java.util.function.Consumer<java.lang.Exception> exceptionConsumer) |
Returns a
ThrowingFunction applying the given function to the argument if this function throws an exception. |
default <V> ThrowingFunction<T,V> andThen(ThrowingFunction<? super R,? extends V> after)
ThrowingFunction that first applies this function to the argument, and then applies the after function to the result.java.lang.IllegalArgumentException - if after is nulldefault R apply(T argument)
UncheckedException.R applyThrowing(T argument) throws java.lang.Exception
java.lang.Exceptiondefault <V> ThrowingFunction<V,R> compose(ThrowingFunction<? super V,? extends T> before)
ThrowingFunction that first applies the before function to the argument, and then applies this function to the result.java.lang.IllegalArgumentException - if before is nulldefault java.util.function.Function<T,R> fallbackTo(java.util.function.Function<T,R> fallback)
Function applying the given function to the argument if this function throws an exception.java.lang.IllegalArgumentException - if fallback is nulldefault java.util.function.Function<T,R> fallbackTo(java.util.function.Function<T,R> fallback, java.util.function.Consumer<java.lang.Exception> exceptionConsumer)
Function applying the given function to the argument if this function throws an exception.java.lang.IllegalArgumentException - if fallback is nulldefault java.util.function.Function<T,R> orReturn(R value)
Function returning the given value if this function throws an exception.default java.util.function.Function<T,R> orReturn(R value, java.util.function.Consumer<java.lang.Exception> exceptionConsumer)
Function returning the given value if this function throws an exception.default ThrowingFunction<T,R> orThrow(java.lang.Class<? extends java.lang.RuntimeException> exceptionClass)
ThrowingFunction throwing an exception of the given type if this function throws an exception.
The original exception thrown by this function is the cause of the thrown exception.
The exception class must have a constructor accepting a single Throwable as an argument.
java.lang.IllegalArgumentException - if exceptionClass is nulldefault ThrowingFunction<T,R> orThrow(java.lang.Class<? extends java.lang.RuntimeException> exceptionClass, java.lang.String message)
ThrowingFunction throwing an exception of the given type if this function throws an exception.
The original exception thrown by this function is the cause of the thrown exception.
The exception class must have a constructor accepting String and Throwable as arguments.
java.lang.IllegalArgumentException - if exceptionClass is nulldefault ThrowingFunction<T,R> orTryWith(ThrowingFunction<? super T,? extends R> other)
ThrowingFunction applying the given function to the argument if this function throws an exception.java.lang.IllegalArgumentException - if other is nulldefault ThrowingFunction<T,R> orTryWith(ThrowingFunction<? super T,? extends R> other, java.util.function.Consumer<java.lang.Exception> exceptionConsumer)
ThrowingFunction applying the given function to the argument if this function throws an exception.java.lang.IllegalArgumentException - if other is null