com.insightfullogic.lambdabehave.impl.generators.RandomNumberGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lambda-behave Show documentation
Show all versions of lambda-behave Show documentation
A modern testing and behavioural specification framework for Java 8
package com.insightfullogic.lambdabehave.impl.generators;
import com.insightfullogic.lambdabehave.generators.SourceGenerator;
import java.util.Random;
public class RandomNumberGenerator implements SourceGenerator {
private final Random random;
private final long seed;
public RandomNumberGenerator() {
// TODO: investigate more non-determinism in the seed
this(System.nanoTime());
}
public RandomNumberGenerator(final long seed) {
random = new Random(seed);
this.seed = seed;
}
@Override
public int generateInt(final int maxValue) {
return random.nextInt(maxValue);
}
@Override
public long getSeed() {
return seed;
}
}