[ 
https://issues.apache.org/jira/browse/TEXT-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16071331#comment-16071331
 ] 

Gilles commented on TEXT-97:
----------------------------

I'm contradicting myself but I'm not so happy with
{code}
withinRange(char[] ... pairs)
{code}

# This API does not prevent passing an argument that is not an array of pairs. 
It may throw {{ArrayIndexOutOfBoundsException}} or silently discard part of the 
input.
# Usage requires the knowledge of the ordering of the characters (whereas, it 
is ultimately irrelevant to the output).

What about
{code}
withinRange(char ... args)
{code}
where the code will check that {{args.length}} is a multiple of 2?

HoweverI still wonder why it would not be better to have helper methods that 
generate a {{char[]}} to be used with
{code}
selectFrom(char ... args)
{code}
I.e. somewhere in TEXT, there could exist
{code}
public char[] numericCharacters() {
    return new char[] {'0', '1', '2', /* etc. */ };
}
{code}


> 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)

Reply via email to