After upgrading to org.apache.commons:commons-lang3:3.6from, 3.5I get a lot of warnings about RandomStringUtilsthat that are out of date. Recommended Alternative RandomStringGeneratorFrom commons-text. However, this class is very awkward to use if all you need is just a string (say in unit test). For comparison:
String name1 = RandomStringUtils.randomAlphabetic(FIRST_NAME_LENGTH);
String name2 = new RandomStringGenerator.Builder().withinRange('a', 'z').build()
.generate(FIRST_NAME_LENGTH);
(I know that these are not even the same semantics, but I wanted it to be short.)
So I'm looking for a short and elegant way, ideally a replacement; Java 8, Spring, Guava, and even test libraries are welcome.
source
share