Interface ToLongFunctionWithException<T,E extends Exception>
-
- Type Parameters:
T- the type of the input to the functionE- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<ToLongFunction<T>,ToLongFunction<T>,ToLongFunctionWithException<T,E>>,PrimitiveReturnExceptionHandlerSupport<ToLongFunction<T>,ToLongFunctionWithException<T,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 ToLongFunctionWithException<T,E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<ToLongFunction<T>,ToLongFunctionWithException<T,E>>
Represents a function that produces a long-valued result and may throw exception. This is thelong-producing primitive specialization forFunctionWithException.General contract
long applyAsLong(T value) throws E- The functional method.- uncheck - Return a
ToLongFunction<T> - lift - Return a
ToLongFunction<T> - ignore - Return a
ToLongFunction<T>
- See Also:
ToLongFunction
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description longapplyAsLong(T value)Applies this function to the given argument.default longdefaultValue()Defines the default value returned by the ignore and ignored method.static <T,E extends Exception>
ToLongFunctionWithException<T,E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.static <T,E extends Exception>
ToLongFunction<T>ignored(ToLongFunctionWithException<T,E> function)Converts aToLongFunctionWithExceptionto a liftedToLongFunctionreturning0in case of exception.static <T,E extends Exception>
ToLongFunction<T>ignored(ToLongFunctionWithException<T,E> function, long defaultValue)Converts aToLongFunctionWithExceptionto a liftedToLongFunctionreturning a default value in case of exception.static <T,E extends Exception>
ToLongFunction<T>lifted(ToLongFunctionWithException<T,E> function)Converts aToLongFunctionWithExceptionto a liftedToLongFunctionreturning0in case of exception.static <T,E extends Exception>
ToLongFunction<T>unchecked(ToLongFunctionWithException<T,E> function)Converts aToLongFunctionExceptionto aToLongFunctionthat wraps exception toRuntimeException.static <T,E extends Exception>
ToLongFunction<T>unchecked(ToLongFunctionWithException<T,E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aToLongFunctionWithExceptionto aToLongFunctionthat wraps exception toRuntimeExceptionby using the provided mapping function.default ToLongFunction<T>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
-
applyAsLong
long applyAsLong(T 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:
ToLongFunction.applyAsLong(Object)
-
uncheckOrIgnore
default ToLongFunction<T> uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<T,E extends Exception>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
failing
static <T,E extends Exception> ToLongFunctionWithException<T,E> failing(Supplier<E> exceptionBuilder)
Returns a function that always throw exception.- Type Parameters:
T- the type of the input object to the functionE- the type of the exception- Parameters:
exceptionBuilder- the supplier to create the exception- Returns:
- a function that always throw exception
-
unchecked
static <T,E extends Exception> ToLongFunction<T> unchecked(ToLongFunctionWithException<T,E> function)
Converts aToLongFunctionExceptionto aToLongFunctionthat wraps exception toRuntimeException.- Type Parameters:
T- the type of the input object to the functionE- the type of the potential exception- Parameters:
function- to be unchecked- Returns:
- the unchecked exception
- Throws:
NullPointerException- if function is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck(),unchecked(ToLongFunctionWithException, Function)
-
unchecked
static <T,E extends Exception> ToLongFunction<T> unchecked(ToLongFunctionWithException<T,E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aToLongFunctionWithExceptionto aToLongFunctionthat wraps exception toRuntimeExceptionby using the provided mapping function.- Type Parameters:
T- the type of the input object to the functionE- 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(ToLongFunctionWithException)
-
lifted
static <T,E extends Exception> ToLongFunction<T> lifted(ToLongFunctionWithException<T,E> function)
Converts aToLongFunctionWithExceptionto a liftedToLongFunctionreturning0in case of exception.- Type Parameters:
T- the type of the input object to the functionE- 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 <T,E extends Exception> ToLongFunction<T> ignored(ToLongFunctionWithException<T,E> function)
Converts aToLongFunctionWithExceptionto a liftedToLongFunctionreturning0in case of exception.- Type Parameters:
T- the type of the input object to the functionE- 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 <T,E extends Exception> ToLongFunction<T> ignored(ToLongFunctionWithException<T,E> function, long defaultValue)
Converts aToLongFunctionWithExceptionto a liftedToLongFunctionreturning a default value in case of exception.- Type Parameters:
T- the type of the input object to the functionE- the type of the potential exception- Parameters:
function- to be lifteddefaultValue- value to be returned in case of exception- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore(),ignored(ToLongFunctionWithException)
-
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
-
-