T - type of values generated@FunctionalInterface public interface Gen<T>
| Modifier and Type | Method and Description |
|---|---|
default T |
_gen(SourceOfRandomness random,
GenerationStatus status)
Deprecated.
For use by junit-quickcheck only -- when we migrate to Java 9,
this method will likely become
private. |
default Gen<T> |
filter(Predicate<? super T> condition)
Gives a generation strategy that produces a random value by having this
strategy produce random values until one satisfies the given condition,
then using that value as the result.
|
default Gen<Optional<T>> |
filterOptional(Predicate<? super T> condition)
|
default <U> Gen<U> |
flatMap(Function<? super T,? extends Gen<? extends U>> mapper)
Gives a generation strategy that produces a random value by having this
strategy produce a random value, then applying the given function to
that value, and asking the result to produce a value.
|
static <U> Pair<Integer,Gen<? extends U>> |
freq(int weight,
Gen<? extends U> generator)
Helper for making a weighted generator indicator for
frequency(Pair, Pair[]). |
static <U> Gen<U> |
frequency(Pair<Integer,Gen<? extends U>> first,
Pair<Integer,Gen<? extends U>>... rest)
Gives a generation strategy that produces a random value by choosing
one of the given generators at random with probability in proportion
to their given weights, and having it generate a value.
|
T |
generate(SourceOfRandomness random,
GenerationStatus status)
Generates a value, possibly influenced by a source of randomness and
metadata about the generation.
|
default <U> Gen<U> |
map(Function<? super T,? extends U> mapper)
Gives a generation strategy that produces a random value by having this
strategy produce a random value, then applying the given function to
that value, and returning the result.
|
static <U> Gen<U> |
oneOf(Gen<? extends U> first,
Gen<? extends U>... rest)
Gives a generation strategy that produces a random value by choosing
one of the given generators at random with (approximately) equal
probability, and having it generate a value.
|
static <U> Gen<U> |
oneOf(U first,
U... rest)
Gives a generation strategy that produces a random value by choosing
one of the given values at random with (approximately) equal
probability.
|
static <U> Gen<U> |
pure(U constant)
Gives a generation strategy that produces the given value, always.
|
default Gen<List<T>> |
times(int times) |
T generate(SourceOfRandomness random, GenerationStatus status)
random - source of randomness to be used when generating the valuestatus - an object that can be used to influence the generated
value. For example, generating lists can use the size method to generate lists with a given
number of elements.default <U> Gen<U> map(Function<? super T,? extends U> mapper)
U - type of values produced by the mapped generation strategymapper - function that converts receiver's random values to
result's valuesdefault <U> Gen<U> flatMap(Function<? super T,? extends Gen<? extends U>> mapper)
U - type of values produced by the mapped generation strategymapper - function that converts receiver's random values to
another kind of generation strategydefault Gen<T> filter(Predicate<? super T> condition)
condition - a condition the generated value is to meetdefault Gen<Optional<T>> filterOptional(Predicate<? super T> condition)
Gives a generation strategy that produces a random value by having
this strategy produce a random value and wrapping it in an
Optional; if the value meets the given condition, the wrapping
optional will be present.
If the value meets the condition but is null, the wrapping
optional will not be considered
present.
condition - a condition the generated value is to meetstatic <U> Gen<U> pure(U constant)
U - type of values produced by the resulting strategyconstant - the value to be returned by the resulting strategy@SafeVarargs static <U> Gen<U> oneOf(U first, U... rest)
U - type of values produced by the resulting strategyfirst - first possible choicerest - the other possible choices@SafeVarargs static <U> Gen<U> oneOf(Gen<? extends U> first, Gen<? extends U>... rest)
U - type of values produced by the resulting strategyfirst - first possible generator choicerest - the other possible generator choices@SafeVarargs static <U> Gen<U> frequency(Pair<Integer,Gen<? extends U>> first, Pair<Integer,Gen<? extends U>>... rest)
U - type of values produced by the resulting strategyfirst - first possible (weighted) generator choicerest - the other possible (weighted) generator choicesstatic <U> Pair<Integer,Gen<? extends U>> freq(int weight, Gen<? extends U> generator)
frequency(Pair, Pair[]).U - type of values produced by the given generation strategyweight - an integer weightgenerator - a generator@Deprecated default T _gen(SourceOfRandomness random, GenerationStatus status)
private.random - source of randomness to be used when generating the valuestatus - an object that can be used to influence the generated
value. For example, generating lists can use the size method to generate lists with a given
number of elements.Copyright © 2019. All rights reserved.