Module com.machinezoo.noexception
Interface OptionalLongToDoubleFunction
-
- All Superinterfaces:
-
LongFunction<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 OptionalLongToDoubleFunction extends LongFunction<OptionalDouble>
Variation ofLongToDoubleFunction
that returnsOptionalDouble
instead of the raw value.OptionalLongToDoubleFunction
is typically obtained fromExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction)
, in which case its return value is empty when the underlyingLongToDoubleFunction
throws an exception. See noexception tutorial.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OptionalDouble
apply(long value)
Variation ofLongToDoubleFunction.applyAsDouble(long)
that returnsOptionalDouble
.default LongToDoubleFunction
orElse(double result)
Converts thisOptionalLongToDoubleFunction
to plainLongToDoubleFunction
using default value.default LongToDoubleFunction
orElseGet(DoubleSupplier source)
Converts thisOptionalLongToDoubleFunction
to plainLongToDoubleFunction
using fallbackDoubleSupplier
.
-
-
-
Method Detail
-
apply
OptionalDouble apply(long value)
Variation ofLongToDoubleFunction.applyAsDouble(long)
that returnsOptionalDouble
. If thisOptionalLongToDoubleFunction
is obtained fromExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction)
, theOptionalDouble
will be empty only if the underlyingLongToDoubleFunction
throws. Otherwise the returnedOptionalDouble
just wraps the return value of underlyingLongToDoubleFunction
.- Specified by:
-
apply
in interfaceLongFunction<OptionalDouble>
- Parameters:
-
value
- seeLongToDoubleFunction.applyAsDouble(long)
- Returns:
-
OptionalDouble
typically wrapping return value ofLongToDoubleFunction.applyAsDouble(long)
, or an emptyOptionalDouble
(typically signifying an exception) - See Also:
-
ExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction)
,LongToDoubleFunction.applyAsDouble(long)
-
orElse
default LongToDoubleFunction orElse(double result)
Converts thisOptionalLongToDoubleFunction
to plainLongToDoubleFunction
using default value. The returnedLongToDoubleFunction
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
LongToDoubleFunction
that either unwrapsOptionalDouble
or returns default value - See Also:
-
orElseGet(DoubleSupplier)
,OptionalDouble.orElse(double)
-
orElseGet
default LongToDoubleFunction orElseGet(DoubleSupplier source)
Converts thisOptionalLongToDoubleFunction
to plainLongToDoubleFunction
using fallbackDoubleSupplier
. The returnedLongToDoubleFunction
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
LongToDoubleFunction
that either unwrapsOptionalDouble
or falls back tosource
- See Also:
-
orElse(double)
,OptionalDouble.orElseGet(DoubleSupplier)
-
-