| Package | Description |
|---|---|
| java.util |
Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).
|
| java.util.stream |
Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Optional |
Optional.empty()
Returns an empty
Optional instance.
|
Optional |
Optional.filter(Predicate
If a value is present, and the value matches the given predicate, return an
Optional describing the value, otherwise return an empty
Optional.
|
<U> Optional |
Optional.flatMap(Function
If a value is present, apply the provided
Optional-bearing mapping function to it, return that result, otherwise return an empty
Optional.
|
<U> Optional |
Optional.map(Function
If a value is present, apply the provided mapping function to it, and if the result is non-null, return an
Optional describing the result.
|
static <T> Optional |
Optional.of(T value)
Returns an
Optional with the specified present non-null value.
|
static <T> Optional |
Optional.ofNullable(T value)
Returns an
Optional describing the specified value, if non-null, otherwise returns an empty
Optional.
|
| Modifier and Type | Method and Description |
|---|---|
<U> Optional |
Optional.flatMap(Function
If a value is present, apply the provided
Optional-bearing mapping function to it, return that result, otherwise return an empty
Optional.
|
| Modifier and Type | Method and Description |
|---|---|
Optional |
Stream.findAny()
Returns an
Optional describing some element of the stream, or an empty
Optional if the stream is empty.
|
Optional |
Stream.findFirst()
Returns an
Optional describing the first element of this stream, or an empty
Optional if the stream is empty.
|
Optional |
Stream.max(Comparator
Returns the maximum element of this stream according to the provided
Comparator.
|
Optional |
Stream.min(Comparator
Returns the minimum element of this stream according to the provided
Comparator.
|
Optional |
Stream.reduce(BinaryOperator
Performs a
reduction on the elements of this stream, using an
associative accumulation function, and returns an
Optional describing the reduced value, if any.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Collector |
Collectors.maxBy(Comparator
Returns a
Collector that produces the maximal element according to a given
Comparator, described as an
Optional<T>.
|
static <T> Collector |
Collectors.minBy(Comparator
Returns a
Collector that produces the minimal element according to a given
Comparator, described as an
Optional<T>.
|
static <T> Collector |
Collectors.reducing(BinaryOperator
Returns a
Collector which performs a reduction of its input elements under a specified
BinaryOperator.
|