net.jqwik.api.arbitraries.SetArbitrary Maven / Gradle / Ivy
package net.jqwik.api.arbitraries;
import java.util.*;
import java.util.function.*;
import org.apiguardian.api.*;
import net.jqwik.api.*;
import static org.apiguardian.api.API.Status.*;
/**
* Fluent interface to add functionality to arbitraries that generate instances
* of type {@linkplain Set}
*/
@API(status = MAINTAINED, since = "1.3.2")
public interface SetArbitrary extends StreamableArbitrary> {
/**
* Fix the size to {@code size}.
*
* @param size The size of the generated set
* @return new arbitrary instance
*/
@Override
default SetArbitrary ofSize(int size) {
return this.ofMinSize(size).ofMaxSize(size);
}
/**
* Set lower size boundary {@code minSize} (included).
*
* @param minSize The minimum size of the generated set
* @return new arbitrary instance
*/
SetArbitrary ofMinSize(int minSize);
/**
* Set upper size boundary {@code maxSize} (included).
*
* @param maxSize The maximum size of the generated set
* @return new arbitrary instance
*/
SetArbitrary ofMaxSize(int maxSize);
/**
* Map over each element of the generated streamable giving access to the
* all elements when streaming.
*
* @param The target type of a set to generate
* @param mapper Mapper function to element type U
* @return arbitrary of a set of Us
*/
@API(status = MAINTAINED, since = "1.4.0")
Arbitrary> mapEach(BiFunction, T, U> mapper);
/**
* Flat-map over each element of the generated streamable giving access to the
* all elements when streaming.
*
* @param The target type of a set to generate
* @param flatMapper Mapper function to arbitrary of element type U
* @return arbitrary of a set of Us
*/
@API(status = MAINTAINED, since = "1.4.0")
Arbitrary> flatMapEach(BiFunction, T, Arbitrary> flatMapper);
/**
* Add the constraint that elements of the generated set must be unique
* relating to an element's "feature" being extracted using the
* {@code by} function.
* The extracted features are being compared using {@linkplain Object#equals(Object)}.
*
*
* The constraint can be combined with other {@linkplain #uniqueElements(Function)} constraints.
*
*
* @return new arbitrary instance
*/
@API(status = MAINTAINED, since = "1.4.0")
SetArbitrary uniqueElements(Function by);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy