net.jqwik.engine.properties.arbitraries.UseGeneratorsArbitrary Maven / Gradle / Ivy
The newest version!
package net.jqwik.engine.properties.arbitraries;
import java.util.*;
import java.util.function.*;
import net.jqwik.api.*;
import org.jspecify.annotations.*;
abstract class UseGeneratorsArbitrary implements Arbitrary {
private final RandomGenerator randomGenerator;
private final Function>> exhaustiveGeneratorFunction;
private final Function> edgeCasesSupplier;
public UseGeneratorsArbitrary(
RandomGenerator randomGenerator,
Function>> exhaustiveGeneratorFunction,
Function> edgeCasesSupplier
) {
this.randomGenerator = randomGenerator;
this.exhaustiveGeneratorFunction = exhaustiveGeneratorFunction;
this.edgeCasesSupplier = edgeCasesSupplier;
}
@Override
public RandomGenerator generator(int tries) {
return randomGenerator;
}
@Override
public Optional> exhaustive(long maxNumberOfSamples) {
return exhaustiveGeneratorFunction.apply(maxNumberOfSamples);
}
@Override
public EdgeCases edgeCases(int maxEdgeCases) {
return maxEdgeCases <= 0
? EdgeCases.none()
: edgeCasesSupplier.apply(maxEdgeCases);
}
}