All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jqwik.engine.properties.stateful.DefaultActionSequenceArbitrary Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
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 TypedCloneable implements ActionSequenceArbitrary {

	private final Arbitrary> actionArbitrary;

	private int size = 0;

	@SuppressWarnings("unchecked")
	public DefaultActionSequenceArbitrary(Arbitrary> actionArbitrary) {
		this.actionArbitrary = (Arbitrary>) actionArbitrary;
	}

	@Override
	public ActionSequenceArbitrary ofMinSize(int minSize) {
		return this;
	}

	@Override
	public ActionSequenceArbitrary ofSize(int size) {
		DefaultActionSequenceArbitrary clone = typedClone();
		clone.size = size;
		return clone;
	}

	@Override
	public RandomGenerator> generator(int genSize) {
		final int effectiveMaxSize =
			size != 0 ? size : (int) Math.max(Math.round(Math.sqrt(genSize)), 10);
		return new ActionSequenceGenerator<>(actionArbitrary, genSize, effectiveMaxSize);
	}

	@Override
	public EdgeCases> edgeCases(int maxEdgeCases) {
		return EdgeCases.none();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy