commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Duncan Jones (JIRA)" <>
Subject [jira] [Commented] (TEXT-34) Add class to generate random strings
Date Mon, 19 Dec 2016 19:46:58 GMT


Duncan Jones commented on TEXT-34:

Thanks for the feedback Emmanuel. It's great you have a real life use case we can examine.

One concern I had about adding that functionality was it didn't seem very text-oriented to
me. It is essentially selecting random objects from an array; the objects just happen to be
{{char}} or {{int}} values. 

The specific functionality you describe can be achieved with the filters, but I appreciate
that was only an example:

String licence = new RandomStringBuilder().ofLength(20).withMinimum('A').withMaximum('Z')
        .filteredBy(new CodePointPredicate() {
            public boolean test(int codePoint) {
                return codePoint != 'O' && codePoint != 'I';

So, in short, it was a deliberate omission, but I forgot to kick off the discussion about
whether it was a good idea!

By the way, I'm not suggesting filters are an appropriate substitution for the original functionality.
There's no efficient way you can use filters to create an arbitrary collection of characters.
I'm questioning whether the original functionality belongs in a text-processing component.

> Add class to generate random strings
> ------------------------------------
>                 Key: TEXT-34
>                 URL:
>             Project: Commons Text
>          Issue Type: New Feature
>            Reporter: Duncan Jones
>            Assignee: Duncan Jones
> The {{RandomStringUtils}} class will be deprecated in Commons Lang and reborn in Commons
> Because the original class has some complicated parameters and potentially unnecessary
capabilities, I'll simplify as I move it across. I'll also ensure the class plays nicely with
Unicode characters.

This message was sent by Atlassian JIRA

View raw message