net.jqwik.api.arbitraries.StreamableArbitrary Maven / Gradle / Ivy
package net.jqwik.api.arbitraries;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import org.apiguardian.api.*;
import net.jqwik.api.*;
import static org.apiguardian.api.API.Status.*;
/**
* Fluent interface to add functionality to arbitraries whose generation artefacts
* can be streamed, e.g. {@link List}, {@link Set}, {@link Stream} and Arrays
*/
@API(status = MAINTAINED, since = "1.2.1")
public interface StreamableArbitrary extends SizableArbitrary {
/**
* Given an {@code initial} argument use {@code accumulator} to produce
* the final result.
*
* @param initial The initial argument. Also the result if streamable is empty
* @param accumulator The function used to reduce a streamable into a result one by one
* @param The result type
* @return The result of accumulating all elements in streamable
*/
Arbitrary reduce(R initial, BiFunction accumulator);
/**
* Fix the size to {@code size}.
*/
default StreamableArbitrary ofSize(int size) {
return ofMinSize(size).ofMaxSize(size);
}
/**
* Set lower size boundary {@code minSize} (included).
*/
StreamableArbitrary ofMinSize(int minSize);
/**
* Set upper size boundary {@code maxSize} (included).
*/
StreamableArbitrary ofMaxSize(int maxSize);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy