Module com.machinezoo.noexception
Interface OptionalToDoubleFunction<T>
-
- Type Parameters:
-
T- seeToDoubleFunction
- All Superinterfaces:
-
Function<T,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 OptionalToDoubleFunction<T> extends Function<T,OptionalDouble>
Variation ofToDoubleFunctionthat returnsOptionalDoubleinstead of the raw value.OptionalToDoubleFunctionis typically obtained fromExceptionHandler.fromToDoubleFunction(ToDoubleFunction), in which case its return value is empty when the underlyingToDoubleFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDoubleapply(T value)Variation ofToDoubleFunction.applyAsDouble(Object)that returnsOptionalDouble.default ToDoubleFunction<T>orElse(double result)Converts thisOptionalToDoubleFunctionto plainToDoubleFunctionusing default value.default ToDoubleFunction<T>orElseGet(DoubleSupplier source)
-
-
-
Method Detail
-
apply
OptionalDouble apply(T value)
Variation ofToDoubleFunction.applyAsDouble(Object)that returnsOptionalDouble. If thisOptionalToDoubleFunctionis obtained fromExceptionHandler.fromToDoubleFunction(ToDoubleFunction), theOptionalDoublewill be empty only if the underlyingToDoubleFunctionthrows. Otherwise the returnedOptionalDoublejust wraps the return value of underlyingToDoubleFunction.- Specified by:
-
applyin interfaceFunction<T,OptionalDouble> - Parameters:
-
value- seeToDoubleFunction.applyAsDouble(Object) - Returns:
-
OptionalDoubletypically wrapping return value ofToDoubleFunction.applyAsDouble(Object), or an emptyOptionalDouble(typically signifying an exception) - See Also:
-
ExceptionHandler.fromToDoubleFunction(ToDoubleFunction),ToDoubleFunction.applyAsDouble(Object)
-
orElse
default ToDoubleFunction<T> orElse(double result)
Converts thisOptionalToDoubleFunctionto plainToDoubleFunctionusing default value. The returnedToDoubleFunctionwill unwrap present value from theOptionalDoubleif possible, or returnresultif theOptionalDoubleis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalDouble - Returns:
-
plain
ToDoubleFunctionthat either unwrapsOptionalDoubleor returns default value - See Also:
-
orElseGet(DoubleSupplier),OptionalDouble.orElse(double)
-
orElseGet
default ToDoubleFunction<T> orElseGet(DoubleSupplier source)
Converts thisOptionalToDoubleFunctionto plainToDoubleFunctionusing fallbackDoubleSupplier. The returnedToDoubleFunctionwill unwrap present value from theOptionalDoubleif possible, or fall back to callingsourceif theOptionalDoubleis empty.- Parameters:
-
source-DoubleSupplierto query for fallback value whenOptionalDoubleis empty - Returns:
-
plain
ToDoubleFunctionthat either unwrapsOptionalDoubleor falls back tosource - See Also:
-
orElse(double),OptionalDouble.orElseGet(DoubleSupplier)
-
-