public final class OptionalLongs extends Object
OptionalLong
.Modifier and Type | Field and Description |
---|---|
static LongPredicate |
IS_NEGATIVE
Predicate returning
true for all values less than zero. |
static LongPredicate |
IS_NEGATIVE_OR_ZERO
Predicate returning
true for all values less than or equal to zero. |
static LongPredicate |
IS_POSITIVE
Predicate returning
true for all values greater than zero. |
static LongPredicate |
IS_POSITIVE_OR_ZERO
Predicate returning
true for all values greater than or equal to
zero. |
Modifier and Type | Method and Description |
---|---|
static Optional<Long> |
boxed(OptionalLong optional)
|
static OptionalLong |
filter(OptionalLong optional,
LongPredicate predicate)
If a value is present, and the value matches the given predicate, return an
OptionalLong describing the value, otherwise return an empty
OptionalLong . |
static OptionalLong |
flatMap(OptionalLong optional,
LongFunction<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 OptionalDouble |
flatMapToDouble(OptionalLong optional,
LongFunction<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(OptionalLong optional,
LongFunction<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 <T> Optional<T> |
flatMapToObj(OptionalLong optional,
LongFunction<Optional<T>> mapper)
|
static OptionalLong |
map(OptionalLong optional,
LongToLongFunction mapper)
If a value is present, applies
mapper to optional and returns
an OptionalLong describing the result. |
static OptionalDouble |
mapToDouble(OptionalLong optional,
LongToDoubleFunction mapper)
If a value is present, applies
mapper to optional and returns
an OptionalDouble describing the result. |
static OptionalInt |
mapToInt(OptionalLong optional,
LongToIntFunction mapper)
|
static <T> Optional<T> |
mapToObj(OptionalLong optional,
LongFunction<T> mapper)
|
static OptionalLong |
ofNon(LongPredicate isEmpty,
long value)
Returns an
OptionalLong describing the specified value, if non-empty,
otherwise returns an empty OptionalLong . |
static OptionalLong |
ofNullable(Long value)
Returns an
OptionalLong describing the specified value, if non-null,
otherwise returns an empty OptionalLong . |
static LongStream |
stream(OptionalLong... optionals)
Returns a stream consisting of present elements.
|
public static final LongPredicate IS_NEGATIVE
true
for all values less than zero.public static final LongPredicate IS_NEGATIVE_OR_ZERO
true
for all values less than or equal to zero.public static final LongPredicate IS_POSITIVE
true
for all values greater than zero.public static final LongPredicate IS_POSITIVE_OR_ZERO
true
for all values greater than or equal to
zero.public static Optional<Long> boxed(OptionalLong optional)
public static OptionalLong filter(OptionalLong optional, LongPredicate predicate)
OptionalLong
describing the value, otherwise return an empty
OptionalLong
.optional
- optional valuepredicate
- a predicate to apply to the value, if presentOptionalLong
describing the value of optional
if a
value is present and the value matches the given predicate, otherwise
an empty OptionalLong
public static OptionalLong flatMap(OptionalLong optional, LongFunction<OptionalLong> mapper)
OptionalLong
-bearing
mapping function to it, return that result, otherwise return an empty
OptionalLong
. This method is similar to
map(OptionalLong, LongToLongFunction)
, 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 OptionalDouble flatMapToDouble(OptionalLong optional, LongFunction<OptionalDouble> mapper)
OptionalDouble
-bearing
mapping function to it, return that result, otherwise return an empty
OptionalDouble
. This method is similar to
mapToDouble(OptionalLong, LongToDoubleFunction)
, 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(OptionalLong optional, LongFunction<OptionalInt> mapper)
OptionalInt
-bearing mapping
function to it, return that result, otherwise return an empty
OptionalInt
. This method is similar to
mapToInt(OptionalLong, LongToIntFunction)
, 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 <T> Optional<T> flatMapToObj(OptionalLong optional, LongFunction<Optional<T>> mapper)
Optional
-bearing mapping
function to it, return that result, otherwise return an empty
Optional
. This method is similar to
mapToObj(OptionalLong, LongFunction)
, 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 OptionalLong map(OptionalLong optional, LongToLongFunction 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 OptionalDouble mapToDouble(OptionalLong optional, LongToDoubleFunction 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(OptionalLong optional, LongToIntFunction 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 <T> Optional<T> mapToObj(OptionalLong optional, LongFunction<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 OptionalLong ofNon(LongPredicate isEmpty, long value)
OptionalLong
describing the specified value, if non-empty,
otherwise returns an empty OptionalLong
. The term empty is
described by isEmpty
.isEmpty
- predicate describing the term emptyvalue
- the possibly-empty value to describeOptionalLong
with a present value if the specified value
is non-empty, otherwise an empty OptionalLong
public static OptionalLong ofNullable(@Nullable Long value)
OptionalLong
describing the specified value, if non-null,
otherwise returns an empty OptionalLong
.value
- the possibly-null value to describeOptionalLong
with a present value if the specified value
is non-null, otherwise an empty OptionalLong
@SafeVarargs public static LongStream stream(OptionalLong... optionals)
optionals
- array of optional elementsCopyright © 2025. All rights reserved.