net.jqwik.api.EdgeCases Maven / Gradle / Ivy
package net.jqwik.api;
import java.util.*;
import java.util.function.*;
import org.apiguardian.api.*;
import static org.apiguardian.api.API.Status.*;
@API(status = EXPERIMENTAL, since = "1.3.0")
public interface EdgeCases extends Iterable> {
@API(status = INTERNAL)
abstract class EdgeCasesFacade {
private static final EdgeCases.EdgeCasesFacade implementation;
static {
implementation = FacadeLoader.load(EdgeCases.EdgeCasesFacade.class);
}
public abstract EdgeCases fromSuppliers(List>> suppliers);
}
@API(status = EXPERIMENTAL, since = "1.3.9")
interface Config {
static Consumer> noConfig() {
return config -> {};
}
/**
* Don't use any of the default edge cases
*
* @return same configuration instance
*/
Config none();
/**
* Only include default edge cases for which {@linkplain #filter(Predicate)} returns true
*
* @param filter A predicate
* @return same configuration instance
*/
Config filter(Predicate filter);
/**
* Add one or more unshrinkable additional values as edge cases.
*
*
* Some arbitraries may allow those values to be outside the value range generated by this arbitrary;
* this is mainly due to implementation issues.
* In general you should not add "forbidden" values since it will weaken the semantics
* of built-in constraints.
*
*
* @param edgeCases The edge cases to add to default edge cases.
* @return same configuration instance
*/
@SuppressWarnings("unchecked")
Config add(T... edgeCases);
/**
* Include only the values given; and only if they are in the set of default edge cases
*
* @param includedValues The values to be included
* @return same configuration instance
*/
@SuppressWarnings("unchecked")
Config includeOnly(T... includedValues);
}
List>> suppliers();
default int size() {
return suppliers().size();
}
default boolean isEmpty() {
return size() == 0;
}
default Iterator> iterator() {
return suppliers().stream().map(Supplier::get).iterator();
}
@API(status = INTERNAL)
static EdgeCases fromSuppliers(List>> suppliers) {
return EdgeCasesFacade.implementation.fromSuppliers(suppliers);
}
@API(status = INTERNAL)
static EdgeCases none() {
return fromSuppliers(Collections.emptyList());
}
@API(status = INTERNAL)
static EdgeCases fromSupplier(Supplier> supplier) {
return fromSuppliers(Collections.singletonList(supplier));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy