Class CharMatcher.Is

All Implemented Interfaces:
Predicate<Character>, Predicate<Character>
Enclosing class:
CharMatcher

private static final class CharMatcher.Is extends CharMatcher.FastMatcher
Implementation of CharMatcher.is(char).
  • Field Details

    • match

      private final char match
  • Constructor Details

    • Is

      Is(char match)
  • Method Details

    • matches

      public boolean matches(char c)
      Description copied from class: CharMatcher
      Determines a true or false value for the given character.
      Specified by:
      matches in class CharMatcher
    • replaceFrom

      public String replaceFrom(CharSequence sequence, char replacement)
      Description copied from class: CharMatcher
      Returns a string copy of the input character sequence, with each matching BMP character replaced by a given replacement character. For example:
      
       CharMatcher.is('a').replaceFrom("radar", 'o')
       
      ... returns "rodor".

      The default implementation uses CharMatcher.indexIn(CharSequence) to find the first matching character, then iterates the remainder of the sequence calling CharMatcher.matches(char) for each character.

      Overrides:
      replaceFrom in class CharMatcher
      Parameters:
      sequence - the character sequence to replace matching characters in
      replacement - the character to append to the result string in place of each matching character in sequence
      Returns:
      the new string
    • and

      public CharMatcher and(CharMatcher other)
      Description copied from class: CharMatcher
      Returns a matcher that matches any character matched by both this matcher and other.
      Overrides:
      and in class CharMatcher
    • or

      public CharMatcher or(CharMatcher other)
      Description copied from class: CharMatcher
      Returns a matcher that matches any character matched by either this matcher or other.
      Overrides:
      or in class CharMatcher
    • negate

      public CharMatcher negate()
      Description copied from class: CharMatcher
      Returns a matcher that matches any character not matched by this matcher.
      Specified by:
      negate in interface Predicate<Character>
      Overrides:
      negate in class CharMatcher.FastMatcher
    • setBits

      void setBits(BitSet table)
      Description copied from class: CharMatcher
      Sets bits in table matched by this matcher.
      Overrides:
      setBits in class CharMatcher
    • toString

      public String toString()
      Description copied from class: CharMatcher
      Returns a string representation of this CharMatcher, such as CharMatcher.or(WHITESPACE, JAVA_DIGIT).
      Overrides:
      toString in class CharMatcher