Interface LongUnaryOperatorWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<LongUnaryOperator,LongUnaryOperator,LongUnaryOperatorWithException<E>>,PrimitiveReturnExceptionHandlerSupport<LongUnaryOperator,LongUnaryOperatorWithException<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 LongUnaryOperatorWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<LongUnaryOperator,LongUnaryOperatorWithException<E>>
Represents an operation on a singlelong-valued operand, may thrown exception and that produces along-valued result. This is the primitive type specialization ofUnaryOperatorWithExceptionforlong.General contract
long applyAsLong(long operand) throws E- The functional method.- uncheck - Return a
LongUnaryOperator - lift - Return a
LongUnaryOperator - ignore - Return a
LongUnaryOperator
- See Also:
LongUnaryOperator
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default LongUnaryOperatorWithException<E>andThen(LongUnaryOperatorWithException<? extends E> after)Returns a composed operator that first applies this operator to its input, and then applies theafteroperator to the result.longapplyAsLong(long operand)Applies this operator to the given operand.default LongUnaryOperatorWithException<E>compose(LongUnaryOperatorWithException<? extends E> before)Returns a composed operator that first applies thebeforeoperator to its input, and then applies this operator to the result.default longdefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
LongUnaryOperatorWithException<E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.static <E extends Exception>
LongUnaryOperatorWithException<E>identity()Returns a unary operator that always returns its input argument.default LongUnaryOperatorignore()Converts thisLongUnaryOperatorWithExceptionto a liftedLongUnaryOperatorreturning zero in case of exception.static <E extends Exception>
LongUnaryOperatorignored(LongUnaryOperatorWithException<E> function)Converts aLongUnaryOperatorWithExceptionto a liftedLongUnaryOperatorreturning0in case of exception.static <E extends Exception>
LongUnaryOperatorignored(LongUnaryOperatorWithException<E> function, long defaultValue)Converts aLongUnaryOperatorWithExceptionto a liftedLongUnaryOperatorreturning a default value in case of exception.static <E extends Exception>
LongUnaryOperatorlifted(LongUnaryOperatorWithException<E> function)Converts aLongUnaryOperatorWithExceptionto a liftedLongUnaryOperatorusing0as return value in case of error.default LongUnaryOperatoruncheck()Converts thisLongUnaryOperatorWithExceptionto aLongUnaryOperatorthat convert exception toRuntimeException.static <E extends Exception>
LongUnaryOperatorunchecked(LongUnaryOperatorWithException<E> function)Converts aLongUnaryOperatorExceptionto aLongUnaryOperatorthat wraps exception toRuntimeException.static <E extends Exception>
LongUnaryOperatorunchecked(LongUnaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aLongUnaryOperatorWithExceptionto aLongUnaryOperatorthat wraps exception toRuntimeExceptionby using the provided mapping function.default LongUnaryOperatoruncheckOrIgnore(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
lift
-
-
-
-
Method Detail
-
applyAsLong
long applyAsLong(long 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:
LongUnaryOperator.applyAsLong(long)
-
uncheckOrIgnore
default LongUnaryOperator uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<LongUnaryOperator,LongUnaryOperatorWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
uncheck
default LongUnaryOperator uncheck()
Converts thisLongUnaryOperatorWithExceptionto aLongUnaryOperatorthat convert exception toRuntimeException.- Specified by:
uncheckin interfaceExceptionHandlerSupport<LongUnaryOperator,LongUnaryOperator,LongUnaryOperatorWithException<E extends Exception>>- Specified by:
uncheckin interfacePrimitiveReturnExceptionHandlerSupport<LongUnaryOperator,LongUnaryOperatorWithException<E extends Exception>>- Returns:
- the unchecked function
- See Also:
unchecked(LongUnaryOperatorWithException),unchecked(LongUnaryOperatorWithException, Function)
-
ignore
default LongUnaryOperator ignore()
Converts thisLongUnaryOperatorWithExceptionto a liftedLongUnaryOperatorreturning zero in case of exception.- Specified by:
ignorein interfaceExceptionHandlerSupport<LongUnaryOperator,LongUnaryOperator,LongUnaryOperatorWithException<E extends Exception>>- Specified by:
ignorein interfacePrimitiveReturnExceptionHandlerSupport<LongUnaryOperator,LongUnaryOperatorWithException<E extends Exception>>- Returns:
- the function that ignore error
- See Also:
ignored(LongUnaryOperatorWithException)
-
compose
default LongUnaryOperatorWithException<E> compose(LongUnaryOperatorWithException<? 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(LongUnaryOperatorWithException)
-
andThen
default LongUnaryOperatorWithException<E> andThen(LongUnaryOperatorWithException<? 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(LongUnaryOperatorWithException)
-
identity
static <E extends Exception> LongUnaryOperatorWithException<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> LongUnaryOperatorWithException<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> LongUnaryOperator unchecked(LongUnaryOperatorWithException<E> function)
Converts aLongUnaryOperatorExceptionto aLongUnaryOperatorthat 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:
uncheck(),unchecked(LongUnaryOperatorWithException, Function)
-
unchecked
static <E extends Exception> LongUnaryOperator unchecked(LongUnaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aLongUnaryOperatorWithExceptionto aLongUnaryOperatorthat 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:
uncheck(),unchecked(LongUnaryOperatorWithException)
-
lifted
static <E extends Exception> LongUnaryOperator lifted(LongUnaryOperatorWithException<E> function)
Converts aLongUnaryOperatorWithExceptionto a liftedLongUnaryOperatorusing0as 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> LongUnaryOperator ignored(LongUnaryOperatorWithException<E> function)
Converts aLongUnaryOperatorWithExceptionto a liftedLongUnaryOperatorreturning0in 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:
ignore()
-
ignored
static <E extends Exception> LongUnaryOperator ignored(LongUnaryOperatorWithException<E> function, long defaultValue)
Converts aLongUnaryOperatorWithExceptionto a liftedLongUnaryOperatorreturning a default 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:
ignore(),ignored(LongUnaryOperatorWithException)
-
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
-
-