/** * Returns a predicate that represents the logical negation of this * predicate. * * @return a predicate that represents the logical negation of this * predicate */ default CharPredicate negate() { return (value) -> !test(value); }
/** * Returns a predicate that represents the logical negation of this * predicate. * * @return a predicate that represents the logical negation of this * predicate */ default CharPredicate negate() { return (value) -> !test(value); }
/** * Returns a composed predicate that represents a short-circuiting logical * AND of this predicate and another. When evaluating the composed * predicate, if this predicate is {@code false}, then the {@code other} * predicate is not evaluated. * * <p>Any exceptions thrown during evaluation of either predicate are relayed * to the caller; if evaluation of this predicate throws an exception, the * {@code other} predicate will not be evaluated. * * @param other a predicate that will be logically-ANDed with this * predicate * @return a composed predicate that represents the short-circuiting logical * AND of this predicate and the {@code other} predicate * @throws NullPointerException if other is null */ default CharPredicate and(CharPredicate other) { Objects.requireNonNull( other); return (value) -> test(value) && other.test(value); }
/** * Returns a composed predicate that represents a short-circuiting logical * AND of this predicate and another. When evaluating the composed * predicate, if this predicate is {@code false}, then the {@code other} * predicate is not evaluated. * * <p>Any exceptions thrown during evaluation of either predicate are relayed * to the caller; if evaluation of this predicate throws an exception, the * {@code other} predicate will not be evaluated. * * @param other a predicate that will be logically-ANDed with this * predicate * @return a composed predicate that represents the short-circuiting logical * AND of this predicate and the {@code other} predicate * @throws NullPointerException if other is null */ default CharPredicate and(CharPredicate other) { Objects.requireNonNull( other); return (value) -> test(value) && other.test(value); }
/** * Returns a composed predicate that represents a short-circuiting logical * OR of this predicate and another. When evaluating the composed * predicate, if this predicate is {@code true}, then the {@code other} * predicate is not evaluated. * * <p>Any exceptions thrown during evaluation of either predicate are relayed * to the caller; if evaluation of this predicate throws an exception, the * {@code other} predicate will not be evaluated. * * @param other a predicate that will be logically-ORed with this * predicate * @return a composed predicate that represents the short-circuiting logical * OR of this predicate and the {@code other} predicate * @throws NullPointerException if other is null */ default CharPredicate or(CharPredicate other) { Objects.requireNonNull(other); return (value) -> test(value) || other.test(value); } }
/** * Returns a composed predicate that represents a short-circuiting logical * OR of this predicate and another. When evaluating the composed * predicate, if this predicate is {@code true}, then the {@code other} * predicate is not evaluated. * * <p>Any exceptions thrown during evaluation of either predicate are relayed * to the caller; if evaluation of this predicate throws an exception, the * {@code other} predicate will not be evaluated. * * @param other a predicate that will be logically-ORed with this * predicate * @return a composed predicate that represents the short-circuiting logical * OR of this predicate and the {@code other} predicate * @throws NullPointerException if other is null */ default CharPredicate or(CharPredicate other) { Objects.requireNonNull(other); return (value) -> test(value) || other.test(value); } }
public static boolean all( @This CharSequence thiz, CharPredicate predicate ) { for( int i = 0; i < thiz.length(); i++ ) { if( !predicate.test( thiz.charAt( i ) ) ) { return false; } } return true; }
public static boolean all( @This CharSequence thiz, CharPredicate predicate ) { for( int i = 0; i < thiz.length(); i++ ) { if( !predicate.test( thiz.charAt( i ) ) ) { return false; } } return true; }
/** * Returns a sub sequence of this char sequence having trailing characters matching the {@code predicate} trimmed. */ public static CharSequence trimEnd( @This CharSequence thiz, CharPredicate predicate ) { for( int index = thiz.length() - 1; index >= 0; index-- ) { if( !predicate.test( thiz.charAt( index ) ) ) { return thiz.subSequence( 0, index + 1 ); } } return ""; }
/** * Returns a sub sequence of this char sequence having leading characters matching the {@code predicate} trimmed. */ public static CharSequence trimStart( @This CharSequence thiz, CharPredicate predicate ) { for( int index = 0; index < thiz.length(); index++ ) { if( !predicate.test( thiz.charAt( index ) ) ) { return thiz.subSequence( index, thiz.length() ); } } return ""; }
/** * Returns a sub sequence of this char sequence having trailing characters matching the {@code predicate} trimmed. */ public static CharSequence trimEnd( @This CharSequence thiz, CharPredicate predicate ) { for( int index = thiz.length() - 1; index >= 0; index-- ) { if( !predicate.test( thiz.charAt( index ) ) ) { return thiz.subSequence( 0, index + 1 ); } } return ""; }
/** * Returns a sub sequence of this char sequence having leading characters matching the {@code predicate} trimmed. */ public static CharSequence trimStart( @This CharSequence thiz, CharPredicate predicate ) { for( int index = 0; index < thiz.length(); index++ ) { if( !predicate.test( thiz.charAt( index ) ) ) { return thiz.subSequence( index, thiz.length() ); } } return ""; }
boolean match = predicate.test( thiz.charAt( index ) );
boolean match = predicate.test( thiz.charAt( index ) );