Module com.machinezoo.noexception
Interface OptionalDoubleBinaryOperator
-
- 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 OptionalDoubleBinaryOperator
Variation ofDoubleBinaryOperator
that returnsOptionalDouble
instead of the raw value.OptionalDoubleBinaryOperator
is typically obtained fromExceptionHandler.fromDoubleBinaryOperator(DoubleBinaryOperator)
, in which case its return value is empty when the underlyingDoubleBinaryOperator
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDouble
apply(double left, double right)
Variation ofDoubleBinaryOperator.applyAsDouble(double, double)
that returnsOptionalDouble
.default DoubleBinaryOperator
orElse(double result)
Converts thisOptionalDoubleBinaryOperator
to plainDoubleBinaryOperator
using default value.default DoubleBinaryOperator
orElseGet(DoubleSupplier source)
Converts thisOptionalDoubleBinaryOperator
to plainDoubleBinaryOperator
using fallbackDoubleSupplier
.
-
-
-
Method Detail
-
apply
OptionalDouble apply(double left, double right)
Variation ofDoubleBinaryOperator.applyAsDouble(double, double)
that returnsOptionalDouble
. If thisOptionalDoubleBinaryOperator
is obtained fromExceptionHandler.fromDoubleBinaryOperator(DoubleBinaryOperator)
, theOptionalDouble
will be empty only if the underlyingDoubleBinaryOperator
throws. Otherwise the returnedOptionalDouble
just wraps the return value of underlyingDoubleBinaryOperator
.- Parameters:
-
left
- seeDoubleBinaryOperator.applyAsDouble(double, double)
-
right
- seeDoubleBinaryOperator.applyAsDouble(double, double)
- Returns:
-
OptionalDouble
typically wrapping return value ofDoubleBinaryOperator.applyAsDouble(double, double)
, or an emptyOptionalDouble
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromDoubleBinaryOperator(DoubleBinaryOperator)
,DoubleBinaryOperator.applyAsDouble(double, double)
-
orElse
default DoubleBinaryOperator orElse(double result)
Converts thisOptionalDoubleBinaryOperator
to plainDoubleBinaryOperator
using default value. The returnedDoubleBinaryOperator
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
DoubleBinaryOperator
that either unwrapsOptionalDouble
or returns default value - See Also:
-
orElseGet(DoubleSupplier)
,OptionalDouble.orElse(double)
-
orElseGet
default DoubleBinaryOperator orElseGet(DoubleSupplier source)
Converts thisOptionalDoubleBinaryOperator
to plainDoubleBinaryOperator
using fallbackDoubleSupplier
. The returnedDoubleBinaryOperator
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
DoubleBinaryOperator
that either unwrapsOptionalDouble
or falls back tosource
- See Also:
-
orElse(double)
,OptionalDouble.orElseGet(DoubleSupplier)
-
-