[
https://issues.apache.org/jira/browse/TEXT-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16071427#comment-16071427
]
Gilles commented on TEXT-97:
----------------------------
bq. those should call .withinRange(char[] ...)
I don't think so, unless you have an argument that the alternative approach
(i.e. methods that create a {{char[]}}) is not good.
You'd have a point if the ranges were not ultimately converted to a list of
{{Character}} (but it seems that doing without would complicate the generator).
bq. if someone in future would needs another range
Then, my opinion is to not populate the API with potentially unused methods.
Indeed, TEXT-96 requests three utilities:
* randomNumeric
* randomAlphabetic
* randomAlphanumeric
Given the methods which I suggested above, and changing
{code}
selectFrom(char ...)
{code}
to
{code}
selectFrom(char[] ...)
{code}
the OP could obtain what he wants:
{code}
RandomStringGenerator randAlphaNum = new RandomStringGenerator.Builder()
.selectFrom(lowerCaseAscii(),
upperCaseAscii(),
decimalDigits()).build();
String s = randAlphaNum.generate(10);
{code}
Having (or not) a {{RandomStringUtils}} class that would contain syntactic
sugar allowing usage such as
{code}
RandomStringUtils.randomNumeric(10)
{code}
is another discussion.
> RandomStringGenerator should be able to pass multiple ranges to .withinRange()
> ------------------------------------------------------------------------------
>
> Key: TEXT-97
> URL: https://issues.apache.org/jira/browse/TEXT-97
> Project: Commons Text
> Issue Type: Improvement
> Reporter: Amey Jadiye
> Fix For: 1.2
>
>
> Users should have ability to pass multiple ranges to generate desired output.
> Ex. For
> *.randomNumeric()*
> {code}
> char [][] ranges = {{'0','9'}};
> RandomStringGenerator generator = new
> RandomStringGenerator.Builder().withinRange(ranges).build();
> {code}
> *.randomAlphabetic()*
> {code}
> char [][] ranges = {{'A','Z'}}; // or {{'A','Z'},{'a','z'}}
> RandomStringGenerator generator = new
> RandomStringGenerator.Builder().withinRange(ranges).build();
> {code}
> *.randomAlphanumeric()*
> {code}
> char [][] ranges = {{'0','9'},{'A','Z'},{'a','b'}};
> RandomStringGenerator generator = new
> RandomStringGenerator.Builder().withinRange(ranges).build();
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)