net.jqwik.api.Arbitrary Maven / Gradle / Ivy
package net.jqwik.api;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import org.apiguardian.api.*;
import net.jqwik.api.arbitraries.*;
import static org.apiguardian.api.API.Status.*;
/**
* The main interface for representing objects that can be generated and shrunk.
*
* @param The type of generated objects. Primitive objects (e.g. int, boolean etc.) are represented by their boxed
* type (e.g. Integer, Boolean).
*/
@API(status = STABLE, since = "1.0")
public interface Arbitrary {
@API(status = INTERNAL)
abstract class ArbitraryFacade {
private static final ArbitraryFacade implementation;
static {
implementation = FacadeLoader.load(ArbitraryFacade.class);
}
public abstract Optional> flatMapExhaustiveGenerator(
ExhaustiveGenerator self,
Function> mapper,
long maxNumberOfSamples
);
public abstract ListArbitrary list(Arbitrary elementArbitrary);
public abstract SetArbitrary set(Arbitrary elementArbitrary);
public abstract StreamArbitrary stream(Arbitrary elementArbitrary);
public abstract IteratorArbitrary iterator(Arbitrary elementArbitrary);
public abstract StreamableArbitrary array(Arbitrary elementArbitrary, Class arrayClass);
public abstract Stream sampleStream(Arbitrary arbitrary);
public abstract Arbitrary injectNull(Arbitrary self, double nullProbability);
}
/**
* Create the random generator for an arbitrary
*
* @param genSize a very unspecific configuration parameter that can be used
* to influence the configuration and behaviour of a random generator
* if and only if the generator wants to be influenced.
* Many generators are independent of genSize.
*
* The default value of {@code genSize} is the number of tries configured
* for a property. Use {@linkplain Arbitrary#fixGenSize(int)} to fix
* the parameter for a given arbitrary.
* @return a new random generator instance
*/
RandomGenerator generator(int genSize);
/**
* Sometimes simplifies test writing
* @return The same instance but with type Arbitrary<Object>
*/
@SuppressWarnings("unchecked")
@API(status = INTERNAL)
default Arbitrary
© 2015 - 2025 Weber Informatics LLC | Privacy Policy