F - the type of the java standard functional interface. For example,
Function<T,R>.L - the type of the lifted functional interface. For example,
Function<T,Optional<R>>.BiConsumerWithException<T,U,E>, BiFunctionWithException<T,U,R,E>, BinaryOperatorWithException<T,E>, BiPredicateWithException<T,U,E>, BooleanSupplierWithException<E>, ConsumerWithException<T,E>, DoubleBinaryOperatorWithException<E>, DoubleConsumerWithException<E>, DoubleFunctionWithException<R,E>, DoublePredicateWithException<E>, DoubleSupplierWithException<E>, DoubleToIntFunctionWithException<E>, DoubleToLongFunctionWithException<E>, DoubleUnaryOperatorWithException<E>, FileFilterWithException<E>, FilenameFilterWithException<E>, FunctionWithException<T,R,E>, IntBinaryOperatorWithException<E>, IntConsumerWithException<E>, IntFunctionWithException<R,E>, IntPredicateWithException<E>, IntSupplierWithException<E>, IntToDoubleFunctionWithException<E>, IntToLongFunctionWithException<E>, IntUnaryOperatorWithException<E>, LongBinaryOperatorWithException<E>, LongConsumerWithException<E>, LongFunctionWithException<R,E>, LongPredicateWithException<E>, LongSupplierWithException<E>, LongToDoubleFunctionWithException<E>, LongToIntFunctionWithException<E>, LongUnaryOperatorWithException<E>, NoReturnExceptionHandlerSupport<F,S>, ObjDoubleConsumerWithException<T,E>, ObjectInputFilterWithException<E>, ObjectReturnExceptionHandlerSupport<F,L,S,T>, ObjIntConsumerWithException<T,E>, ObjLongConsumerWithException<T,E>, PathMatcherWithException<E>, PredicateWithException<T,E>, PrimitiveReturnExceptionHandlerSupport<F>, RunnableWithException<E>, SupplierWithException<T,E>, ToDoubleBiFunctionWithException<T,U,E>, ToDoubleFunctionWithException<T,E>, ToIntBiFunctionWithException<T,U,E>, ToIntFunctionWithException<T,E>, ToLongBiFunctionWithException<T,U,E>, ToLongFunctionWithException<T,E>, UnaryOperatorWithException<T,E>public interface ExceptionHandlerSupport<F,L>
| Modifier and Type | Method | Description |
|---|---|---|
default Function<Exception,RuntimeException> |
exceptionMapper() |
Mapping operation to convert the exception that may be thrown during
execution to
RuntimeException. |
static <E extends Exception> |
exceptionMapperFor(Class<E> clazz,
Function<E,RuntimeException> mapper) |
Deprecated, for removal: This API element is subject to removal in a future version.
Since 2.0.0, use the
ExceptionMapper interface and the
method ExceptionMapper.forException(java.lang.Class<E>, java.util.function.Function<E, java.lang.RuntimeException>) or the others methods
of this interface. |
F |
ignore() |
Converts this functional interface to the corresponding java standard
functional interface returning a default value in case of error.
|
L |
lift() |
Converts this functional interface to a lifted one.
|
F |
uncheck() |
Converts this functional interface to the corresponding one in java and wrap
exception using
exceptionMapper(). |
default Function<Exception,RuntimeException> exceptionMapper()
RuntimeException.WrappedException.WrappedExceptionF uncheck()
exceptionMapper().
Conceptually, the exception encapsulation is done in the following way :
(xxx) -> {
try {
// do the underlying functional interface action and return result if
// applicable
} catch (Exception e) {
throw new exceptionMapper().apply(e);
}
}
L lift()
Optional is provided. For functional interface
without return value, this method will be identical to ignore().
For functional interface with Object result, the principle is :
(xxx) -> {
try {
return Optional.ofNullable(realaction(xxx));
} catch (Exception e) {
return Optional.empty();
}
}
For functional interface with primitive result, the principle is :
(xxx) -> {
try {
return realaction(xxx);
} catch (Exception e) {
return defaultValue;
}
}
For functional interface without result, the principle is :
(xxx) -> {
try {
realaction(xxx);
} catch (Exception e) {
// do nothing
}
}
F ignore()
For functional interface with Object result, the principle is :
(xxx) -> {
try {
return realaction(xxx);
} catch (Exception e) {
return null;
}
}
For functional interface with primitive result, the principle is :
(xxx) -> {
try {
return realaction(xxx);
} catch (Exception e) {
return defaultValue;
}
}
For functional interface without result, the principle is :
(xxx) -> {
try {
realaction(xxx);
} catch (Exception e) {
// do nothing
}
}
@Deprecated(forRemoval=true, since="2.0.0") static <E extends Exception> Function<Exception,RuntimeException> exceptionMapperFor(Class<E> clazz, Function<E,RuntimeException> mapper)
ExceptionMapper interface and the
method ExceptionMapper.forException(java.lang.Class<E>, java.util.function.Function<E, java.lang.RuntimeException>) or the others methods
of this interface.E - the type of the exception.clazz - the class of the exception to be wrapped.mapper - the exception mapper.WrappedException.Copyright © 2019. All rights reserved.