commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvz <...@git.apache.org>
Subject [GitHub] commons-text pull request #50: TEXT-90: Add CharacterPredicates for ASCII le...
Date Thu, 15 Jun 2017 01:45:59 GMT
Github user jvz commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/50#discussion_r122104071
  
    --- Diff: src/main/java/org/apache/commons/text/CharacterPredicates.java ---
    @@ -48,5 +48,73 @@ public boolean test(int codePoint) {
             public boolean test(int codePoint) {
                 return Character.isDigit(codePoint);
             }
    -    }
    +    },
    +
    +    /**
    +     * Tests if the code points represents a number between 0 and 9.
    +     *
    +     * @since 1.2
    +     */
    +    ARABIC_NUMERALS {
    +        @Override
    +        public boolean test(int codePoint) {
    +            return codePoint >= ZERO_CODEPOINT && codePoint <= NINE_CODEPOINT;
    +        }
    +    },
    +
    +    /**
    +     * Tests if the code points represents a letter between a and z.
    +     *
    +     * @since 1.2
    +     */
    +    ASCII_LOWERCASE_LETTERS {
    +        @Override
    +        public boolean test(int codePoint) {
    +            return codePoint >= LOWERCASE_A_CODEPOINT && codePoint <= LOWERCASE_Z_CODEPOINT;
    +        }
    +    },
    +
    +    /**
    +     * Tests if the code points represents a letter between A and Z.
    +     *
    +     * @since 1.2
    +     */
    +    ASCII_UPPERCASE_LETTERS {
    +        @Override
    +        public boolean test(int codePoint) {
    +            return codePoint >= UPPERCASE_A_CODEPOINT && codePoint <= UPPERCASE_Z_CODEPOINT;
    +        }
    +    },
    +
    +    /**
    +     * Tests if the code points represents a letter between a and Z.
    +     *
    +     * @since 1.2
    +     */
    +    ASCII_LETTERS {
    +        @Override
    +        public boolean test(int codePoint) {
    +            return ASCII_LOWERCASE_LETTERS.test(codePoint) || ASCII_UPPERCASE_LETTERS.test(codePoint);
    +        }
    +    },
    +
    +    /**
    +     * Tests if the code points represents a letter between a and Z or a number between
0 and 9.
    +     *
    +     * @since 1.2
    +     */
    +    ASCII_ALPHA_NUMERALS {
    +        @Override
    +        public boolean test(int codePoint) {
    +            return ASCII_LOWERCASE_LETTERS.test(codePoint) || ASCII_UPPERCASE_LETTERS.test(codePoint)
    +                    || ARABIC_NUMERALS.test(codePoint);
    +        }
    +    };
    +
    +    private static final int NINE_CODEPOINT = 57;
    --- End diff --
    
    Wouldn't it make more sense to use an implicit widening on `'9'` to `int` rather than
hardcoded constants?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message