|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.java.quickcheck.generator.CombinedGenerators
@Iterables @Samples public class CombinedGenerators
CombinedGenerators
can be used to create custom Generator
s.
Field Summary | |
---|---|
static int |
DEFAULT_COLLECTION_MAX_SIZE
|
static int |
DEFAULT_MAX_TRIES
|
Constructor Summary | |
---|---|
CombinedGenerators()
|
Method Summary | ||
---|---|---|
static
|
arrays(Generator<? extends T> content,
Class<T> type)
Create a generator of arrays with values from the content generator. |
|
static
|
arrays(Generator<? extends T> content,
Generator<Integer> size,
Class<T> type)
Create a generator of arrays with values from the content generator. |
|
static Generator<byte[]> |
byteArrays()
Create a generator of byte arrays. |
|
static Generator<byte[]> |
byteArrays(Generator<Byte> content,
Generator<Integer> size)
Create a generator of byte arrays. |
|
static Generator<byte[]> |
byteArrays(Generator<Integer> size)
Create a generator of byte arrays. |
|
static
|
ensureValues(Collection<T> ensuredValues)
Create a deterministic generator which guarantees that all values from the ensuredValues collection will be returned if enough calls to Generator.next() are issued (i.e. ensuredValues.size() <= # of
runs). |
|
static
|
ensureValues(Collection<T> ensuredValues,
Generator<T> otherValues)
Create a deterministic generator which guarantees that all values from the ensuredValues collection will be returned if enough calls to Generator.next() are issued (i.e. ensuredValues.size() <= # of
runs). |
|
static
|
ensureValues(T... content)
Create a deterministic generator which guarantees that all values from the ensuredValues array will be returned if enough calls to Generator.next() are issued (i.e. ensuredValues.size() <= # of
runs). |
|
static
|
excludeValues(Collection<T> values,
Collection<T> excluded)
Create a generator that omits a given set of values. |
|
static
|
excludeValues(Collection<T> values,
T... excluded)
Create a generator that omits a given set of values. |
|
static
|
excludeValues(Generator<T> generator,
Collection<T> excluded)
Create a generator that omits a given set of values. |
|
static
|
excludeValues(Generator<T> generator,
T... excluded)
Create a generator that omits a given set of values. |
|
static
|
excludeValues(Generator<T> generator,
T excluded)
Create a generator that omits a given value. |
|
static
|
frequency(Generator<T> generator,
int weight)
Create a frequency generator. |
|
static Generator<int[]> |
intArrays()
Create a generator of integer arrays. |
|
static Generator<int[]> |
intArrays(Generator<Integer> size)
Create a generator of integer arrays. |
|
static Generator<int[]> |
intArrays(Generator<Integer> content,
Generator<Integer> size)
Create a generator of integer arrays. |
|
static
|
iterators(Generator<? extends T> content)
Create a generator of iterators. |
|
static
|
iterators(Generator<? extends T> content,
Generator<Integer> size)
Create a generator of iterators. |
|
static
|
lists(Generator<? extends T> content)
Create a generator of lists with values from the content generator. |
|
static
|
lists(Generator<? extends T> content,
Generator<Integer> size)
Create a generator of lists with values from the content generator. |
|
static
|
lists(Generator<? extends T> content,
int low)
Create a generator of lists with values from the content generator. |
|
static
|
lists(Generator<? extends T> content,
int low,
int high)
Create a generator of lists with values from the content generator. |
|
static
|
maps(Generator<K> keys,
Generator<V> values)
Create a generator of maps . |
|
static
|
maps(Generator<K> keys,
Generator<V> values,
Generator<Integer> size)
Create a generator of maps . |
|
static
|
maps(Map<K,V> supermap)
Create a generator of maps from a given map. |
|
static
|
maps(Map<K,V> supermap,
Generator<Integer> sizes)
Create a generator of maps from a given map. |
|
static
|
nonEmptyArrays(Generator<? extends T> content,
Class<T> type)
Create a generator of arrays that are not empty. |
|
static
|
nonEmptyIterators(Generator<T> content)
Create a generator of iterators. |
|
static
|
nonEmptyLists(Generator<? extends T> content)
Create a generator of non-empty lists with values from the content generator. |
|
static
|
nonEmptySets(Generator<? extends T> content)
Create a generator of sets that are not empty. |
|
static
|
nullsAnd(Generator<T> generator)
Create a generator as a combination of a null value generator and generator of type T. |
|
static
|
nullsAnd(Generator<T> generator,
int weight)
Create a generator as a combination of a null value generator and generator of type T. |
|
static
|
oneOf(Generator<T> generator)
OneOf is a convenience method for frequency(Generator, int) when all generator
share the same weight. |
|
static
|
pairs(Generator<A> first,
Generator<B> second)
Create a generator of pairs of type A for the left value and type B for the right value. |
|
static
|
sets(Generator<? extends T> content)
Create a generator of sets with values from the content generator. |
|
static
|
sets(Generator<? extends T> content,
Generator<Integer> size)
Create a generator of sets with values from the content generator. |
|
static
|
sets(Generator<? extends T> content,
int low,
int high)
Create a generator of sets with values from the content generator. |
|
static
|
sets(Set<T> superset)
Create a generator of subsets from a given set. |
|
static
|
sets(Set<T> superset,
Generator<Integer> size)
Create a generator of subsets from a given set. |
|
static
|
sortedLists(Generator<T> content)
Create a generator of sorted lists with values from the content generator. |
|
static
|
sortedLists(Generator<T> content,
Generator<Integer> size)
Create a generator of sorted lists with values from the content generator. |
|
static
|
sortedLists(Generator<T> content,
int low,
int high)
Create a generator of sorted lists with values from the content generator. |
|
static
|
triples(Generator<A> first,
Generator<B> second,
Generator<C> third)
Create a generator of triples of the types A, B and C for first, second and third value. |
|
static
|
uniqueValues(Generator<T> generator)
Create a generator that ensures unique values The actual values are created with an arbitrary generator. |
|
static
|
uniqueValues(Generator<T> generator,
Comparator<? super T> comparator)
Create a generator that ensures unique values. |
|
static
|
uniqueValues(Generator<T> generator,
Comparator<? super T> comparator,
int tries)
Create a generator that ensures unique values. |
|
static
|
uniqueValues(Generator<T> generator,
int tries)
Create a generator that ensures unique values. |
|
static
|
vectors(Generator<T> content,
int size)
Create a generator which will create vectors (here lists) of type T. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_COLLECTION_MAX_SIZE
public static final int DEFAULT_MAX_TRIES
Constructor Detail |
---|
public CombinedGenerators()
Method Detail |
---|
public static <T> FrequencyGenerator<T> frequency(Generator<T> generator, int weight)
Create a frequency generator. The frequency of Generator
usage
depends on the generator weight.
T
- type of values generated by the generators.generator
- pairs of generators and their weights used to created the
valuespublic static <T> ExtendibleGenerator<T,T> oneOf(Generator<T> generator)
frequency(Generator, int)
when all generator
share the same weight.
public static <T> Generator<List<T>> vectors(Generator<T> content, int size)
T
- Type of the list values.size
- Number of element in the vector.public static <A,B> Generator<Pair<A,B>> pairs(Generator<A> first, Generator<B> second)
A
- Type of left value.B
- Type of right value.first
- Generator for left values.second
- Generator for right values.public static <A,B,C> Generator<Triple<A,B,C>> triples(Generator<A> first, Generator<B> second, Generator<C> third)
A
- Type of first value.B
- Type of second value.C
- Type of third value.first
- Generator for first values.second
- Generator for second values.third
- Generator for third values.public static <T> Generator<T> nullsAnd(Generator<T> generator)
T
- Type of the values generated.public static <T> Generator<T> nullsAnd(Generator<T> generator, int weight)
T
- Type of the values generated.weight
- weight of the provided generatorpublic static <T> Generator<Set<T>> sets(Generator<? extends T> content)
T
- type of set elements generatedcontent
- generator providing the content of sets generatedpublic static <T> Generator<Set<T>> sets(Generator<? extends T> content, Generator<Integer> size)
T
- type of set elements generatedcontent
- generator providing the content of sets generatedsize
- size of the sets generatedpublic static <T> Generator<Set<T>> sets(Generator<? extends T> content, int low, int high)
T
- type of set elements generatedcontent
- generator providing the content of sets generatedlow
- minimal sizehigh
- max sizepublic static <T> Generator<Set<T>> nonEmptySets(Generator<? extends T> content)
T
- type of set elements generatedcontent
- generator providing the content of sets generatedpublic static <T> Generator<Set<T>> sets(Set<T> superset)
T
- type of set elements generatedsuperset
- of the generated setpublic static <T> Generator<Set<T>> sets(Set<T> superset, Generator<Integer> size)
T
- type of set elements generatedsuperset
- of the generated setsize
- of the generated setpublic static <T> Generator<Iterator<T>> iterators(Generator<? extends T> content)
Values of the elements will be taken from the content generator.
T
- type of iterator elements generatedcontent
- generator providing the content of iterators generatedpublic static <T> Generator<Iterator<T>> nonEmptyIterators(Generator<T> content)
Values of the elements will be taken from the content generator. The generated iterator will have at least one element.
T
- type of iterator elements generatedcontent
- generator providing the content of iterators generatedpublic static <T> Generator<Iterator<T>> iterators(Generator<? extends T> content, Generator<Integer> size)
Values of the elements will be taken from the content generator. The length of the iterators will be determined with the size generator.
T
- type of iterator elements generatedcontent
- generator providing the content of iterators generatedsize
- used to determine the number of elements of the iteratorpublic static <T> Generator<List<T>> lists(Generator<? extends T> content)
Distribution.UNIFORM
.
T
- type of list elements generatedcontent
- generator providing the content of lists generatedpublic static <T> Generator<List<T>> nonEmptyLists(Generator<? extends T> content)
Distribution.UNIFORM
.
T
- type of list elements generatedcontent
- generator providing the content of lists generatedpublic static <T> Generator<List<T>> lists(Generator<? extends T> content, Generator<Integer> size)
T
- type of list elements generatedcontent
- generator providing the content of lists generatedsize
- integer used to determine the list sizepublic static <T> Generator<List<T>> lists(Generator<? extends T> content, int low, int high)
T
- type of list elements generatedcontent
- generator providing the content of lists generatedlow
- minimal sizehigh
- max sizepublic static <T> Generator<List<T>> lists(Generator<? extends T> content, int low)
T
- type of list elements generatedcontent
- generator providing the content of lists generatedlow
- minimal size. If low is larger than
DEFAULT_COLLECTION_MAX_SIZE
then it
is the upper size bound as well.public static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content)
T
- type of list elements generatedcontent
- generator providing the content of lists generatedpublic static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content, int low, int high)
T
- type of list elements generatedcontent
- generator providing the content of lists generatedlow
- minimal sizehigh
- max sizepublic static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content, Generator<Integer> size)
T
- type of list elements generatedcontent
- generator providing the content of lists generatedsize
- integer used to determine the list sizepublic static <T> Generator<T[]> arrays(Generator<? extends T> content, Class<T> type)
Distribution.UNIFORM
.
T
- type of arrays elements generatedcontent
- generator providing the content of arrays generatedtype
- type of arrays generatedpublic static <T> Generator<T[]> nonEmptyArrays(Generator<? extends T> content, Class<T> type)
T
- type of arrays elements generatedcontent
- generator providing the content of arrays generatedtype
- type of arrays generatedpublic static <T> Generator<T[]> arrays(Generator<? extends T> content, Generator<Integer> size, Class<T> type)
T
- type of arrays elements generatedcontent
- generator providing the content of arrays generatedsize
- integer used to determine the array sizetype
- type of arrays generatedpublic static Generator<byte[]> byteArrays()
ByteArrayGenerator.MIN_SIZE
and
ByteArrayGenerator.MAX_SIZE
constants.
public static Generator<byte[]> byteArrays(Generator<Integer> size)
size
- integer used to determine the array sizepublic static Generator<byte[]> byteArrays(Generator<Byte> content, Generator<Integer> size)
size
- integer used to determine the array sizecontent
- generator for the byte array contentpublic static Generator<int[]> intArrays()
public static Generator<int[]> intArrays(Generator<Integer> size)
size
- integer used to determine the array sizepublic static Generator<int[]> intArrays(Generator<Integer> content, Generator<Integer> size)
size
- integer used to determine the array sizecontent
- generator for the integer array contentpublic static <K,V> Generator<Map<K,V>> maps(Generator<K> keys, Generator<V> values)
maps
.
This is a generator for simple maps where the values are not related to the keys.
keys
- Generator
for the keys of the mapvalues
- Generator
for the values of the mappublic static <K,V> Generator<Map<K,V>> maps(Generator<K> keys, Generator<V> values, Generator<Integer> size)
maps
.
This is a generator for simple maps where the values are not related to the keys.
keys
- Generator
for the keys of the mapvalues
- Generator
for the values of the mapsize
- integer used to determine the size of the generated mappublic static <K,V> Generator<Map<K,V>> maps(Map<K,V> supermap)
The entry set of the generated maps are subsets of the given map's entry set.
supermap
- of the generated mapspublic static <K,V> Generator<Map<K,V>> maps(Map<K,V> supermap, Generator<Integer> sizes)
The entry set of the generated maps are subsets of the given map's entry set.
supermap
- of the generated mapssizes
- of the generated mapspublic static <T> StatefulGenerator<T> ensureValues(Collection<T> ensuredValues)
Generator.next()
are issued (i.e. ensuredValues.size() <= # of
runs). The order of values is undefined.
T
- type of values return by the generatorpublic static <T> StatefulGenerator<T> ensureValues(T... content)
Generator.next()
are issued (i.e. ensuredValues.size() <= # of
runs). The order of values is undefined.
T
- type of values return by the generatorpublic static <T> StatefulGenerator<T> ensureValues(Collection<T> ensuredValues, Generator<T> otherValues)
Create a deterministic generator which guarantees that all values from
the ensuredValues collection will be returned if enough calls to
Generator.next()
are issued (i.e. ensuredValues.size() <= # of
runs). The order of values is undefined.
If all values of ensuredValues are generated calls to
Generator.next()
will return values from the otherValues
generator.
T
- type of values return by the generatorpublic static <T> StatefulGenerator<T> uniqueValues(Generator<T> generator, int tries)
Create a generator that ensures unique values.
The actual values are created with an arbitrary generator.
Note: unique generator depends on valid implementation of equals and hashCode method of the content type generated.
T
- type of values return by the generatorgenerator
- used to create the raw values. This generator can
create duplicate valuestries
- Number of tries to create a new unique value. After this
number of tries is exceeded the generation aborts with a
GeneratorException
.
public static <T> StatefulGenerator<T> uniqueValues(Generator<T> generator, Comparator<? super T> comparator, int tries)
Create a generator that ensures unique values.
The actual values are created with an arbitrary generator.
Unique generator depends on the Comparator
implementation to
decide if two instances are the same (i.e. when the comparator returns 0
for Comparator.compare(Object, Object)
).
T
- type of values returned by the generatorgenerator
- used to create the raw values. This generator can create
duplicate valuescomparator
- that decides if two values are of the same equivalence class.tries
- Number of tries to create a new unique value. After this
number of tries is exceeded the generation aborts with a
GeneratorException
.
public static <T> StatefulGenerator<T> uniqueValues(Generator<T> generator, Comparator<? super T> comparator)
Create a generator that ensures unique values.
The actual values are created with an arbitrary generator.
Unique generator depends on the Comparator
implementation to
decide if two instances are the same (i.e. when the comparator returns 0
for Comparator.compare(Object, Object)
).
T
- type of values returned by the generatorgenerator
- used to create the raw values. This generator can create
duplicate valuescomparator
- that decides if two values are of the same equivalence class.
public static <T> StatefulGenerator<T> uniqueValues(Generator<T> generator)
Create a generator that ensures unique values
The actual values are created with an arbitrary generator.
Note: unique generator depends on valid implementation of equals and hashCode method of the content type generated.
T
- type of values return by the generatorgenerator
- used to create the raw values. This generator can
create duplicate values
public static <T> Generator<T> excludeValues(Generator<T> generator, T excluded)
generator
- used to create the raw values.excluded
- value. This value will not be returned.public static <T> Generator<T> excludeValues(Generator<T> generator, T... excluded)
generator
- used to create the raw values.excluded
- values. These values will not be returned.public static <T> Generator<T> excludeValues(Collection<T> values, T... excluded)
values
- of generatorexcluded
- values. These values will not be returned.public static <T> Generator<T> excludeValues(Collection<T> values, Collection<T> excluded)
values
- of generatorexcluded
- values. These values will not be returned.public static <T> Generator<T> excludeValues(Generator<T> generator, Collection<T> excluded)
generator
- used to create the raw values.excluded
- values. These values will not be returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |