Java 8 Streams API - Stream-Level Predicates: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
Line 42: Line 42:


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.
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.
<syntaxhighlight lang='java'>
public interface Stream<T> ... {
  boolean noneMatch​(Predicate<? super T> predicate);
}
</syntaxhighlight>

Latest revision as of 20:09, 28 March 2018

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);

}