T
- The type of the elements that the stream emits.public interface FilteringOperators<T>
The documentation for each operator uses marble diagrams to visualize how the operator functions. Each element flowing in and out of the stream is represented as a coloured marble that has a value, with the operator applying some transformation or some side effect, termination and error signals potentially being passed, and for operators that subscribe to the stream, an output value being redeemed at the end.
Below is an example diagram labelling all the parts of the stream.
Modifier and Type | Method and Description |
---|---|
FilteringOperators<T> |
distinct()
Creates a stream consisting of the distinct elements (according to
Object.equals(Object) ) of this stream. |
FilteringOperators<T> |
dropWhile(Predicate<? super T> predicate)
Drop the longest prefix of elements from this stream that satisfy the given
predicate . |
FilteringOperators<T> |
filter(Predicate<? super T> predicate)
Filter elements emitted by this publisher using the given
Predicate . |
FilteringOperators<T> |
limit(long maxSize)
Truncate this stream, ensuring the stream is no longer than
maxSize elements in length. |
FilteringOperators<T> |
skip(long n)
Discard the first
n of this stream. |
FilteringOperators<T> |
takeWhile(Predicate<? super T> predicate)
Take the longest prefix of elements from this stream that satisfy the given
predicate . |
FilteringOperators<T> filter(Predicate<? super T> predicate)
Predicate
.
Any elements that return true
when passed to the Predicate
will be emitted, all other
elements will be dropped.
predicate
- The predicate to apply to each element.FilteringOperators<T> distinct()
Object.equals(Object)
) of this stream.
FilteringOperators<T> limit(long maxSize)
maxSize
elements in length.
If maxSize
is reached, the stream will be completed, and upstream will be cancelled. Completion of the
stream will occur immediately when the element that satisfies the maxSize
is received.
maxSize
- The maximum size of the returned stream.IllegalArgumentException
- If maxSize
is less than zero.FilteringOperators<T> skip(long n)
n
of this stream. If this stream contains fewer than n
elements, this stream will
effectively be an empty stream.
n
- The number of elements to discard.IllegalArgumentException
- If n
is less than zero.FilteringOperators<T> takeWhile(Predicate<? super T> predicate)
predicate
.
When the predicate
returns false, the stream will be completed, and upstream will be cancelled.
predicate
- The predicate.FilteringOperators<T> dropWhile(Predicate<? super T> predicate)
predicate
.
As long as the predicate
returns true, no elements will be emitted from this stream. Once the first element
is encountered for which the predicate
returns false, all subsequent elements will be emitted, and the
predicate
will no longer be invoked.
predicate
- The predicate.Copyright © 2019 Eclipse Foundation. All rights reserved.