net.jqwik.engine.properties.stateful.DefaultActionSequenceArbitrary Maven / Gradle / Ivy
package net.jqwik.engine.properties.stateful;
import net.jqwik.api.*;
import net.jqwik.api.stateful.*;
import net.jqwik.engine.properties.arbitraries.*;
public class DefaultActionSequenceArbitrary extends AbstractArbitraryBase implements ActionSequenceArbitrary {
private final Arbitrary> actionArbitrary;
private int minSize = 1;
private int maxSize = 0;
public DefaultActionSequenceArbitrary(Arbitrary> actionArbitrary) {
this.actionArbitrary = actionArbitrary;
}
@Override
public ActionSequenceArbitrary ofMinSize(int minSize) {
DefaultActionSequenceArbitrary clone = typedClone();
clone.minSize = Math.max(1, minSize);
return clone;
}
@Override
public ActionSequenceArbitrary ofMaxSize(int maxSize) {
DefaultActionSequenceArbitrary clone = typedClone();
clone.maxSize = Math.max(Math.max(1, maxSize), minSize);
return clone;
}
@Override
public RandomGenerator> generator(int genSize) {
final int effectiveMaxSize =
maxSize != 0 ? maxSize
: (int) Math.max(Math.round(Math.sqrt(genSize)), 10);
return new ActionSequenceGenerator<>(actionArbitrary, genSize, minSize, effectiveMaxSize);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy