net.jqwik.engine.properties.SourceOfRandomness Maven / Gradle / Ivy
package net.jqwik.engine.properties;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import net.jqwik.api.*;
public class SourceOfRandomness {
private static Supplier RNG = ThreadLocalRandom::current;
private static ThreadLocal current = ThreadLocal.withInitial(Random::new);
public static String createRandomSeed() {
return Long.toString(RNG.get().nextLong());
}
public static Random create(String seed) {
try {
Random random = new Random(Long.parseLong(seed));
current.set(random);
return random;
} catch (NumberFormatException nfe) {
throw new JqwikException(String.format("[%s] is not a valid random seed.", seed));
}
}
public static Random current() {
return current.get();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy