Module com.machinezoo.noexception
Interface OptionalDoubleToIntFunction
-
- All Superinterfaces:
-
DoubleFunction<OptionalInt>
- 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 OptionalDoubleToIntFunction extends DoubleFunction<OptionalInt>
Variation ofDoubleToIntFunction
that returnsOptionalInt
instead of the raw value.OptionalDoubleToIntFunction
is typically obtained fromExceptionHandler.fromDoubleToIntFunction(DoubleToIntFunction)
, in which case its return value is empty when the underlyingDoubleToIntFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalInt
apply(double value)
Variation ofDoubleToIntFunction.applyAsInt(double)
that returnsOptionalInt
.default DoubleToIntFunction
orElse(int result)
Converts thisOptionalDoubleToIntFunction
to plainDoubleToIntFunction
using default value.default DoubleToIntFunction
orElseGet(IntSupplier source)
-
-
-
Method Detail
-
apply
OptionalInt apply(double value)
Variation ofDoubleToIntFunction.applyAsInt(double)
that returnsOptionalInt
. If thisOptionalDoubleToIntFunction
is obtained fromExceptionHandler.fromDoubleToIntFunction(DoubleToIntFunction)
, theOptionalInt
will be empty only if the underlyingDoubleToIntFunction
throws. Otherwise the returnedOptionalInt
just wraps the return value of underlyingDoubleToIntFunction
.- Specified by:
-
apply
in interfaceDoubleFunction<OptionalInt>
- Parameters:
-
value
- seeDoubleToIntFunction.applyAsInt(double)
- Returns:
-
OptionalInt
typically wrapping return value ofDoubleToIntFunction.applyAsInt(double)
, or an emptyOptionalInt
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromDoubleToIntFunction(DoubleToIntFunction)
,DoubleToIntFunction.applyAsInt(double)
-
orElse
default DoubleToIntFunction orElse(int result)
Converts thisOptionalDoubleToIntFunction
to plainDoubleToIntFunction
using default value. The returnedDoubleToIntFunction
will unwrap present value from theOptionalInt
if possible, or returnresult
if theOptionalInt
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalInt
- Returns:
-
plain
DoubleToIntFunction
that either unwrapsOptionalInt
or returns default value - See Also:
-
orElseGet(IntSupplier)
,OptionalInt.orElse(int)
-
orElseGet
default DoubleToIntFunction orElseGet(IntSupplier source)
Converts thisOptionalDoubleToIntFunction
to plainDoubleToIntFunction
using fallbackIntSupplier
. The returnedDoubleToIntFunction
will unwrap present value from theOptionalInt
if possible, or fall back to callingsource
if theOptionalInt
is empty.- Parameters:
-
source
-IntSupplier
to query for fallback value whenOptionalInt
is empty - Returns:
-
plain
DoubleToIntFunction
that either unwrapsOptionalInt
or falls back tosource
- See Also:
-
orElse(int)
,OptionalInt.orElseGet(IntSupplier)
-
-