commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Tompkins (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TEXT-97) RandomStringGenerator should be able to pass multiple ranges to .withinRange()
Date Fri, 07 Jul 2017 13:18:00 GMT

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

Rob Tompkins commented on TEXT-97:
----------------------------------

Based on what [~erans] said above, it almost makes sense to have
{code:java}
addRangeToAlphabet(char rangeMin, char rangeMax)
{code}
to avoid the need for input validation. I also quite like the
{code:java}
RandomStringGenerator randAlphaNum = new RandomStringGenerator.Builder()
    .selectFrom(lowerCaseAscii(),
                upperCaseAscii(),
                decimalDigits()).build();
{code}
idea. Is there an argument against:
{code:java}
RandomStringGenerator randAlphaNum = new RandomStringGenerator.Builder()
    . addRangeToAlphabet('a','z')
    . addRangeToAlphabet('A','Z')
    . addRangeToAlphabet('0','9').build();
{code}
aside from the single line bit?

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

Mime
View raw message