commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amey Jadiye (JIRA)" <>
Subject [jira] [Commented] (TEXT-96) Convenience methods needed for RandomStringGenerator
Date Fri, 30 Jun 2017 16:06:00 GMT


Amey Jadiye commented on TEXT-96:

{{RandomStringGenerator}} is certainly better and flexible in terms of your desired output
and I don't know what was motivation behind deprecating {{RandomStringUtils}} and giving away
simple API's. but at some point those simple things should be accommodated somewhere in {{RandomStringGenerator}}
*or* at least should provide more examples in Javadocs. *or* helper utilities should me present
somewhere which will bring back usefulness of {{RandomStringUtils}} to -> {{RandomStringGenerator}}

> Convenience methods needed for RandomStringGenerator
> ----------------------------------------------------
>                 Key: TEXT-96
>                 URL:
>             Project: Commons Text
>          Issue Type: Improvement
>    Affects Versions: 1.1
>            Reporter: Peter Phillips
>            Priority: Minor
> {{RandomStringGenerator}} is extremely verbose compared to the deprecated commons.lang3
> Previously we could write:
> {code:java}
> RandomStringUtils.randomNumeric(10)
> {code}
> to generate a numeric string whereas this now has become:
> {code:java}
> new RandomStringGenerator.Builder().withinRange('0', '9').build().generate(10)
> {code}
> although in practice we would then also use static imports too.
> The {{randomAlphabetic}} conversion is even more verbose:
> {code:java}
> new RandomStringGenerator.Builder().withinRange('A', 'z').filteredBy(new CharacterPredicate()
>                     @Override
>                     public boolean test(int codePoint) {
>                         return codePoint >= 'a' || codePoint <= 'Z';
>                     }
>                 }).build().generate(10))
> {code} and at that point I lost enthusiam with trying to replicate {{randomAlphanumeric}}.
> I don't think the average java developer would understand what a code point is in the
first place so then trying to get our automation testers to use the new API to implement random
alphanumeric character generation would be difficult.
> I therefore suggest that commons-text should have a copy of {{RandomStringUtils}} which
can even delegate to {{RandomStringGenerator}} or alternatively convenience static methods
for the common use cases.

This message was sent by Atlassian JIRA

View raw message