Determines a true or false value for any Java char value, just as Predicate does for any Object. Also offers basic text processing methods based on this function. Implementations are strongly encouraged to be side-effect-free and immutable. Throughout the documentation of
| 51 | |
| 52 | |
| 53 | @Beta // Possibly change from chars to code points; decide constants vs. methods |
| 54 | @GwtCompatible(emulated = true) |
| 55 | public abstract class CharMatcher implements Predicate<Character> { |
| 56 | |
| 57 | // Constant matcher factory methods |
| 58 | |
| 59 | /** |
| 60 | * Matches any character. |
| 61 | * |
| 62 | * @since 19.0 (since 1.0 as constant {@code ANY}) |
| 63 | */ |
| 64 | |
| 65 | public static CharMatcher any() { |
| 66 | return Any.INSTANCE; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Matches no characters. |
| 71 | * |
| 72 | * @since 19.0 (since 1.0 as constant {@code NONE}) |
| 73 | */ |
| 74 | |
| 75 | |
| 76 | public static CharMatcher none() { |
| 77 | return None.INSTANCE; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Determines whether a character is whitespace according to the latest Unicode standard, as |
| 82 | * illustrated |
| 83 | * <a href="http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5Cp%7Bwhitespace%7D">here</a>. |
| 84 | * This is not the same definition used by other Java APIs. (See a |
| 85 | * <a href="http://spreadsheets.google.com/pub?key=pd8dAQyHbdewRsnE5x5GzKQ">comparison of several |
| 86 | * definitions of "whitespace"</a>.) |
| 87 | * |
| 88 | * <p><b>Note:</b> as the Unicode definition evolves, we will modify this matcher to keep it up to |
| 89 | * date. |
| 90 | * |
| 91 | * @since 19.0 (since 1.0 as constant {@code WHITESPACE}) |
| 92 | */ |
| 93 | |
| 94 | |
| 95 | public static CharMatcher whitespace() { |
| 96 | return Whitespace.INSTANCE; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Determines whether a character is a breaking whitespace (that is, a whitespace which can be |
| 101 | * interpreted as a break between words for formatting purposes). See {@link #whitespace()} for a |
| 102 | * discussion of that term. |
| 103 | * |
| 104 | * @since 19.0 (since 2.0 as constant {@code BREAKING_WHITESPACE}) |
| 105 | */ |
| 106 | |
| 107 | |
| 108 | public static CharMatcher breakingWhitespace() { |
| 109 | return BreakingWhitespace.INSTANCE; |
| 110 | } |
nothing calls this directly
no test coverage detected