Java 8 Streams API - Stream-Level Predicates

From NovaOrdis Knowledge Base
Revision as of 20:09, 28 March 2018 by Ovidiu (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

These "match" operations apply a predicate to all elements of the stream, subject to short-circuiting, and return a boolean result. Any of these operations are terminal, in that they return a boolean (non-stream) result.

Methods

anyMatch

https://docs.oracle.com/javase/10/docs/api/java/util/stream/Stream.html#anyMatch(java.util.function.Predicate)

Returns whether any elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then false is returned and the predicate is not evaluated.

public interface Stream<T> ... {

   boolean anyMatch(Predicate<? super T> predicate);

}

allMatch

https://docs.oracle.com/javase/10/docs/api/java/util/stream/Stream.html#allMatch(java.util.function.Predicate)

Returns whether all elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated.

public interface Stream<T> ... {

   boolean allMatch(Predicate<? super T> predicate);

}

noneMatch

https://docs.oracle.com/javase/10/docs/api/java/util/stream/Stream.html#noneMatch(java.util.function.Predicate)

Returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated.

public interface Stream<T> ... {

   boolean noneMatch(Predicate<? super T> predicate);

}