@FunctionalInterface public interface OptionalLongToDoubleFunction extends LongFunction<OptionalDouble>
LongToDoubleFunction
that returns OptionalDouble
instead of the raw value. OptionalLongToDoubleFunction
is typically obtained from ExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction)
, in which case its return value is empty when the underlying LongToDoubleFunction
throws an exception. See noexception tutorial.
Modifier and Type | Method and Description |
---|---|
OptionalDouble |
apply(long value)
Variation of LongToDoubleFunction.applyAsDouble(long) that returns OptionalDouble .
|
default LongToDoubleFunction |
orElse(double result)
Converts this OptionalLongToDoubleFunction to plain LongToDoubleFunction using default value.
|
default LongToDoubleFunction |
orElseGet(DoubleSupplier source)
Converts this OptionalLongToDoubleFunction to plain LongToDoubleFunction using fallback DoubleSupplier .
|
OptionalDouble apply(long value)
LongToDoubleFunction.applyAsDouble(long)
that returns OptionalDouble
. If this OptionalLongToDoubleFunction
is obtained from ExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction)
, the OptionalDouble
will be empty only if the underlying LongToDoubleFunction
throws. Otherwise the returned OptionalDouble
just wraps the return value of underlying LongToDoubleFunction
.
apply
in interface LongFunction<OptionalDouble>
value
- see LongToDoubleFunction.applyAsDouble(long)
OptionalDouble
typically wrapping return value of LongToDoubleFunction.applyAsDouble(long)
, or an empty OptionalDouble
(typically signifying an exception)
ExceptionHandler.fromLongToDoubleFunction(LongToDoubleFunction)
, LongToDoubleFunction.applyAsDouble(long)
default LongToDoubleFunction orElse(double result)
OptionalLongToDoubleFunction
to plain LongToDoubleFunction
using default value. The returned LongToDoubleFunction
will unwrap present value from the OptionalDouble
if possible, or return result
if the OptionalDouble
is empty.
result
- default value to return instead of an empty OptionalDouble
LongToDoubleFunction
that either unwraps OptionalDouble
or returns default value
orElseGet(DoubleSupplier)
, OptionalDouble.orElse(double)
default LongToDoubleFunction orElseGet(DoubleSupplier source)
OptionalLongToDoubleFunction
to plain LongToDoubleFunction
using fallback DoubleSupplier
. The returned LongToDoubleFunction
will unwrap present value from the OptionalDouble
if possible, or fall back to calling source
if the OptionalDouble
is empty.
source
- DoubleSupplier
to query for fallback value when OptionalDouble
is empty
LongToDoubleFunction
that either unwraps OptionalDouble
or falls back to source
orElse(double)
, OptionalDouble.orElseGet(DoubleSupplier)
Copyright © 2017–2020 Robert Važan. All rights reserved.