Module com.machinezoo.noexception
Interface OptionalToDoubleBiFunction<T,U>
-
- Type Parameters:
-
T
- seeToDoubleBiFunction
-
U
- seeToDoubleBiFunction
- All Superinterfaces:
-
BiFunction<T,U,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 OptionalToDoubleBiFunction<T,U> extends BiFunction<T,U,OptionalDouble>
Variation ofToDoubleBiFunction
that returnsOptionalDouble
instead of the raw value.OptionalToDoubleBiFunction
is typically obtained fromExceptionHandler.fromToDoubleBiFunction(ToDoubleBiFunction)
, in which case its return value is empty when the underlyingToDoubleBiFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDouble
apply(T t, U u)
Variation ofToDoubleBiFunction.applyAsDouble(Object, Object)
that returnsOptionalDouble
.default ToDoubleBiFunction<T,U>
orElse(double result)
Converts thisOptionalToDoubleBiFunction
to plainToDoubleBiFunction
using default value.default ToDoubleBiFunction<T,U>
orElseGet(DoubleSupplier source)
-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Method Detail
-
apply
OptionalDouble apply(T t, U u)
Variation ofToDoubleBiFunction.applyAsDouble(Object, Object)
that returnsOptionalDouble
. If thisOptionalToDoubleBiFunction
is obtained fromExceptionHandler.fromToDoubleBiFunction(ToDoubleBiFunction)
, theOptionalDouble
will be empty only if the underlyingToDoubleBiFunction
throws. Otherwise the returnedOptionalDouble
just wraps the return value of underlyingToDoubleBiFunction
.- Specified by:
-
apply
in interfaceBiFunction<T,U,OptionalDouble>
- Parameters:
-
t
- seeToDoubleBiFunction.applyAsDouble(Object, Object)
-
u
- seeToDoubleBiFunction.applyAsDouble(Object, Object)
- Returns:
-
OptionalDouble
typically wrapping return value ofToDoubleBiFunction.applyAsDouble(Object, Object)
, or an emptyOptionalDouble
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromToDoubleBiFunction(ToDoubleBiFunction)
,ToDoubleBiFunction.applyAsDouble(Object, Object)
-
orElse
default ToDoubleBiFunction<T,U> orElse(double result)
Converts thisOptionalToDoubleBiFunction
to plainToDoubleBiFunction
using default value. The returnedToDoubleBiFunction
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
ToDoubleBiFunction
that either unwrapsOptionalDouble
or returns default value - See Also:
-
orElseGet(DoubleSupplier)
,OptionalDouble.orElse(double)
-
orElseGet
default ToDoubleBiFunction<T,U> orElseGet(DoubleSupplier source)
Converts thisOptionalToDoubleBiFunction
to plainToDoubleBiFunction
using fallbackDoubleSupplier
. The returnedToDoubleBiFunction
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
ToDoubleBiFunction
that either unwrapsOptionalDouble
or falls back tosource
- See Also:
-
orElse(double)
,OptionalDouble.orElseGet(DoubleSupplier)
-
-