| Modifier and Type | Method and Description |
|---|---|
<R> R |
custom(Function<OptionalDouble,R> function)
Applies custom operator on
OptionalDouble. |
static OptionalDouble |
empty()
Returns an empty
OptionalDouble instance. |
boolean |
equals(Object obj) |
OptionalDouble |
executeIfAbsent(Runnable action)
Invokes action function if value is absent.
|
OptionalDouble |
executeIfPresent(DoubleConsumer consumer)
Invokes consumer function with the value if present.
|
OptionalDouble |
filter(DoublePredicate predicate)
Performs filtering on inner value if it is present.
|
OptionalDouble |
filterNot(DoublePredicate predicate)
Performs negated filtering on inner value if it is present.
|
double |
getAsDouble()
Returns an inner value if present, otherwise throws
NoSuchElementException. |
int |
hashCode() |
void |
ifPresent(DoubleConsumer consumer)
Invokes consumer function with value if present, otherwise does nothing.
|
void |
ifPresentOrElse(DoubleConsumer consumer,
Runnable emptyAction)
If a value is present, performs the given action with the value,
otherwise performs the empty-based action.
|
boolean |
isPresent()
Checks value present.
|
OptionalDouble |
map(DoubleUnaryOperator mapper)
Invokes the given mapping function on inner value if present.
|
OptionalInt |
mapToInt(DoubleToIntFunction mapper)
Invokes the given mapping function on inner value if present.
|
OptionalLong |
mapToLong(DoubleToLongFunction mapper)
Invokes the given mapping function on inner value if present.
|
<U> Optional<U> |
mapToObj(DoubleFunction<U> mapper)
Invokes the given mapping function on inner value if present.
|
static OptionalDouble |
of(double value)
Returns an
OptionalDouble with the specified value present. |
OptionalDouble |
or(Supplier<OptionalDouble> supplier)
Returns current
OptionalDouble if value is present, otherwise
returns an OptionalDouble produced by supplier function. |
double |
orElse(double other)
Returns inner value if present, otherwise returns
other. |
double |
orElseGet(DoubleSupplier other)
Returns the value if present, otherwise returns value produced by supplier function.
|
<X extends Throwable> |
orElseThrow(Supplier<X> exceptionSupplier)
Returns the value if present, otherwise throws an exception provided by supplier function.
|
DoubleStream |
stream()
Wraps a value into
DoubleStream if present,
otherwise returns an empty DoubleStream. |
String |
toString() |
public static OptionalDouble empty()
OptionalDouble instance.OptionalDoublepublic static OptionalDouble of(double value)
OptionalDouble with the specified value present.value - the value to be presentOptionalDouble with the value presentpublic double getAsDouble()
NoSuchElementException.OptionalDoubleNoSuchElementException - if there is no value presentisPresent()public boolean isPresent()
true if a value present, false otherwisepublic void ifPresent(DoubleConsumer consumer)
consumer - the consumer function to be executed if a value is presentNullPointerException - if value is present and consumer is nullpublic void ifPresentOrElse(DoubleConsumer consumer, Runnable emptyAction)
consumer - the consumer function to be executed, if a value is presentemptyAction - the empty-based action to be performed, if no value is presentNullPointerException - if a value is present and the given consumer function is null,
or no value is present and the given empty-based action is null.public OptionalDouble executeIfPresent(DoubleConsumer consumer)
ifPresent, but does not breaks chainingconsumer - consumer functionOptionalDoubleifPresent(com.annimon.stream.function.DoubleConsumer)public OptionalDouble executeIfAbsent(Runnable action)
action - action that invokes if value absentOptionalDoublepublic <R> R custom(Function<OptionalDouble,R> function)
OptionalDouble.R - the type of the resultfunction - a transforming functionNullPointerException - if function is nullpublic OptionalDouble filter(DoublePredicate predicate)
predicate - a predicate functionOptionalDouble if the value is present and matches predicate,
otherwise an empty OptionalDoublepublic OptionalDouble filterNot(DoublePredicate predicate)
predicate - a predicate functionOptionalDouble if the value is present and doesn't matches predicate,
otherwise an empty OptionalDoublepublic OptionalDouble map(DoubleUnaryOperator mapper)
mapper - mapping functionOptionalDouble with transformed value if present,
otherwise an empty OptionalDoubleNullPointerException - if value is present and
mapper is nullpublic <U> Optional<U> mapToObj(DoubleFunction<U> mapper)
U - the type of result valuemapper - mapping functionOptional with transformed value if present,
otherwise an empty OptionalNullPointerException - if value is present and
mapper is nullpublic OptionalInt mapToInt(DoubleToIntFunction mapper)
mapper - mapping functionOptionalInt with transformed value if present,
otherwise an empty OptionalIntNullPointerException - if value is present and
mapper is nullpublic OptionalLong mapToLong(DoubleToLongFunction mapper)
mapper - mapping functionOptionalLong with transformed value if present,
otherwise an empty OptionalLongNullPointerException - if value is present and
mapper is nullpublic DoubleStream stream()
DoubleStream if present,
otherwise returns an empty DoubleStream.DoubleStreampublic OptionalDouble or(Supplier<OptionalDouble> supplier)
OptionalDouble if value is present, otherwise
returns an OptionalDouble produced by supplier function.supplier - supplier function that produces an OptionalDouble to be returnedOptionalDouble if value is present, otherwise
an OptionalDouble produced by supplier functionNullPointerException - if value is not present and
supplier or value produced by it is nullpublic double orElse(double other)
other.other - the value to be returned if there is no value presentotherpublic double orElseGet(DoubleSupplier other)
other - supplier function that produces value if inner value is not presentother.getAsDouble()NullPointerException - if value is not present and other is nullpublic <X extends Throwable> double orElseThrow(Supplier<X> exceptionSupplier) throws X extends Throwable
X - the type of exception to be thrownexceptionSupplier - supplier function that produces an exception to be thrownX - if inner value is not presentX extends ThrowableCopyright © 2017. All rights reserved.