Module com.machinezoo.noexception
Interface OptionalDoubleUnaryOperator
-
- All Superinterfaces:
-
DoubleFunction<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 OptionalDoubleUnaryOperator extends DoubleFunction<OptionalDouble>
Variation ofDoubleUnaryOperator
that returnsOptionalDouble
instead of the raw value.OptionalDoubleUnaryOperator
is typically obtained fromExceptionHandler.fromDoubleUnaryOperator(DoubleUnaryOperator)
, in which case its return value is empty when the underlyingDoubleUnaryOperator
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDouble
apply(double operand)
Variation ofDoubleUnaryOperator.applyAsDouble(double)
that returnsOptionalDouble
.default DoubleUnaryOperator
orElse(double result)
Converts thisOptionalDoubleUnaryOperator
to plainDoubleUnaryOperator
using default value.default DoubleUnaryOperator
orElseGet(DoubleSupplier source)
Converts thisOptionalDoubleUnaryOperator
to plainDoubleUnaryOperator
using fallbackDoubleSupplier
.
-
-
-
Method Detail
-
apply
OptionalDouble apply(double operand)
Variation ofDoubleUnaryOperator.applyAsDouble(double)
that returnsOptionalDouble
. If thisOptionalDoubleUnaryOperator
is obtained fromExceptionHandler.fromDoubleUnaryOperator(DoubleUnaryOperator)
, theOptionalDouble
will be empty only if the underlyingDoubleUnaryOperator
throws. Otherwise the returnedOptionalDouble
just wraps the return value of underlyingDoubleUnaryOperator
.- Specified by:
-
apply
in interfaceDoubleFunction<OptionalDouble>
- Parameters:
-
operand
- seeDoubleUnaryOperator.applyAsDouble(double)
- Returns:
-
OptionalDouble
typically wrapping return value ofDoubleUnaryOperator.applyAsDouble(double)
, or an emptyOptionalDouble
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromDoubleUnaryOperator(DoubleUnaryOperator)
,DoubleUnaryOperator.applyAsDouble(double)
-
orElse
default DoubleUnaryOperator orElse(double result)
Converts thisOptionalDoubleUnaryOperator
to plainDoubleUnaryOperator
using default value. The returnedDoubleUnaryOperator
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
DoubleUnaryOperator
that either unwrapsOptionalDouble
or returns default value - See Also:
-
orElseGet(DoubleSupplier)
,OptionalDouble.orElse(double)
-
orElseGet
default DoubleUnaryOperator orElseGet(DoubleSupplier source)
Converts thisOptionalDoubleUnaryOperator
to plainDoubleUnaryOperator
using fallbackDoubleSupplier
. The returnedDoubleUnaryOperator
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
DoubleUnaryOperator
that either unwrapsOptionalDouble
or falls back tosource
- See Also:
-
orElse(double)
,OptionalDouble.orElseGet(DoubleSupplier)
-
-