Interface PrimitiveReturnExceptionHandlerSupport<F,Z extends PrimitiveReturnExceptionHandlerSupport<F,Z>>
-
- Type Parameters:
F
- the type of the java standard functional interface. For example,Predicate<T>
. The same functional interface is also used for the lifted and ignored version.
- All Superinterfaces:
ExceptionHandlerSupport<F,F,Z>
- All Known Subinterfaces:
BiPredicateWithException<T,U,E>
,BooleanSupplierWithException<E>
,DoubleBinaryOperatorWithException<E>
,DoublePredicateWithException<E>
,DoubleSupplierWithException<E>
,DoubleToIntFunctionWithException<E>
,DoubleToLongFunctionWithException<E>
,DoubleUnaryOperatorWithException<E>
,FileFilterWithException<E>
,FilenameFilterWithException<E>
,IntBinaryOperatorWithException<E>
,IntPredicateWithException<E>
,IntSupplierWithException<E>
,IntToDoubleFunctionWithException<E>
,IntToLongFunctionWithException<E>
,IntUnaryOperatorWithException<E>
,LongBinaryOperatorWithException<E>
,LongPredicateWithException<E>
,LongSupplierWithException<E>
,LongToDoubleFunctionWithException<E>
,LongToIntFunctionWithException<E>
,LongUnaryOperatorWithException<E>
,PathMatcherWithException<E>
,PredicateWithException<T,E>
,ToDoubleBiFunctionWithException<T,U,E>
,ToDoubleFunctionWithException<T,E>
,ToIntBiFunctionWithException<T,U,E>
,ToIntFunctionWithException<T,E>
,ToLongBiFunctionWithException<T,U,E>
,ToLongFunctionWithException<T,E>
public interface PrimitiveReturnExceptionHandlerSupport<F,Z extends PrimitiveReturnExceptionHandlerSupport<F,Z>> extends ExceptionHandlerSupport<F,F,Z>
Root interface to support global operations related to exception handling for functional interface with primitive return value.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static void
handleException(boolean uncheck, Exception e, Function<Exception,RuntimeException> exceptionMapper)
Internal function to throw an exception in case of error and uncheck mode.default F
ignore()
Converts this functional interface to a lifted one.default F
lift()
Converts this functional interface to a lifted one.default F
uncheck()
Converts this functional interface to the corresponding one in java and wrap exception usingExceptionHandlerSupport.exceptionMapper()
.F
uncheckOrIgnore(boolean uncheck)
Used internally to implements the ignore or uncheck operation.-
Methods inherited from interface ch.powerunit.extensions.exceptions.ExceptionHandlerSupport
documented, exceptionMapper
-
-
-
-
Method Detail
-
uncheck
default 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); } }
- Specified by:
uncheck
in interfaceExceptionHandlerSupport<F,F,Z extends PrimitiveReturnExceptionHandlerSupport<F,Z>>
- Returns:
- the unchecked operation
- See Also:
lift()
,ignore()
-
lift
default F lift()
Converts this functional interface to a lifted one. A lifted version return the same type as the original one, with a default value.The concept is
(xxx) -> { try { return realaction(xxx); } catch (Exception e) { return defaultValue; } }
- Specified by:
lift
in interfaceExceptionHandlerSupport<F,F,Z extends PrimitiveReturnExceptionHandlerSupport<F,Z>>
- Returns:
- the lifted function
- See Also:
uncheck()
,ignore()
-
ignore
default F ignore()
Converts this functional interface to a lifted one. A lifted version return the same type as the original one, with a default value.The concept is
(xxx) -> { try { return realaction(xxx); } catch (Exception e) { return defaultValue; } }
- Specified by:
ignore
in interfaceExceptionHandlerSupport<F,F,Z extends PrimitiveReturnExceptionHandlerSupport<F,Z>>
- Returns:
- the lifted function
- See Also:
uncheck()
,lift()
-
uncheckOrIgnore
F uncheckOrIgnore(boolean uncheck)
Used internally to implements the ignore or uncheck operation.- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
handleException
static void handleException(boolean uncheck, Exception e, Function<Exception,RuntimeException> exceptionMapper)
Internal function to throw an exception in case of error and uncheck mode.- Parameters:
uncheck
- true if exception must be thrown.e
- the current exceptionexceptionMapper
- the mapper to create exception
-
-