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

net.jqwik.api.ExhaustiveGenerator Maven / Gradle / Ivy

The newest version!
package net.jqwik.api;

import java.util.function.*;

import org.apiguardian.api.*;
import org.jspecify.annotations.*;

import static org.apiguardian.api.API.Status.*;

/**
 * Used only internally to run and compute exhaustive generation of parameters
 */
@API(status = INTERNAL)
public interface ExhaustiveGenerator extends Iterable {

	long MAXIMUM_SAMPLES_TO_GENERATE = Integer.MAX_VALUE;

	@API(status = INTERNAL)
	abstract class ExhaustiveGeneratorFacade {
		private static final ExhaustiveGeneratorFacade implementation;

		static {
			implementation = FacadeLoader.load(ExhaustiveGeneratorFacade.class);
		}

		public abstract  ExhaustiveGenerator map(ExhaustiveGenerator self, Function mapper);

		public abstract  ExhaustiveGenerator filter(ExhaustiveGenerator self, Predicate filterPredicate, int maxMisses);

		public abstract  ExhaustiveGenerator<@Nullable T> injectNull(ExhaustiveGenerator self);

		public abstract  ExhaustiveGenerator ignoreExceptions(
			ExhaustiveGenerator self,
			Class[] exceptionTypes,
			int maxThrows
		);
	}

	/**
	 * @return the maximum number of values that will be generated
	 */
	long maxCount();

	default  ExhaustiveGenerator map(Function mapper) {
		return ExhaustiveGeneratorFacade.implementation.map(this, mapper);
	}

	default ExhaustiveGenerator filter(Predicate filterPredicate, int maxMisses) {
		return ExhaustiveGeneratorFacade.implementation.filter(this, filterPredicate, maxMisses);
	}

	default ExhaustiveGenerator injectNull() {
		return ExhaustiveGeneratorFacade.implementation.injectNull(this);
	}

	default ExhaustiveGenerator ignoreExceptions(int maxThrows, Class[] exceptionTypes) {
		return ExhaustiveGeneratorFacade.implementation.ignoreExceptions(this, exceptionTypes, maxThrows);
	}

}