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