Interface IntUnaryOperatorWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<IntUnaryOperator,IntUnaryOperator,IntUnaryOperatorWithException<E>>,PrimitiveReturnExceptionHandlerSupport<IntUnaryOperator,IntUnaryOperatorWithException<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 IntUnaryOperatorWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<IntUnaryOperator,IntUnaryOperatorWithException<E>>
Represents an operation on a singleint-valued operand that produces anint-valued result and may throws exception. This is the primitive type specialization ofUnaryOperatorWithExceptionforint.General contract
int applyAsInt(int operand) throws E- The functional method.- uncheck - Return a
IntUnaryOperator - lift - Return a
IntUnaryOperator - ignore - Return a
IntUnaryOperator
- See Also:
IntUnaryOperator
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default IntUnaryOperatorWithException<E>andThen(IntUnaryOperatorWithException<? extends E> after)Returns a composed operator that first applies this operator to its input, and then applies theafteroperator to the result.intapplyAsInt(int operand)Applies this operator to the given operand.default IntUnaryOperatorWithException<E>compose(IntUnaryOperatorWithException<? extends E> before)Returns a composed operator that first applies thebeforeoperator to its input, and then applies this operator to the result.default intdefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
IntUnaryOperatorWithException<E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.static <E extends Exception>
IntUnaryOperatorWithException<E>identity()Returns a unary operator that always returns its input argument.static <E extends Exception>
IntUnaryOperatorignored(IntUnaryOperatorWithException<E> function)Converts aIntUnaryOperatorWithExceptionto a liftedIntUnaryOperatorreturning0in case of exception.static <E extends Exception>
IntUnaryOperatorignored(IntUnaryOperatorWithException<E> function, int defaultValue)Converts aIntUnaryOperatorWithExceptionto a liftedIntUnaryOperatorreturning a default value in case of exception.static <E extends Exception>
IntUnaryOperatorlifted(IntUnaryOperatorWithException<E> function)Converts aIntUnaryOperatorWithExceptionto a liftedIntUnaryOperatorusing0as return value in case of error.static <E extends Exception>
IntUnaryOperatorunchecked(IntUnaryOperatorWithException<E> function)Converts aIntUnaryOperatorExceptionto aIntUnaryOperatorthat wraps exception toRuntimeException.static <E extends Exception>
IntUnaryOperatorunchecked(IntUnaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aIntUnaryOperatorWithExceptionto aIntUnaryOperatorthat wraps exception toRuntimeExceptionby using the provided mapping function.default IntUnaryOperatoruncheckOrIgnore(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 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:
IntUnaryOperator.applyAsInt(int)
-
uncheckOrIgnore
default IntUnaryOperator uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<IntUnaryOperator,IntUnaryOperatorWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
compose
default IntUnaryOperatorWithException<E> compose(IntUnaryOperatorWithException<? 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(IntUnaryOperatorWithException)
-
andThen
default IntUnaryOperatorWithException<E> andThen(IntUnaryOperatorWithException<? 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(IntUnaryOperatorWithException)
-
identity
static <E extends Exception> IntUnaryOperatorWithException<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> IntUnaryOperatorWithException<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> IntUnaryOperator unchecked(IntUnaryOperatorWithException<E> function)
Converts aIntUnaryOperatorExceptionto aIntUnaryOperatorthat 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(IntUnaryOperatorWithException, Function)
-
unchecked
static <E extends Exception> IntUnaryOperator unchecked(IntUnaryOperatorWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aIntUnaryOperatorWithExceptionto aIntUnaryOperatorthat 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(IntUnaryOperatorWithException)
-
lifted
static <E extends Exception> IntUnaryOperator lifted(IntUnaryOperatorWithException<E> function)
Converts aIntUnaryOperatorWithExceptionto a liftedIntUnaryOperatorusing0as 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> IntUnaryOperator ignored(IntUnaryOperatorWithException<E> function)
Converts aIntUnaryOperatorWithExceptionto a liftedIntUnaryOperatorreturning0in 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> IntUnaryOperator ignored(IntUnaryOperatorWithException<E> function, int defaultValue)
Converts aIntUnaryOperatorWithExceptionto a liftedIntUnaryOperatorreturning 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:
PrimitiveReturnExceptionHandlerSupport.ignore(),ignored(IntUnaryOperatorWithException)
-
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
-
-