Package no.digipost.function
Interface ThrowingFunction<T,R,X extends Throwable>
-
- Type Parameters:
T- the type of the input to the functionR- the type of the result of the functionX- the exception type which may be thrown when applying the function
- All Known Subinterfaces:
ThrowingFunction.OfUncheckedException<T,R,X>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ThrowingFunction<T,R,X extends Throwable>
Represents a function that accepts one argument and produces a result, and it may throw an exception.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceThrowingFunction.OfUncheckedException<T,R,X extends RuntimeException>Unification ofThrowingFunctionandFunction.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <V> ThrowingFunction<T,V,X>andThen(ThrowingFunction<? super R,V,? extends X> after)Rapply(T t)default Function<T,R>asUnchecked()default <V> ThrowingFunction<V,R,X>compose(ThrowingFunction<? super V,? extends T,? extends X> before)static <T> ThrowingFunction.OfUncheckedException<T,T,RuntimeException>identity()Returns a function that always returns its input argument.default Function<T,Optional<R>>ifException(BiConsumer<? super T,Exception> exceptionHandler)default Function<T,Optional<R>>ifException(Consumer<Exception> exceptionHandler)default Function<T,R>ifExceptionApply(BiFunction<? super T,Exception,? extends R> exceptionMapper)default Function<T,R>ifExceptionApply(Function<Exception,? extends R> exceptionMapper)default Function<T,R>ifExceptionThrow(BiFunction<? super T,? super Exception,? extends RuntimeException> exceptionMapper)default Function<T,R>ifExceptionThrow(Function<? super Exception,? extends RuntimeException> exceptionMapper)
-
-
-
Method Detail
-
identity
static <T> ThrowingFunction.OfUncheckedException<T,T,RuntimeException> identity()
Returns a function that always returns its input argument.- Type Parameters:
T- the type of the input and output objects to the function- Returns:
- a function that always returns its input argument
-
ifExceptionThrow
default Function<T,R> ifExceptionThrow(Function<? super Exception,? extends RuntimeException> exceptionMapper)
-
ifExceptionThrow
default Function<T,R> ifExceptionThrow(BiFunction<? super T,? super Exception,? extends RuntimeException> exceptionMapper)
-
ifException
default Function<T,Optional<R>> ifException(BiConsumer<? super T,Exception> exceptionHandler)
-
ifExceptionApply
default Function<T,R> ifExceptionApply(Function<Exception,? extends R> exceptionMapper)
-
ifExceptionApply
default Function<T,R> ifExceptionApply(BiFunction<? super T,Exception,? extends R> exceptionMapper)
-
andThen
default <V> ThrowingFunction<T,V,X> andThen(ThrowingFunction<? super R,V,? extends X> after)
-
compose
default <V> ThrowingFunction<V,R,X> compose(ThrowingFunction<? super V,? extends T,? extends X> before)
-
-