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.
Represents a function that accepts one argument and produces a result,
and it may throw an exception.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceUnification ofThrowingFunctionandFunction. -
Method Summary
Modifier and TypeMethodDescriptiondefault <V> ThrowingFunction<T,V, X> andThen(ThrowingFunction<? super R, V, ? extends X> after) 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.ifException(BiConsumer<? super T, Exception> exceptionHandler) ifException(Consumer<Exception> exceptionHandler) ifExceptionApply(BiFunction<? super T, Exception, ? extends R> exceptionMapper) ifExceptionApply(Function<Exception, ? extends R> exceptionMapper) ifExceptionThrow(BiFunction<? super T, ? super Exception, ? extends RuntimeException> exceptionMapper) ifExceptionThrow(Function<? super Exception, ? extends RuntimeException> exceptionMapper)
-
Method Details
-
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
-
apply
-
asUnchecked
-
ifExceptionThrow
-
ifExceptionThrow
default Function<T,R> ifExceptionThrow(BiFunction<? super T, ? super Exception, ? extends RuntimeException> exceptionMapper) -
ifException
-
ifException
-
ifExceptionApply
-
ifExceptionApply
-
andThen
-
compose
default <V> ThrowingFunction<V,R, composeX> (ThrowingFunction<? super V, ? extends T, ? extends X> before)
-