prathambhalla12dev opened a new pull request, #1805: URL: https://github.com/apache/commons-lang/pull/1805
## Summary Implements the feature requested in [LANG-1412](https://issues.apache.org/jira/browse/LANG-1412). Users can now build a character array from human-readable range specifications without manually expanding each range: ```java private static final char[] LEGAL_CHARACTERS = CharSet.getInstance("A-Z", "a-z", "0-9", "-", "_@()&#*[]").toArray(); ``` ### Design - Uses `java.util.BitSet` internally — overlapping ranges are deduplicated in O(n) without any boxing or sorting pass; the bit-scan naturally produces an ascending result. - Throws `IllegalStateException` if the set contains a negated range (e.g. `^a-z`), whose expansion can reach ~65 k characters and is almost certainly unintentional in this context. - Thread-safe: protected by the same `lock` object used by `contains()`. ### Changes | File | Change | |------|--------| | `CharSet.java` | Add `toArray()` method + `BitSet` import | | `CharSetTest.java` | 8 new test methods covering empty set, single char, range, multiple ranges, overlapping ranges, static instances, the JIRA use-case, and negated-range guard | | `changes.xml` | Add LANG-1412 release note | ## Test plan - [x] `mvn test -Dtest=CharSetTest` — 23 tests, 0 failures -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
