Interface CharPredicate

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CharPredicate
A predicate of character. More efficient than Predicate<Character>.
Since:
6.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CharPredicate
    Equivalent to the [a-zA-Z] character class.
    static final CharPredicate
    Corresponds to all characters.
    static final CharPredicate
    Corresponds to the ASCII characters.
    static final CharPredicate
    Corresponds to no characters.
    static final CharPredicate
    Equivalent to the [a-zA-Z0-9_] character class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a CharPredicate that evaluates true if both this and that predicate evaluate to true.
    anyOf(String chars)
    Returns a CharPredicate that matches any of chars.
    is(char ch)
    Returns a CharPredicate for the range of characters: [from, to].
    default boolean
    Returns true if a character sequence contains only matching BMP characters.
    default boolean
    Returns true if a character sequence contains at least one matching BMP character.
    default boolean
    Returns true if a character sequence contains no matching BMP characters.
    noneOf(String chars)
    Returns a CharPredicate that matches any of chars.
    not()
    Returns the negation of this CharPredicate.
    or(char ch)
    Returns a CharPredicate that evaluates true if either this predicate evaluates to true, or the character is ch.
    Returns a CharPredicate that evaluates true if either this or that predicate evaluate to true.
    orRange(char from, char to)
    Returns a CharPredicate that evaluates true if either this predicate evaluates to true, or the character is in the range of [from, to].
    range(char from, char to)
    Returns a CharPredicate for the range of characters: [from, to].
    boolean
    test(char ch)
    Returns true if ch satisfies this predicate.
  • Field Details

    • ALPHA

      static final CharPredicate ALPHA
      Equivalent to the [a-zA-Z] character class.
    • WORD

      static final CharPredicate WORD
      Equivalent to the [a-zA-Z0-9_] character class.
    • ASCII

      static final CharPredicate ASCII
      Corresponds to the ASCII characters.
    • ANY

      static final CharPredicate ANY
      Corresponds to all characters.
    • NONE

      static final CharPredicate NONE
      Corresponds to no characters.
  • Method Details

    • is

      static CharPredicate is(char ch)
      Returns a CharPredicate for the range of characters: [from, to].
    • range

      static CharPredicate range(char from, char to)
      Returns a CharPredicate for the range of characters: [from, to].
    • anyOf

      static CharPredicate anyOf(String chars)
      Returns a CharPredicate that matches any of chars.
    • noneOf

      static CharPredicate noneOf(String chars)
      Returns a CharPredicate that matches any of chars.
    • test

      boolean test(char ch)
      Returns true if ch satisfies this predicate.
    • or

      default CharPredicate or(CharPredicate that)
      Returns a CharPredicate that evaluates true if either this or that predicate evaluate to true.
    • and

      default CharPredicate and(CharPredicate that)
      Returns a CharPredicate that evaluates true if both this and that predicate evaluate to true.
    • or

      default CharPredicate or(char ch)
      Returns a CharPredicate that evaluates true if either this predicate evaluates to true, or the character is ch.
    • orRange

      default CharPredicate orRange(char from, char to)
      Returns a CharPredicate that evaluates true if either this predicate evaluates to true, or the character is in the range of [from, to].
    • not

      default CharPredicate not()
      Returns the negation of this CharPredicate.
    • matchesAnyOf

      default boolean matchesAnyOf(CharSequence sequence)
      Returns true if a character sequence contains at least one matching BMP character. Equivalent to !matchesNoneOf(sequence).
      Since:
      7.0
    • matchesAllOf

      default boolean matchesAllOf(CharSequence sequence)
      Returns true if a character sequence contains only matching BMP characters.
      Since:
      7.0
    • matchesNoneOf

      default boolean matchesNoneOf(CharSequence sequence)
      Returns true if a character sequence contains no matching BMP characters. Equivalent to !matchesAnyOf(sequence).
      Since:
      7.0