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