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 ofToDoubleBiFunctionthat returnsOptionalDoubleinstead of the raw value.OptionalToDoubleBiFunctionis typically obtained fromExceptionHandler.fromToDoubleBiFunction(ToDoubleBiFunction), in which case its return value is empty when the underlyingToDoubleBiFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDoubleapply(T t, U u)Variation ofToDoubleBiFunction.applyAsDouble(Object, Object)that returnsOptionalDouble.default ToDoubleBiFunction<T,U>orElse(double result)Converts thisOptionalToDoubleBiFunctionto plainToDoubleBiFunctionusing 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 thisOptionalToDoubleBiFunctionis obtained fromExceptionHandler.fromToDoubleBiFunction(ToDoubleBiFunction), theOptionalDoublewill be empty only if the underlyingToDoubleBiFunctionthrows. Otherwise the returnedOptionalDoublejust wraps the return value of underlyingToDoubleBiFunction.- Specified by:
-
applyin interfaceBiFunction<T,U,OptionalDouble> - Parameters:
-
t- seeToDoubleBiFunction.applyAsDouble(Object, Object) -
u- seeToDoubleBiFunction.applyAsDouble(Object, Object) - Returns:
-
OptionalDoubletypically 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 thisOptionalToDoubleBiFunctionto plainToDoubleBiFunctionusing default value. The returnedToDoubleBiFunctionwill unwrap present value from theOptionalDoubleif possible, or returnresultif theOptionalDoubleis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalDouble - Returns:
-
plain
ToDoubleBiFunctionthat either unwrapsOptionalDoubleor returns default value - See Also:
-
orElseGet(DoubleSupplier),OptionalDouble.orElse(double)
-
orElseGet
default ToDoubleBiFunction<T,U> orElseGet(DoubleSupplier source)
Converts thisOptionalToDoubleBiFunctionto plainToDoubleBiFunctionusing fallbackDoubleSupplier. The returnedToDoubleBiFunctionwill unwrap present value from theOptionalDoubleif possible, or fall back to callingsourceif theOptionalDoubleis empty.- Parameters:
-
source-DoubleSupplierto query for fallback value whenOptionalDoubleis empty - Returns:
-
plain
ToDoubleBiFunctionthat either unwrapsOptionalDoubleor falls back tosource - See Also:
-
orElse(double),OptionalDouble.orElseGet(DoubleSupplier)
-
-