[
https://issues.apache.org/jira/browse/TEXT-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16050984#comment-16050984
]
ASF GitHub Bot commented on TEXT-90:
------------------------------------
Github user PascalSchumacher commented on a diff in the pull request:
https://github.com/apache/commons-text/pull/50#discussion_r122294037
--- 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 --
Sure. I have updated the pull request. Thanks for the suggestion!
> Add CharacterPredicates for ASCII letters (uppercase/lowercase) and arabic
> numerals
> -----------------------------------------------------------------------------------
>
> Key: TEXT-90
> URL: https://issues.apache.org/jira/browse/TEXT-90
> Project: Commons Text
> Issue Type: New Feature
> Reporter: Pascal Schumacher
> Assignee: Pascal Schumacher
> Fix For: 1.2
>
>
> I tried to migrate a project from RandomStringUtils to RandomStringGenerator
> today, but I found it hard to replace methods like
> RandomStringUtils#randomAlphanumeric and RandomStringUtils#randomAlphabetic.
> I believe it would ease migration from RandomStringUtils to
> RandomStringGenerator if CharacterPrecidates would offer more predicates.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)