xdrop / jRand

A Java library to generate random data for all sorts of things. Java random data faker
Apache License 2.0
27 stars 14 forks source link

Flush "properties"/methods? #48

Open Tekknoman opened 4 years ago

Tekknoman commented 4 years ago

Im having issues with using the string generator multiple times. Somehow if i set some "properties"/use some methods for the first string it works as it should.... but if try generating a second string afterwards, it uses the "properties"/methods for the new string and merges them with the newly set generator "properies" Here an Example for that:

public static void main(String[] args) {
        StringGenerator StringGenerator = JRand.string();
        String String1 = StringGenerator.alpha().casing("upper").length(3).gen();
        String String2 = StringGenerator.symbols().length(3).gen();
        System.out.print("String 1: " + String1 + " String 2: " + String2);
}

This gives me this: String 1: THS String 2: (PL

I found a Workaround for this by adding StringGenerator = JRand.string(); between the lines where the strings are generated, but ist there an easyer way for that like StringGenerator.flush() or is that just an issue with that Library? Or even better, so that .gen() empties out the pool every time it's used.