Returns a char matcher that matches any character present in the given character sequence.
(final CharSequence sequence)
| 391 | * sequence. |
| 392 | */ |
| 393 | public static CharMatcher anyOf(final CharSequence sequence) { |
| 394 | switch (sequence.length()) { |
| 395 | case 0: |
| 396 | return none(); |
| 397 | case 1: |
| 398 | return is(sequence.charAt(0)); |
| 399 | case 2: |
| 400 | return isEither(sequence.charAt(0), sequence.charAt(1)); |
| 401 | default: |
| 402 | // TODO(lowasser): is it potentially worth just going ahead and building a precomputed |
| 403 | // matcher? |
| 404 | return new AnyOf(sequence); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | /** |
| 409 | * Returns a {@code char} matcher that matches any character not present in the given character |
no test coverage detected