Module com.machinezoo.noexception
Interface OptionalDoubleToLongFunction
-
- All Superinterfaces:
-
DoubleFunction<OptionalLong>
- 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 OptionalDoubleToLongFunction extends DoubleFunction<OptionalLong>
Variation ofDoubleToLongFunction
that returnsOptionalLong
instead of the raw value.OptionalDoubleToLongFunction
is typically obtained fromExceptionHandler.fromDoubleToLongFunction(DoubleToLongFunction)
, in which case its return value is empty when the underlyingDoubleToLongFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalLong
apply(double value)
Variation ofDoubleToLongFunction.applyAsLong(double)
that returnsOptionalLong
.default DoubleToLongFunction
orElse(long result)
Converts thisOptionalDoubleToLongFunction
to plainDoubleToLongFunction
using default value.default DoubleToLongFunction
orElseGet(LongSupplier source)
Converts thisOptionalDoubleToLongFunction
to plainDoubleToLongFunction
using fallbackLongSupplier
.
-
-
-
Method Detail
-
apply
OptionalLong apply(double value)
Variation ofDoubleToLongFunction.applyAsLong(double)
that returnsOptionalLong
. If thisOptionalDoubleToLongFunction
is obtained fromExceptionHandler.fromDoubleToLongFunction(DoubleToLongFunction)
, theOptionalLong
will be empty only if the underlyingDoubleToLongFunction
throws. Otherwise the returnedOptionalLong
just wraps the return value of underlyingDoubleToLongFunction
.- Specified by:
-
apply
in interfaceDoubleFunction<OptionalLong>
- Parameters:
-
value
- seeDoubleToLongFunction.applyAsLong(double)
- Returns:
-
OptionalLong
typically wrapping return value ofDoubleToLongFunction.applyAsLong(double)
, or an emptyOptionalLong
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromDoubleToLongFunction(DoubleToLongFunction)
,DoubleToLongFunction.applyAsLong(double)
-
orElse
default DoubleToLongFunction orElse(long result)
Converts thisOptionalDoubleToLongFunction
to plainDoubleToLongFunction
using default value. The returnedDoubleToLongFunction
will unwrap present value from theOptionalLong
if possible, or returnresult
if theOptionalLong
is empty.- Parameters:
-
result
- default value to return instead of an emptyOptionalLong
- Returns:
-
plain
DoubleToLongFunction
that either unwrapsOptionalLong
or returns default value - See Also:
-
orElseGet(LongSupplier)
,OptionalLong.orElse(long)
-
orElseGet
default DoubleToLongFunction orElseGet(LongSupplier source)
Converts thisOptionalDoubleToLongFunction
to plainDoubleToLongFunction
using fallbackLongSupplier
. The returnedDoubleToLongFunction
will unwrap present value from theOptionalLong
if possible, or fall back to callingsource
if theOptionalLong
is empty.- Parameters:
-
source
-LongSupplier
to query for fallback value whenOptionalLong
is empty - Returns:
-
plain
DoubleToLongFunction
that either unwrapsOptionalLong
or falls back tosource
- See Also:
-
orElse(long)
,OptionalLong.orElseGet(LongSupplier)
-
-