allMatch

abstract fun allMatch(predicate: Predicate<TextElement>): Boolean(source)

Tests whether all elements in this sequence match the given predicate.

This is a short-circuiting terminal operation: it stops as soon as a non-matching element is found and returns false immediately.

Returns true for empty sequences (vacuous truth).

Examples:


// Check if all elements are whitespace
boolean allWhitespace = list.allMatch(TextElement::isSpaceOrTab);

// Check if all elements are comments
boolean allComments = list.allMatch(TextElement::isComment);

Return

true if all elements match the predicate (or sequence is empty), false otherwise

Parameters

predicate

the predicate to test elements against

Throws

if predicate is null