public final class OptionalDoubles extends Object
OptionalDouble
.Modifier and Type | Field and Description |
---|---|
static DoublePredicate |
IS_NEGATIVE
Predicate returning
true for all values less than zero. |
static DoublePredicate |
IS_NEGATIVE_OR_ZERO
Predicate returning
true for all values less than or equal to zero. |
static DoublePredicate |
IS_POSITIVE
Predicate returning
true for all values greater than zero. |
static DoublePredicate |
IS_POSITIVE_OR_ZERO
Predicate returning
true for all values greater than or equal to
zero. |
Modifier and Type | Method and Description |
---|---|
static Optional<Double> |
boxed(OptionalDouble optional)
|
static OptionalDouble |
filter(OptionalDouble optional,
DoublePredicate predicate)
If a value is present, and the value matches the given predicate, return an
OptionalDouble describing the value, otherwise return an empty
OptionalDouble . |
static OptionalDouble |
flatMap(OptionalDouble optional,
DoubleFunction<OptionalDouble> mapper)
If a value is present, apply the provided
OptionalDouble -bearing
mapping function to it, return that result, otherwise return an empty
OptionalDouble . |
static OptionalInt |
flatMapToInt(OptionalDouble optional,
DoubleFunction<OptionalInt> mapper)
If a value is present, apply the provided
OptionalInt -bearing mapping
function to it, return that result, otherwise return an empty
OptionalInt . |
static OptionalLong |
flatMapToLong(OptionalDouble optional,
DoubleFunction<OptionalLong> mapper)
If a value is present, apply the provided
OptionalLong -bearing
mapping function to it, return that result, otherwise return an empty
OptionalLong . |
static <T> Optional<T> |
flatMapToObj(OptionalDouble optional,
DoubleFunction<Optional<T>> mapper)
|
static OptionalDouble |
map(OptionalDouble optional,
DoubleToDoubleFunction mapper)
If a value is present, applies
mapper to optional and returns
an OptionalDouble describing the result. |
static OptionalInt |
mapToInt(OptionalDouble optional,
DoubleToIntFunction mapper)
|
static OptionalLong |
mapToLong(OptionalDouble optional,
DoubleToLongFunction mapper)
If a value is present, applies
mapper to optional and returns
an OptionalLong describing the result. |
static <T> Optional<T> |
mapToObj(OptionalDouble optional,
DoubleFunction<T> mapper)
|
static OptionalDouble |
ofNon(DoublePredicate isEmpty,
double value)
Returns an
OptionalDouble describing the specified value, if
non-empty, otherwise returns an empty OptionalDouble . |
static OptionalDouble |
ofNullable(Double value)
Returns an
OptionalDouble describing the specified value, if
non-null, otherwise returns an empty OptionalDouble . |
static DoubleStream |
stream(OptionalDouble... optionals)
Returns a stream consisting of present elements.
|
public static final DoublePredicate IS_NEGATIVE
true
for all values less than zero.public static final DoublePredicate IS_NEGATIVE_OR_ZERO
true
for all values less than or equal to zero.public static final DoublePredicate IS_POSITIVE
true
for all values greater than zero.public static final DoublePredicate IS_POSITIVE_OR_ZERO
true
for all values greater than or equal to
zero.public static Optional<Double> boxed(OptionalDouble optional)
public static OptionalDouble filter(OptionalDouble optional, DoublePredicate predicate)
OptionalDouble
describing the value, otherwise return an empty
OptionalDouble
.optional
- optional valuepredicate
- a predicate to apply to the value, if presentOptionalDouble
describing the value of optional
if
a value is present and the value matches the given predicate,
otherwise an empty OptionalDouble
public static OptionalDouble flatMap(OptionalDouble optional, DoubleFunction<OptionalDouble> mapper)
OptionalDouble
-bearing
mapping function to it, return that result, otherwise return an empty
OptionalDouble
. This method is similar to
map(OptionalDouble, DoubleToDoubleFunction)
, but the provided mapper
is one whose result is already an OptionalDouble
, and if invoked,
flatMapToDouble
does not wrap it with an additional
OptionalDouble
.optional
- optional valuemapper
- a mapping function to apply to the value, if present the
mapping functionOptionalDouble
-bearing mapping
function to the value of this OptionalDouble
, if a value is
present, otherwise an empty OptionalDouble
public static OptionalInt flatMapToInt(OptionalDouble optional, DoubleFunction<OptionalInt> mapper)
OptionalInt
-bearing mapping
function to it, return that result, otherwise return an empty
OptionalInt
. This method is similar to
mapToInt(OptionalDouble, DoubleToIntFunction)
, but the provided
mapper is one whose result is already an OptionalInt
, and if invoked,
flatMap
does not wrap it with an additional OptionalInt
.optional
- optional valuemapper
- a mapping function to apply to the value, if present the
mapping functionOptionalInt
-bearing mapping
function to the value of this OptionalInt
, if a value is
present, otherwise an empty OptionalInt
public static OptionalLong flatMapToLong(OptionalDouble optional, DoubleFunction<OptionalLong> mapper)
OptionalLong
-bearing
mapping function to it, return that result, otherwise return an empty
OptionalLong
. This method is similar to
mapToLong(OptionalDouble, DoubleToLongFunction)
, but the provided
mapper is one whose result is already an OptionalLong
, and if
invoked, flatMapToDouble
does not wrap it with an additional
OptionalLong
.optional
- optional valuemapper
- a mapping function to apply to the value, if present the
mapping functionOptionalLong
-bearing mapping
function to the value of this OptionalLong
, if a value is
present, otherwise an empty OptionalLong
public static <T> Optional<T> flatMapToObj(OptionalDouble optional, DoubleFunction<Optional<T>> mapper)
Optional
-bearing mapping
function to it, return that result, otherwise return an empty
Optional
. This method is similar to
mapToObj(OptionalDouble, DoubleFunction)
, but the provided mapper is
one whose result is already an Optional
, and if invoked,
flatMapToDouble
does not wrap it with an additional Optional
.T
- the type parameter to the Optional
returnedoptional
- optional valuemapper
- a mapping function to apply to the value, if present the
mapping functionOptional
-bearing mapping function
to the value of this Optional
, if a value is present,
otherwise an empty Optional
public static OptionalDouble map(OptionalDouble optional, DoubleToDoubleFunction mapper)
mapper
to optional
and returns
an OptionalDouble
describing the result. Otherwise returns an empty
OptionalDouble
.optional
- optional valuemapper
- a mapping function to apply to the value, if presentOptionalDouble
describing the result of applying
mapper
function to the value of optional
, if a value
is present, otherwise an empty OptionalDouble
public static OptionalInt mapToInt(OptionalDouble optional, DoubleToIntFunction mapper)
mapper
to optional
and returns
an OptionalInt
describing the result. Otherwise returns an empty
OptionalInt
.optional
- optional valuemapper
- a mapping function to apply to the value, if presentOptionalInt
describing the result of applying
mapper
function to the value of optional
, if a value
is present, otherwise an empty OptionalInt
public static OptionalLong mapToLong(OptionalDouble optional, DoubleToLongFunction mapper)
mapper
to optional
and returns
an OptionalLong
describing the result. Otherwise returns an empty
OptionalLong
.optional
- optional valuemapper
- a mapping function to apply to the value, if presentOptionalLong
describing the result of applying
mapper
function to the value of optional
, if a value
is present, otherwise an empty OptionalLong
public static <T> Optional<T> mapToObj(OptionalDouble optional, DoubleFunction<T> mapper)
mapper
to optional
and returns
an Optional
describing the result. Otherwise returns an empty
Optional
.T
- the type of the result of mapper
optional
- optional valuemapper
- a mapping function to apply to the value, if presentOptional
describing the result of applying mapper
function to the value of optional
, if a value is present,
otherwise an empty Optional
public static OptionalDouble ofNon(DoublePredicate isEmpty, double value)
OptionalDouble
describing the specified value, if
non-empty, otherwise returns an empty OptionalDouble
. The term
empty is described by isEmpty
.isEmpty
- predicate describing the term emptyvalue
- the possibly-empty value to describeOptionalDouble
with a present value if the specified value
is non-empty, otherwise an empty OptionalDouble
public static OptionalDouble ofNullable(@Nullable Double value)
OptionalDouble
describing the specified value, if
non-null, otherwise returns an empty OptionalDouble
.value
- the possibly-null value to describeOptionalDouble
with a present value if the specified value
is non-null, otherwise an empty OptionalDouble
@SafeVarargs public static DoubleStream stream(OptionalDouble... optionals)
optionals
- array of optional elementsCopyright © 2025. All rights reserved.