[jira] [Commented] (LANG-900) New RandomUtils class

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (LANG-900) New RandomUtils class

ASF GitHub Bot (Jira)

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

Brent Worden commented on LANG-900:
-----------------------------------

How about the ability to supply a user defined Random instance?

{code}
public static byte[] nextBytes(int count) {
    return nextBytes(count, RANDOM);
}

public static byte[] nextBytes(int count, Random rng) {
    Validate.isTrue(count >= 0, "Count cannot be negative.");

    byte[] result = new byte[count];
    rng.nextBytes(result);
    return result;
}
{code}

               

> New RandomUtils class
> ---------------------
>
>                 Key: LANG-900
>                 URL: https://issues.apache.org/jira/browse/LANG-900
>             Project: Commons Lang
>          Issue Type: New Feature
>            Reporter: Duncan Jones
>            Priority: Minor
>         Attachments: RandomUtils.java, RandomUtilsTest.java
>
>
> Attached is a new {{RandomUtils}} class and associated test, which offers some methods not available in the standard {{Random}} class:
>  - a {{nextBytes(int count)}} method that returns a byte array
>  - versions of {{nextInt}}, {{nextLong}}, {{nextFloat}} and {{nextDouble}} that return a value within a range.
> Comments very welcome!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira