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 ofIntToDoubleFunction
that returnsOptionalDouble
instead of the raw value.OptionalIntToDoubleFunction
is typically obtained fromExceptionHandler.fromIntToDoubleFunction(IntToDoubleFunction)
, in which case its return value is empty when the underlyingIntToDoubleFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDouble
apply(int value)
Variation ofIntToDoubleFunction.applyAsDouble(int)
that returnsOptionalDouble
.default IntToDoubleFunction
orElse(double result)
Converts thisOptionalIntToDoubleFunction
to plainIntToDoubleFunction
using default value.default IntToDoubleFunction
orElseGet(DoubleSupplier source)
Converts thisOptionalIntToDoubleFunction
to plainIntToDoubleFunction
using fallbackDoubleSupplier
.
-
-
-
Method Detail
-
apply
OptionalDouble apply(int value)
Variation ofIntToDoubleFunction.applyAsDouble(int)
that returnsOptionalDouble
. If thisOptionalIntToDoubleFunction
is obtained fromExceptionHandler.fromIntToDoubleFunction(IntToDoubleFunction)
, theOptionalDouble
will be empty only if the underlyingIntToDoubleFunction
throws. Otherwise the returnedOptionalDouble
just wraps the return value of underlyingIntToDoubleFunction
.- Specified by:
-
apply
in interfaceIntFunction<OptionalDouble>
- Parameters:
-
value
- seeIntToDoubleFunction.applyAsDouble(int)
- Returns:
-
OptionalDouble
typically 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 thisOptionalIntToDoubleFunction
to plainIntToDoubleFunction
using default value. The returnedIntToDoubleFunction
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
IntToDoubleFunction
that either unwrapsOptionalDouble
or returns default value - See Also:
-
orElseGet(DoubleSupplier)
,OptionalDouble.orElse(double)
-
orElseGet
default IntToDoubleFunction orElseGet(DoubleSupplier source)
Converts thisOptionalIntToDoubleFunction
to plainIntToDoubleFunction
using fallbackDoubleSupplier
. The returnedIntToDoubleFunction
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
IntToDoubleFunction
that either unwrapsOptionalDouble
or falls back tosource
- See Also:
-
orElse(double)
,OptionalDouble.orElseGet(DoubleSupplier)
-
-