Interface DoubleToLongFunctionWithException<E extends Exception>
-
- Type Parameters:
E
- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<DoubleToLongFunction,DoubleToLongFunction,DoubleToLongFunctionWithException<E>>
,PrimitiveReturnExceptionHandlerSupport<DoubleToLongFunction,DoubleToLongFunctionWithException<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 DoubleToLongFunctionWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<DoubleToLongFunction,DoubleToLongFunctionWithException<E>>
Represents a function that accepts a double-valued argument, may throw exception and produces a long-valued result. This is thedouble
-to-long
primitive specialization forFunctionWithException
.General contract
long applyAsLong(double value) throws E
- The functional method.- uncheck - Return a
DoubleToLongFunction
- lift - Return a
DoubleToLongFunction
- ignore - Return a
DoubleToLongFunction
- See Also:
DoubleToLongFunction
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description long
applyAsLong(double value)
Applies this function to the given argument.default long
defaultValue()
Defines the default value returned by the ignore and ignored method.static <E extends Exception>
DoubleToLongFunctionWithException<E>failing(Supplier<E> exceptionBuilder)
Returns a function that always throw exception.static <E extends Exception>
DoubleToLongFunctionignored(DoubleToLongFunctionWithException<E> function)
Converts aDoubleToLongFunctionWithException
to a liftedDoubleToLongFunction
returning0
in case of exception.static <E extends Exception>
DoubleToLongFunctionignored(DoubleToLongFunctionWithException<E> function, long defaultValue)
Converts aDoubleToLongFunctionWithException
to a liftedDoubleToLongFunction
returning a default value in case of exception.static <E extends Exception>
DoubleToLongFunctionlifted(DoubleToLongFunctionWithException<E> function)
Converts aDoubleToLongFunctionWithException
to a liftedDoubleToLongFunction
returning0
in case of exception.static <E extends Exception>
DoubleToLongFunctionunchecked(DoubleToLongFunctionWithException<E> function)
Converts aDoubleToLongFunctionWithException
to aDoubleToLongFunction
that convert exception toRuntimeException
.static <E extends Exception>
DoubleToLongFunctionunchecked(DoubleToLongFunctionWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aDoubleToLongFunctionWithException
to aDoubleToLongFunction
that convert exception toRuntimeException
by using the provided mapping function.default DoubleToLongFunction
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(double 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:
DoubleToLongFunction.applyAsLong(double)
-
uncheckOrIgnore
default DoubleToLongFunction uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupport
Used internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnore
in interfacePrimitiveReturnExceptionHandlerSupport<DoubleToLongFunction,DoubleToLongFunctionWithException<E extends Exception>>
- Parameters:
uncheck
- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
failing
static <E extends Exception> DoubleToLongFunctionWithException<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> DoubleToLongFunction unchecked(DoubleToLongFunctionWithException<E> function)
Converts aDoubleToLongFunctionWithException
to aDoubleToLongFunction
that convert 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(DoubleToLongFunctionWithException, Function)
-
unchecked
static <E extends Exception> DoubleToLongFunction unchecked(DoubleToLongFunctionWithException<E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aDoubleToLongFunctionWithException
to aDoubleToLongFunction
that convert exception toRuntimeException
by 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(DoubleToLongFunctionWithException)
-
lifted
static <E extends Exception> DoubleToLongFunction lifted(DoubleToLongFunctionWithException<E> function)
Converts aDoubleToLongFunctionWithException
to a liftedDoubleToLongFunction
returning0
in 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> DoubleToLongFunction ignored(DoubleToLongFunctionWithException<E> function)
Converts aDoubleToLongFunctionWithException
to a liftedDoubleToLongFunction
returning0
in 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> DoubleToLongFunction ignored(DoubleToLongFunctionWithException<E> function, long defaultValue)
Converts aDoubleToLongFunctionWithException
to a liftedDoubleToLongFunction
returning 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(DoubleToLongFunctionWithException)
-
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
-
-