Package | Description |
---|---|
java8.util |
Provides some of the new
java.util classes and implementations of
static and default interface methods added in Java 8 and, in addition, the
JEP 269: Convenience Factory
Methods for Collections that were introduced in Java 9. |
java8.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<T> |
Optional.empty()
Returns an empty
Optional instance. |
Optional<T> |
Optional.filter(Predicate<? super T> predicate)
If a value is present, and the value matches the given predicate,
returns an
Optional describing the value, otherwise returns an
empty Optional . |
<U> Optional<U> |
Optional.flatMap(Function<? super T,? extends Optional<? extends U>> mapper)
If a value is present, returns the result of applying the given
Optional -bearing mapping function to the value, otherwise returns
an empty Optional . |
<U> Optional<U> |
Optional.map(Function<? super T,? extends U> mapper)
If a value is present, returns an
Optional describing (as if by
ofNullable(T) ) the result of applying the given mapping function to
the value, otherwise returns an empty Optional . |
static <T> Optional<T> |
Optional.of(T value)
Returns an
Optional describing the given non-null value. |
static <T> Optional<T> |
Optional.ofNullable(T value)
Returns an
Optional describing the given value, if
non-null , otherwise returns an empty Optional . |
Optional<T> |
Optional.or(Supplier<? extends Optional<? extends T>> supplier)
If a value is present, returns an
Optional describing the value,
otherwise returns an Optional produced by the supplying function. |
Modifier and Type | Method and Description |
---|---|
<U> Optional<U> |
Optional.flatMap(Function<? super T,? extends Optional<? extends U>> mapper)
If a value is present, returns the result of applying the given
Optional -bearing mapping function to the value, otherwise returns
an empty Optional . |
Optional<T> |
Optional.or(Supplier<? extends Optional<? extends T>> supplier)
If a value is present, returns an
Optional describing the value,
otherwise returns an Optional produced by the supplying function. |
Modifier and Type | Method and Description |
---|---|
Optional<T> |
Stream.findAny()
Returns an
Optional describing some element of the stream, or an
empty Optional if the stream is empty. |
Optional<T> |
Stream.findFirst()
Returns an
Optional describing the first element of this stream,
or an empty Optional if the stream is empty. |
Optional<T> |
Stream.max(Comparator<? super T> comparator)
Returns the maximum element of this stream according to the provided
Comparator . |
Optional<T> |
Stream.min(Comparator<? super T> comparator)
Returns the minimum element of this stream according to the provided
Comparator . |
Optional<T> |
Stream.reduce(BinaryOperator<T> accumulator)
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<T,?,Optional<T>> |
Collectors.maxBy(Comparator<? super T> comparator)
Returns a
Collector that produces the maximal element according
to a given Comparator , described as an Optional<T> . |
static <T> Collector<T,?,Optional<T>> |
Collectors.minBy(Comparator<? super T> comparator)
Returns a
Collector that produces the minimal element according
to a given Comparator , described as an Optional<T> . |
static <T> Collector<T,?,Optional<T>> |
Collectors.reducing(BinaryOperator<T> op)
Returns a
Collector which performs a reduction of its
input elements under a specified BinaryOperator . |
Copyright © 2020. All rights reserved.