Module com.machinezoo.noexception
Interface OptionalDoubleSupplier
-
- All Superinterfaces:
-
Supplier<OptionalDouble>
- 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 OptionalDoubleSupplier extends Supplier<OptionalDouble>
Variation ofDoubleSupplier
that returnsOptionalDouble
instead of the raw value.OptionalDoubleSupplier
is typically obtained fromExceptionHandler.fromDoubleSupplier(DoubleSupplier)
, in which case its return value is empty when the underlyingDoubleSupplier
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDouble
get()
Variation ofDoubleSupplier.getAsDouble()
that returnsOptionalDouble
.default DoubleSupplier
orElse(double result)
Converts thisOptionalDoubleSupplier
to plainDoubleSupplier
using default value.default DoubleSupplier
orElseGet(DoubleSupplier source)
-
-
-
Method Detail
-
get
OptionalDouble get()
Variation ofDoubleSupplier.getAsDouble()
that returnsOptionalDouble
. If thisOptionalDoubleSupplier
is obtained fromExceptionHandler.fromDoubleSupplier(DoubleSupplier)
, theOptionalDouble
will be empty only if the underlyingDoubleSupplier
throws. Otherwise the returnedOptionalDouble
just wraps the return value of underlyingDoubleSupplier
.- Specified by:
-
get
in interfaceSupplier<OptionalDouble>
- Returns:
-
OptionalDouble
typically wrapping return value ofDoubleSupplier.getAsDouble()
, or an emptyOptionalDouble
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromDoubleSupplier(DoubleSupplier)
,DoubleSupplier.getAsDouble()
-
orElse
default DoubleSupplier orElse(double result)
Converts thisOptionalDoubleSupplier
to plainDoubleSupplier
using default value. The returnedDoubleSupplier
will unwrap present value from theOptionalDouble
if possible, or returnresult
if theOptionalDouble
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalDouble
- Returns:
-
plain
DoubleSupplier
that either unwrapsOptionalDouble
or returns default value - See Also:
-
orElseGet(DoubleSupplier)
,OptionalDouble.orElse(double)
-
orElseGet
default DoubleSupplier orElseGet(DoubleSupplier source)
Converts thisOptionalDoubleSupplier
to plainDoubleSupplier
using fallbackDoubleSupplier
. The returnedDoubleSupplier
will unwrap present value from theOptionalDouble
if possible, or fall back to callingsource
if theOptionalDouble
is empty.- Parameters:
-
source
-DoubleSupplier
to query for fallback value whenOptionalDouble
is empty - Returns:
-
plain
DoubleSupplier
that either unwrapsOptionalDouble
or falls back tosource
- See Also:
-
orElse(double)
,OptionalDouble.orElseGet(DoubleSupplier)
-
-