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 ofDoubleSupplierthat returnsOptionalDoubleinstead of the raw value.OptionalDoubleSupplieris typically obtained fromExceptionHandler.fromDoubleSupplier(DoubleSupplier), in which case its return value is empty when the underlyingDoubleSupplierthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDoubleget()Variation ofDoubleSupplier.getAsDouble()that returnsOptionalDouble.default DoubleSupplierorElse(double result)Converts thisOptionalDoubleSupplierto plainDoubleSupplierusing default value.default DoubleSupplierorElseGet(DoubleSupplier source)
-
-
-
Method Detail
-
get
OptionalDouble get()
Variation ofDoubleSupplier.getAsDouble()that returnsOptionalDouble. If thisOptionalDoubleSupplieris obtained fromExceptionHandler.fromDoubleSupplier(DoubleSupplier), theOptionalDoublewill be empty only if the underlyingDoubleSupplierthrows. Otherwise the returnedOptionalDoublejust wraps the return value of underlyingDoubleSupplier.- Specified by:
-
getin interfaceSupplier<OptionalDouble> - Returns:
-
OptionalDoubletypically 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 thisOptionalDoubleSupplierto plainDoubleSupplierusing default value. The returnedDoubleSupplierwill unwrap present value from theOptionalDoubleif possible, or returnresultif theOptionalDoubleis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalDouble - Returns:
-
plain
DoubleSupplierthat either unwrapsOptionalDoubleor returns default value - See Also:
-
orElseGet(DoubleSupplier),OptionalDouble.orElse(double)
-
orElseGet
default DoubleSupplier orElseGet(DoubleSupplier source)
Converts thisOptionalDoubleSupplierto plainDoubleSupplierusing fallbackDoubleSupplier. The returnedDoubleSupplierwill unwrap present value from theOptionalDoubleif possible, or fall back to callingsourceif theOptionalDoubleis empty.- Parameters:
-
source-DoubleSupplierto query for fallback value whenOptionalDoubleis empty - Returns:
-
plain
DoubleSupplierthat either unwrapsOptionalDoubleor falls back tosource - See Also:
-
orElse(double),OptionalDouble.orElseGet(DoubleSupplier)
-
-