Interface ObjectReturnExceptionHandlerSupport<F,L,S,T,Z extends ObjectReturnExceptionHandlerSupport<F,L,S,T,Z>>
-
- Type Parameters:
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>>.S- the type of the staged functional interface. For example,Function<T,CompletionStage<R>>.T- the type of the return type of the Functional interface.
- All Superinterfaces:
ExceptionHandlerSupport<F,L,Z>
- All Known Subinterfaces:
BiFunctionWithException<T,U,R,E>,BinaryOperatorWithException<T,E>,DoubleFunctionWithException<R,E>,FunctionWithException<T,R,E>,IntFunctionWithException<R,E>,LongFunctionWithException<R,E>,ObjectInputFilterWithException<E>,SupplierWithException<T,E>,UnaryOperatorWithException<T,E>
public interface ObjectReturnExceptionHandlerSupport<F,L,S,T,Z extends ObjectReturnExceptionHandlerSupport<F,L,S,T,Z>> extends ExceptionHandlerSupport<F,L,Z>
Root interface to support global operations related to exception handling for functional interface returning Object result.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default TdefaultValue()Defines the default value (by defaultnull) returned by the ignore and ignored method.Fignore()Converts this functional interface to the corresponding java standard functional interface returning a null in case of error.Llift()Converts this functional interface to a lifted one.default Function<Exception,Optional<T>>notThrowingHandler()Used internally to support the exception interception.Sstage()Converts this functional interface to the corresponding java standard functional interface with staged result.static <T> CompletionStage<T>staged(Callable<T> internal)Used internally to support the exception interception.default Function<Exception,T>throwingHandler()Used internally to support the exception interception.Funcheck()Converts this functional interface to the corresponding one in java and wrap exception usingExceptionHandlerSupport.exceptionMapper().static <T> Tunchecked(Callable<T> internal, Function<Exception,T> exceptionhandler)Used internally to support the exception interception.-
Methods inherited from interface ch.powerunit.extensions.exceptions.ExceptionHandlerSupport
documented, exceptionMapper
-
-
-
-
Method Detail
-
uncheck
F uncheck()
Converts this functional interface to the corresponding one in java and wrap exception usingExceptionHandlerSupport.exceptionMapper().Conceptually, the exception encapsulation is done in the following way :
(xxx) -> { try { return realaction(xxx); } catch (Exception e) { throw new exceptionMapper().apply(e); } }
-
lift
L lift()
Converts this functional interface to a lifted one. The lifted version return an Optional of the original return type.Conceptually, this is done by :
(xxx) -> { try { return Optional.ofNullable(realaction(xxx)); } catch (Exception e) { return Optional.empty(); } }
-
ignore
F ignore()
Converts this functional interface to the corresponding java standard functional interface returning a null in case of error.The principle is :
(xxx) -> { try { return realaction(xxx); } catch (Exception e) { return null; } }
-
stage
S stage()
Converts this functional interface to the corresponding java standard functional interface with staged result.- Returns:
- the operation supporting stage.
- Since:
- 1.1.0
- See Also:
CompletionStage
-
defaultValue
default T defaultValue()
Defines the default value (by defaultnull) returned by the ignore and ignored method.- Returns:
- the default value for the ignore/ignored method.
- Since:
- 3.0.0
-
unchecked
static <T> T unchecked(Callable<T> internal, Function<Exception,T> exceptionhandler)
Used internally to support the exception interception.- Type Parameters:
T- type of the return value- Parameters:
internal- the call to be doneexceptionhandler- the exception handler. May throw RuntimeException or return some default value.- Returns:
- the result
- Throws:
RuntimeException- in case of error
-
staged
static <T> CompletionStage<T> staged(Callable<T> internal)
Used internally to support the exception interception.- Type Parameters:
T- type of the return value- Parameters:
internal- the call to be done- Returns:
- the completion stage
- Throws:
RuntimeException- in case of error
-
throwingHandler
default Function<Exception,T> throwingHandler()
Used internally to support the exception interception.- Returns:
- exception handler to support exception control
-
notThrowingHandler
default Function<Exception,Optional<T>> notThrowingHandler()
Used internally to support the exception interception.- Returns:
- exception handler to ignore exception
-
-