Module com.machinezoo.noexception
Interface OptionalIntToDoubleFunction
-
- All Superinterfaces:
-
IntFunction<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 OptionalIntToDoubleFunction extends IntFunction<OptionalDouble>
Variation ofIntToDoubleFunctionthat returnsOptionalDoubleinstead of the raw value.OptionalIntToDoubleFunctionis typically obtained fromExceptionHandler.fromIntToDoubleFunction(IntToDoubleFunction), in which case its return value is empty when the underlyingIntToDoubleFunctionthrows an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDoubleapply(int value)Variation ofIntToDoubleFunction.applyAsDouble(int)that returnsOptionalDouble.default IntToDoubleFunctionorElse(double result)Converts thisOptionalIntToDoubleFunctionto plainIntToDoubleFunctionusing default value.default IntToDoubleFunctionorElseGet(DoubleSupplier source)Converts thisOptionalIntToDoubleFunctionto plainIntToDoubleFunctionusing fallbackDoubleSupplier.
-
-
-
Method Detail
-
apply
OptionalDouble apply(int value)
Variation ofIntToDoubleFunction.applyAsDouble(int)that returnsOptionalDouble. If thisOptionalIntToDoubleFunctionis obtained fromExceptionHandler.fromIntToDoubleFunction(IntToDoubleFunction), theOptionalDoublewill be empty only if the underlyingIntToDoubleFunctionthrows. Otherwise the returnedOptionalDoublejust wraps the return value of underlyingIntToDoubleFunction.- Specified by:
-
applyin interfaceIntFunction<OptionalDouble> - Parameters:
-
value- seeIntToDoubleFunction.applyAsDouble(int) - Returns:
-
OptionalDoubletypically wrapping return value ofIntToDoubleFunction.applyAsDouble(int), or an emptyOptionalDouble(typically signifying an exception) - See Also:
-
ExceptionHandler.fromIntToDoubleFunction(IntToDoubleFunction),IntToDoubleFunction.applyAsDouble(int)
-
orElse
default IntToDoubleFunction orElse(double result)
Converts thisOptionalIntToDoubleFunctionto plainIntToDoubleFunctionusing default value. The returnedIntToDoubleFunctionwill unwrap present value from theOptionalDoubleif possible, or returnresultif theOptionalDoubleis empty.- Parameters:
-
result- default value to return instead of an emptyOptionalDouble - Returns:
-
plain
IntToDoubleFunctionthat either unwrapsOptionalDoubleor returns default value - See Also:
-
orElseGet(DoubleSupplier),OptionalDouble.orElse(double)
-
orElseGet
default IntToDoubleFunction orElseGet(DoubleSupplier source)
Converts thisOptionalIntToDoubleFunctionto plainIntToDoubleFunctionusing fallbackDoubleSupplier. The returnedIntToDoubleFunctionwill unwrap present value from theOptionalDoubleif possible, or fall back to callingsourceif theOptionalDoubleis empty.- Parameters:
-
source-DoubleSupplierto query for fallback value whenOptionalDoubleis empty - Returns:
-
plain
IntToDoubleFunctionthat either unwrapsOptionalDoubleor falls back tosource - See Also:
-
orElse(double),OptionalDouble.orElseGet(DoubleSupplier)
-
-