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