Interface DoubleSupplierWithException<E extends Exception>
-
- Type Parameters:
E- the type of the potential exception of the operation
- All Superinterfaces:
ExceptionHandlerSupport<DoubleSupplier,DoubleSupplier,DoubleSupplierWithException<E>>,PrimitiveReturnExceptionHandlerSupport<DoubleSupplier,DoubleSupplierWithException<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 DoubleSupplierWithException<E extends Exception> extends PrimitiveReturnExceptionHandlerSupport<DoubleSupplier,DoubleSupplierWithException<E>>
Represents a supplier ofdouble-valued results and may throw exception. This is thedouble-producing primitive specialization ofSupplierWithException.There is no requirement that a distinct result be returned each time the supplier is invoked.
General contract
double getAsDouble() throws E- The functional method.- uncheck - Return a
DoubleSupplier - lift - Return a
DoubleSupplier - ignore - Return a
DoubleSupplier
- See Also:
DoubleSupplier
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default doubledefaultValue()Defines the default value returned by the ignore and ignored method.static <E extends Exception>
DoubleSupplierWithException<E>failing(Supplier<E> exceptionBuilder)Returns a supplier that always throw exception.doublegetAsDouble()Gets a result.static <E extends Exception>
DoubleSupplierignored(DoubleSupplierWithException<E> supplier)Converts aDoubleSupplierWithExceptionto a liftedDoubleSupplierreturning0in case of exception.static <E extends Exception>
DoubleSupplierignored(DoubleSupplierWithException<E> supplier, double defaultValue)Converts aDoubleSupplierWithExceptionto a liftedDoubleSupplierreturning a default value in case of exception.static <E extends Exception>
DoubleSupplierlifted(DoubleSupplierWithException<E> supplier)Converts aDoubleSupplierWithExceptionto a liftedDoubleSupplierreturning0in case of exception.static <E extends Exception>
DoubleSupplierunchecked(DoubleSupplierWithException<E> supplier)Converts aDoubleSupplierWithExceptionto aDoubleSupplierthat wraps exception toRuntimeException.static <E extends Exception>
DoubleSupplierunchecked(DoubleSupplierWithException<E> supplier, Function<Exception,RuntimeException> exceptionMapper)Converts aDoubleSupplierWithExceptionto aDoubleSupplierthat wraps exception toRuntimeExceptionby using the provided mapping function.default DoubleSupplieruncheckOrIgnore(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
-
getAsDouble
double getAsDouble() throws E extends Exception
Gets a result.- Returns:
- a result
- Throws:
E- any exceptionE extends Exception- See Also:
DoubleSupplier.getAsDouble()
-
uncheckOrIgnore
default DoubleSupplier uncheckOrIgnore(boolean uncheck)
Description copied from interface:PrimitiveReturnExceptionHandlerSupportUsed internally to implements the ignore or uncheck operation.- Specified by:
uncheckOrIgnorein interfacePrimitiveReturnExceptionHandlerSupport<DoubleSupplier,DoubleSupplierWithException<E extends Exception>>- Parameters:
uncheck- create unchecked version of the function when true, else ignored version.- Returns:
- the function
-
failing
static <E extends Exception> DoubleSupplierWithException<E> failing(Supplier<E> exceptionBuilder)
Returns a supplier that always throw exception.- Type Parameters:
E- the type of the exception- Parameters:
exceptionBuilder- the supplier to create the exception- Returns:
- an operation that always throw exception
-
unchecked
static <E extends Exception> DoubleSupplier unchecked(DoubleSupplierWithException<E> supplier)
Converts aDoubleSupplierWithExceptionto aDoubleSupplierthat wraps exception toRuntimeException.- Type Parameters:
E- the type of the potential exception- Parameters:
supplier- to be unchecked- Returns:
- the unchecked supplier
- Throws:
NullPointerException- if supplier is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck(),unchecked(DoubleSupplierWithException, Function)
-
unchecked
static <E extends Exception> DoubleSupplier unchecked(DoubleSupplierWithException<E> supplier, Function<Exception,RuntimeException> exceptionMapper)
Converts aDoubleSupplierWithExceptionto aDoubleSupplierthat wraps exception toRuntimeExceptionby using the provided mapping function.- Type Parameters:
E- the type of the potential exception- Parameters:
supplier- the be uncheckedexceptionMapper- a function to convert the exception to the runtime exception.- Returns:
- the unchecked supplier
- Throws:
NullPointerException- if supplier or exceptionMapper is null- See Also:
PrimitiveReturnExceptionHandlerSupport.uncheck(),unchecked(DoubleSupplierWithException)
-
lifted
static <E extends Exception> DoubleSupplier lifted(DoubleSupplierWithException<E> supplier)
Converts aDoubleSupplierWithExceptionto a liftedDoubleSupplierreturning0in case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
supplier- to be lifted- Returns:
- the lifted supplier
- Throws:
NullPointerException- if supplier is null- See Also:
PrimitiveReturnExceptionHandlerSupport.lift()
-
ignored
static <E extends Exception> DoubleSupplier ignored(DoubleSupplierWithException<E> supplier)
Converts aDoubleSupplierWithExceptionto a liftedDoubleSupplierreturning0in case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
supplier- to be lifted- Returns:
- the lifted supplier
- Throws:
NullPointerException- if supplier is null- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore()
-
ignored
static <E extends Exception> DoubleSupplier ignored(DoubleSupplierWithException<E> supplier, double defaultValue)
Converts aDoubleSupplierWithExceptionto a liftedDoubleSupplierreturning a default value in case of exception.- Type Parameters:
E- the type of the potential exception- Parameters:
supplier- to be lifteddefaultValue- the default value in case of exception- Returns:
- the lifted supplier
- Throws:
NullPointerException- if supplier is null- Since:
- 3.0.0
- See Also:
PrimitiveReturnExceptionHandlerSupport.ignore(),ignored(DoubleSupplierWithException)
-
defaultValue
default double 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
-
-