Interface IntBinaryOperatorWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<IntBinaryOperator,IntBinaryOperator,IntBinaryOperatorWithException<E>>,PrimitiveReturnExceptionHandlerSupport<IntBinaryOperator,IntBinaryOperatorWithException<E>>
- 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 IntBinaryOperatorWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<IntBinaryOperator,IntBinaryOperatorWithException<E>>
Represents an operation upon twoint-valued operands, may thrown exception and producing anint-valued result. This is the primitive type specialization ofBinaryOperatorWithExceptionforint.General contract
int applyAsInt(int left, int right) throws E- The functional method.- uncheck - Return a
IntBinaryOperator - lift - Return a
IntBinaryOperator - ignore - Return a
IntBinaryOperator
- See Also:
IntBinaryOperator
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intapplyAsInt(int left, int right)Applies this operator to the given operands.default intdefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
IntBinaryOperatorWithException<E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.static <E extends Exception>
IntBinaryOperatorignored(IntBinaryOperatorWithException<E> function)Converts aIntBinaryOperatorWithExceptionto a liftedIntBinaryOperatorwith0as return value in case of exception.static <E extends Exception>
IntBinaryOperatorignored(IntBinaryOperatorWithException<E> function, int defaultValue)Converts aIntBinaryOperatorWithExceptionto a liftedIntBinaryOperatorwith a default value as return value in case of exception.static <E extends Exception>
IntBinaryOperatorlifted(IntBinaryOperatorWithException<E> function)Converts aIntBinaryOperatorWithExceptionto a liftedIntBinaryOperatorwith0as return value in case of exception.static <E extends Exception>
IntBinaryOperatorunchecked(IntBinaryOperatorWithException<E> function)Converts aIntBinaryOperatorWithExceptionto aIntBinaryOperatorthat convert exception toRuntimeException.static <E extends Exception>
IntBinaryOperatorunchecked(IntBinaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aIntBinaryOperatorWithExceptionto aIntBinaryOperatorthat convert exception toRuntimeExceptionby using the provided mapping function.default IntBinaryOperatoruncheckOrIgnore(boolean uncheck)Used internally to implements the ignore or uncheck operation.-
Methods inherited from interface ch.powerunit.extensions.exceptions.ExceptionHandlerSupport
documented, exceptionMapper
-
Methods inherited from interface ch.powerunit.extensions.exceptions.PrimitiveReturnExceptionHandlerSupport
ignore, lift, uncheck
-
-
-
-
Method Detail
-
applyAsInt
int applyAsInt(int left, int right) throws E extends Exception
Applies this operator to the given operands.- Parameters:
left- the first operandright- the second operand- Returns:
- the operator result
- Throws:
E- any exceptionE extends Exception- See Also:
IntBinaryOperator.applyAsInt(int, int)
-
uncheckOrIgnore
default IntBinaryOperator uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<IntBinaryOperator,IntBinaryOperatorWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
failing
static <E extends Exception> IntBinaryOperatorWithException<E> failing(Supplier<E> exceptionBuilder)
Returns a function that always throw exception.- Type Parameters:
E- the type of the exception- Parameters:
exceptionBuilder- the supplier to create the exception- Returns:
- a function that always throw exception
-
unchecked
static <E extends Exception> IntBinaryOperator unchecked(IntBinaryOperatorWithException<E> function)
Converts aIntBinaryOperatorWithExceptionto aIntBinaryOperatorthat convert exception toRuntimeException.- Type Parameters:
E- the type of the potential exception- Parameters:
function- to be unchecked- Returns:
- the unchecked function
- Throws:
NullPointerException- if function is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck(),unchecked(IntBinaryOperatorWithException, Function)
-
unchecked
static <E extends Exception> IntBinaryOperator unchecked(IntBinaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aIntBinaryOperatorWithExceptionto aIntBinaryOperatorthat convert exception toRuntimeExceptionby using the provided mapping function.- Type Parameters:
E- the type of the potential exception- Parameters:
function- the be uncheckedexceptionMapper- a function to convert the exception to the runtime exception.- Returns:
- the unchecked function
- Throws:
NullPointerException- if function or exceptionMapper is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck(),unchecked(IntBinaryOperatorWithException)
-
lifted
static <E extends Exception> IntBinaryOperator lifted(IntBinaryOperatorWithException<E> function)
Converts aIntBinaryOperatorWithExceptionto a liftedIntBinaryOperatorwith0as return value in case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
function- to be lifted- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- See Also:
PrimitiveReturnExceptionHandlerSupport.lift()
-
ignored
static <E extends Exception> IntBinaryOperator ignored(IntBinaryOperatorWithException<E> function)
Converts aIntBinaryOperatorWithExceptionto a liftedIntBinaryOperatorwith0as return value in case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
function- to be lifted- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
-
ignored
static <E extends Exception> IntBinaryOperator ignored(IntBinaryOperatorWithException<E> function, int defaultValue)
Converts aIntBinaryOperatorWithExceptionto a liftedIntBinaryOperatorwith a default value as return value in case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
function- to be lifteddefaultValue- value in case of exception- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore(),ignored(IntBinaryOperatorWithException)
-
defaultValue
default int defaultValue()
Defines the default value returned by the ignore and ignored method.- Returns:
- the default value for the ignore/ignored method.
- Since:
- 3.0.0
-
-