Interface DoubleUnaryOperatorWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<DoubleUnaryOperator,DoubleUnaryOperator,DoubleUnaryOperatorWithException<E>>,PrimitiveReturnExceptionHandlerSupport<DoubleUnaryOperator,DoubleUnaryOperatorWithException<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 DoubleUnaryOperatorWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<DoubleUnaryOperator,DoubleUnaryOperatorWithException<E>>
Represents an operation on a singledouble-valued operand that may thrown exception and produces adouble-valued result. This is the primitive type specialization ofUnaryOperatorWithExceptionfordouble.General contract
double applyAsDouble(double operand) throws E- The functional method.- uncheck - Return a
DoubleUnaryOperator - lift - Return a
DoubleUnaryOperator - ignore - Return a
DoubleUnaryOperator
- See Also:
DoubleUnaryOperator
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default DoubleUnaryOperatorWithException<E>andThen(DoubleUnaryOperatorWithException<? extends E> after)Returns a composed operator that first applies this operator to its input, and then applies theafteroperator to the result.doubleapplyAsDouble(double operand)Applies this operator to the given operand.default DoubleUnaryOperatorWithException<E>compose(DoubleUnaryOperatorWithException<? extends E> before)Returns a composed operator that first applies thebeforeoperator to its input, and then applies this operator to the result.default doubledefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
DoubleUnaryOperatorWithException<E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.static <E extends Exception>
DoubleUnaryOperatorWithException<E>identity()Returns a unary operator that always returns its input argument.static <E extends Exception>
DoubleUnaryOperatorignored(DoubleUnaryOperatorWithException<E> function)Converts aDoubleUnaryOperatorWithExceptionto a liftedDoubleUnaryOperatorreturning0in case of exception.static <E extends Exception>
DoubleUnaryOperatorignored(DoubleUnaryOperatorWithException<E> function, double defaultValue)Converts aDoubleUnaryOperatorWithExceptionto a liftedDoubleUnaryOperatorreturning a default value in case of exception.static <E extends Exception>
DoubleUnaryOperatorlifted(DoubleUnaryOperatorWithException<E> function)Converts aDoubleUnaryOperatorWithExceptionto a liftedDoubleUnaryOperatorusing0as return value in case of error.static <E extends Exception>
DoubleUnaryOperatorunchecked(DoubleUnaryOperatorWithException<E> function)Converts aDoubleUnaryOperatorExceptionto aDoubleUnaryOperatorthat wraps exception toRuntimeException.static <E extends Exception>
DoubleUnaryOperatorunchecked(DoubleUnaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aDoubleUnaryOperatorWithExceptionto aDoubleUnaryOperatorthat wraps exception toRuntimeExceptionby using the provided mapping function.default DoubleUnaryOperatoruncheckOrIgnore(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 operand) throws E extends Exception
Applies this operator to the given operand.- Parameters:
operand- the operand- Returns:
- the operator result
- Throws:
E- any exceptionE extends Exception- See Also:
DoubleUnaryOperator.applyAsDouble(double)
-
uncheckOrIgnore
default DoubleUnaryOperator uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<DoubleUnaryOperator,DoubleUnaryOperatorWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
compose
default DoubleUnaryOperatorWithException<E> compose(DoubleUnaryOperatorWithException<? extends E> before)
Returns a composed operator that first applies thebeforeoperator to its input, and then applies this operator to the result. If evaluation of either operator throws an exception, it is relayed to the caller of the composed operator.- Parameters:
before- the operator to apply before this operator is applied- Returns:
- a composed operator that first applies the
beforeoperator and then applies this operator - Throws:
NullPointerException- if before is null- See Also:
andThen(DoubleUnaryOperatorWithException)
-
andThen
default DoubleUnaryOperatorWithException<E> andThen(DoubleUnaryOperatorWithException<? extends E> after)
Returns a composed operator that first applies this operator to its input, and then applies theafteroperator to the result. If evaluation of either operator throws an exception, it is relayed to the caller of the composed operator.- Parameters:
after- the operator to apply after this operator is applied- Returns:
- a composed operator that first applies this operator and then applies
the
afteroperator - Throws:
NullPointerException- if after is null- See Also:
compose(DoubleUnaryOperatorWithException)
-
identity
static <E extends Exception> DoubleUnaryOperatorWithException<E> identity()
Returns a unary operator that always returns its input argument.- Type Parameters:
E- the exception that may be thrown- Returns:
- a unary operator that always returns its input argument
-
failing
static <E extends Exception> DoubleUnaryOperatorWithException<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> DoubleUnaryOperator unchecked(DoubleUnaryOperatorWithException<E> function)
Converts aDoubleUnaryOperatorExceptionto aDoubleUnaryOperatorthat 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(DoubleUnaryOperatorWithException, Function)
-
unchecked
static <E extends Exception> DoubleUnaryOperator unchecked(DoubleUnaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aDoubleUnaryOperatorWithExceptionto aDoubleUnaryOperatorthat wraps 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(DoubleUnaryOperatorWithException)
-
lifted
static <E extends Exception> DoubleUnaryOperator lifted(DoubleUnaryOperatorWithException<E> function)
Converts aDoubleUnaryOperatorWithExceptionto a liftedDoubleUnaryOperatorusing0as return value in case of error.- 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> DoubleUnaryOperator ignored(DoubleUnaryOperatorWithException<E> function)
Converts aDoubleUnaryOperatorWithExceptionto a liftedDoubleUnaryOperatorreturning0in 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> DoubleUnaryOperator ignored(DoubleUnaryOperatorWithException<E> function, double defaultValue)
Converts aDoubleUnaryOperatorWithExceptionto a liftedDoubleUnaryOperatorreturning a default value in case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
function- to be lifteddefaultValue- the default value in case of exception- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore(),ignored(DoubleUnaryOperatorWithException)
-
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
-
-