Interface LongToIntFunctionWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<LongToIntFunction,LongToIntFunction,LongToIntFunctionWithException<E>>,PrimitiveReturnExceptionHandlerSupport<LongToIntFunction,LongToIntFunctionWithException<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 LongToIntFunctionWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<LongToIntFunction,LongToIntFunctionWithException<E>>
Represents a function that accepts a long-valued argument, may throw exception and produces an int-valued result. This is thelong-to-intprimitive specialization forFunctionWithException.General contract
int applyAsInt(long value) throws E- The functional method.- uncheck - Return a
LongToIntFunction - lift - Return a
LongToIntFunction - ignore - Return a
LongToIntFunction
- See Also:
LongToIntFunction
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intapplyAsInt(long value)Applies this function to the given argument.default intdefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
LongToIntFunctionWithException<E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.default LongToIntFunctionignore()Converts thisLongToIntFunctionWithExceptionto a liftedLongToIntFunctionreturning0in case of exception.static <E extends Exception>
LongToIntFunctionignored(LongToIntFunctionWithException<E> function)Converts aLongToIntFunctionWithExceptionto a liftedLongToIntFunctionreturning0in case of exception.static <E extends Exception>
LongToIntFunctionignored(LongToIntFunctionWithException<E> function, int defaultValue)Converts aLongToIntFunctionWithExceptionto a liftedLongToIntFunctionreturning a default value in case of exception.static <E extends Exception>
LongToIntFunctionlifted(LongToIntFunctionWithException<E> function)Converts aLongToIntFunctionWithExceptionto a liftedLongToIntFunctionreturning0in case of exception.default LongToIntFunctionuncheck()Converts thisLongToIntFunctionWithExceptionto aLongToIntFunctionthat wraps exception toRuntimeException.static <E extends Exception>
LongToIntFunctionunchecked(LongToIntFunctionWithException<E> function)Converts aLongToIntFunctionWithExceptionto aLongToIntFunctionthat wraps exception toRuntimeException.static <E extends Exception>
LongToIntFunctionunchecked(LongToIntFunctionWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aLongToIntFunctionWithExceptionto aLongToIntFunctionthat wraps exception toRuntimeExceptionby using the provided mapping function.default LongToIntFunctionuncheckOrIgnore(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
-
applyAsInt
int applyAsInt(long value) throws E extends Exception
Applies this function to the given argument.- Parameters:
value- the function argument- Returns:
- the function result
- Throws:
E- any exceptionE extends Exception- See Also:
LongToIntFunction.applyAsInt(long)
-
uncheckOrIgnore
default LongToIntFunction uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<LongToIntFunction,LongToIntFunctionWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
uncheck
default LongToIntFunction uncheck()
Converts thisLongToIntFunctionWithExceptionto aLongToIntFunctionthat wraps exception toRuntimeException.- Specified by:
uncheckin interfaceExceptionHandlerSupport<LongToIntFunction,LongToIntFunction,LongToIntFunctionWithException<E extends Exception>>- Specified by:
uncheckin interfacePrimitiveReturnExceptionHandlerSupport<LongToIntFunction,LongToIntFunctionWithException<E extends Exception>>- Returns:
- the unchecked function
- See Also:
unchecked(LongToIntFunctionWithException),unchecked(LongToIntFunctionWithException, Function)
-
ignore
default LongToIntFunction ignore()
Converts thisLongToIntFunctionWithExceptionto a liftedLongToIntFunctionreturning0in case of exception.- Specified by:
ignorein interfaceExceptionHandlerSupport<LongToIntFunction,LongToIntFunction,LongToIntFunctionWithException<E extends Exception>>- Specified by:
ignorein interfacePrimitiveReturnExceptionHandlerSupport<LongToIntFunction,LongToIntFunctionWithException<E extends Exception>>- Returns:
- the ignoring function
- See Also:
ignored(LongToIntFunctionWithException)
-
failing
static <E extends Exception> LongToIntFunctionWithException<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> LongToIntFunction unchecked(LongToIntFunctionWithException<E> function)
Converts aLongToIntFunctionWithExceptionto aLongToIntFunctionthat 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(LongToIntFunctionWithException, Function)
-
unchecked
static <E extends Exception> LongToIntFunction unchecked(LongToIntFunctionWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aLongToIntFunctionWithExceptionto aLongToIntFunctionthat 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(LongToIntFunctionWithException)
-
lifted
static <E extends Exception> LongToIntFunction lifted(LongToIntFunctionWithException<E> function)
Converts aLongToIntFunctionWithExceptionto a liftedLongToIntFunctionreturning0in 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> LongToIntFunction ignored(LongToIntFunctionWithException<E> function)
Converts aLongToIntFunctionWithExceptionto a liftedLongToIntFunctionreturning0in 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> LongToIntFunction ignored(LongToIntFunctionWithException<E> function, int defaultValue)
Converts aLongToIntFunctionWithExceptionto a liftedLongToIntFunctionreturning 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(LongToIntFunctionWithException)
-
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
-
-