Interface LongBinaryOperatorWithException<E extends Exception>
-
- Type Parameters:
E
- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<LongBinaryOperator,LongBinaryOperator,LongBinaryOperatorWithException<E>>
,PrimitiveReturnExceptionHandlerSupport<LongBinaryOperator,LongBinaryOperatorWithException<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 LongBinaryOperatorWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<LongBinaryOperator,LongBinaryOperatorWithException<E>>
Represents an operation upon twolong
-valued operands and producing along
-valued result which may throw exception. This is the primitive type specialization ofBinaryOperatorWithException
forlong
.General contract
long applyAsLong(long left, long right) throws E
- The functional method.- uncheck - Return a
LongBinaryOperator
- lift - Return a
LongBinaryOperator
- ignore - Return a
LongBinaryOperator
- See Also:
LongBinaryOperator
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description long
applyAsLong(long left, long right)
Applies this operator to the given operands.default long
defaultValue()
Defines the default value returned by the ignore and ignored method.static <E extends Exception>
LongBinaryOperatorWithException<E>failing(Supplier<E> exceptionBuilder)
Returns a function that always throw exception.static <E extends Exception>
LongBinaryOperatorignored(LongBinaryOperatorWithException<E> function)
Converts aLongBinaryOperatorWithException
to a liftedLongBinaryOperator
with0
as return value in case of exception.static <E extends Exception>
LongBinaryOperatorignored(LongBinaryOperatorWithException<E> function, long defaultValue)
Converts aLongBinaryOperatorWithException
to a liftedLongBinaryOperator
with a default value as return value in case of exception.static <E extends Exception>
LongBinaryOperatorlifted(LongBinaryOperatorWithException<E> function)
Converts aLongBinaryOperatorWithException
to a liftedLongBinaryOperator
with0
as return value in case of exception.static <E extends Exception>
LongBinaryOperatorunchecked(LongBinaryOperatorWithException<E> function)
Converts aLongBinaryOperatorWithException
to aLongBinaryOperator
that convert exception toRuntimeException
.static <E extends Exception>
LongBinaryOperatorunchecked(LongBinaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aLongBinaryOperatorWithException
to aLongBinaryOperator
that convert exception toRuntimeException
by using the provided mapping function.default LongBinaryOperator
uncheckOrIgnore(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
-
applyAsLong
long applyAsLong(long left, long 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:
LongBinaryOperator.applyAsLong(long, long)
-
uncheckOrIgnore
default LongBinaryOperator uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupport
Used internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnore
in interfacePrimitiveReturnExceptionHandlerSupport<LongBinaryOperator,LongBinaryOperatorWithException<E extends Exception>>
- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
failing
static <E extends Exception> LongBinaryOperatorWithException<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> LongBinaryOperator unchecked(LongBinaryOperatorWithException<E> function)
Converts aLongBinaryOperatorWithException
to aLongBinaryOperator
that 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(LongBinaryOperatorWithException, Function)
-
unchecked
static <E extends Exception> LongBinaryOperator unchecked(LongBinaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aLongBinaryOperatorWithException
to aLongBinaryOperator
that convert exception toRuntimeException
by 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(LongBinaryOperatorWithException)
-
lifted
static <E extends Exception> LongBinaryOperator lifted(LongBinaryOperatorWithException<E> function)
Converts aLongBinaryOperatorWithException
to a liftedLongBinaryOperator
with0
as 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> LongBinaryOperator ignored(LongBinaryOperatorWithException<E> function)
Converts aLongBinaryOperatorWithException
to a liftedLongBinaryOperator
with0
as 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> LongBinaryOperator ignored(LongBinaryOperatorWithException<E> function, long defaultValue)
Converts aLongBinaryOperatorWithException
to a liftedLongBinaryOperator
with 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(LongBinaryOperatorWithException)
-
defaultValue
default long 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
-
-