Class Generators
- java.lang.Object
-
- de.cuioss.test.generator.internal.net.java.quickcheck.generator.Generators
-
public class Generators extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_COLLECTION_MAX_SIZEstatic intDEFAULT_MAX_TRIESstatic intDEFAULT_STRING_MAX_LENGTH
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Generator<T[]>arrays(Generator<? extends T> content, Generator<Integer> size, Class<T> type)Create a generator of arrays with values from the content generator.static <T> Generator<T[]>arrays(Generator<? extends T> content, Class<T> type)Create a generator of arrays with values from the content generator.static Generator<Character>basicLatinCharacters()Create a new character generator which generates latin characters.static Generator<Boolean>booleans()Create a generator for boolean values.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 Generator<Byte>bytes()Create a new byte generator which creates byte values ranging fromByte.MIN_VALUEtoByte.MAX_VALUE.static Generator<Byte>bytes(byte lo, byte hi)Create a new byte generator which creates byte values ranging from lo to hi.static Generator<Byte>bytes(byte lo, byte hi, Distribution distribution)Create a new integer generator which creates integers ranging from lo to hi based on the givenDistribution.static <T> Generator<T>cast(Generator<? extends T> generator)Cast a generator to a super type generator.static Generator<Character>characters()Create a new character generator.
The characters are from the Basic Latin and Latin-1 Supplement unicode blocks.static Generator<Character>characters(char lo, char hi)Create a new character generator which generates characters ranging from lo to hi.static Generator<Character>characters(Character... chars)Create a new character generator which generates characters from the given character array.static Generator<Character>characters(Iterable<Character> chars)Create a new character generator which generates characters from the given characters.static Generator<Character>characters(String string)Create a new character generator which generates characters from the given string.static <T> Generator<T>clonedValues(T prototype)A cloning generator which uses object serialization to create clones of the prototype object.static Generator<Date>dates()Create a generator for date values.static Generator<Date>dates(long low, long high)Create a generator for date values from low to high.static Generator<Date>dates(Long low, Long high, TimeUnit precision)Create a generator for date values from low to high with the given precision.static Generator<Date>dates(TimeUnit precision)Create a generator for date values with the given precision.static Generator<Date>dates(Date low, Date high)Create a generator for date values from low to high.static <T> ObjectGenerator<T>defaultObjects(Class<T> objectType)Create a generator from adeclarative object generator definition.static Generator<Double>doubles()Create a new double generator which creates doubles ranging fromDouble.MIN_VALUEtoDouble.MAX_VALUE.static Generator<Double>doubles(double lo, double hi)Create a new double generator which creates doubles ranging from lo to hi.static Generator<Double>doubles(double lo, double hi, Distribution distribution)Create a new double generator which creates doubles ranging from lo to hi based on the givenDistribution.static <T> Generator<List<T>>duplicates(Iterable<T> input)Create a generator that produces lists of duplicates.static <T> Generator<List<T>>duplicates(T... input)Create a generator that produces lists of duplicates.static <T> StatefulGenerator<T>ensureValues(Iterable<T> ensuredValues)Create a deterministic generator which guarantees that all values from the ensuredValues collection will be returned if enough calls toGenerator.next()are issued (i.e.static <T> StatefulGenerator<T>ensureValues(Iterable<T> ensuredValues, int window, Generator<T> otherValues)Create a generator which guarantees that all values from the ensuredValues will be returned in a defined window when enough calls toGenerator.next()are issued.static <T> StatefulGenerator<T>ensureValues(Iterable<T> ensuredValues, Generator<T> otherValues)Create a deterministic generator which guarantees that all values from the ensuredValues collection will be returned if enough calls toGenerator.next()are issued (i.e.static <T> StatefulGenerator<T>ensureValues(T... content)Create a deterministic generator which guarantees that all values from the ensuredValues array will be returned if enough calls toGenerator.next()are issued (i.e.static <T extends Enum<T>>
Generator<T>enumValues(Class<T> enumClass)Create a generator of enumeration values.static <T extends Enum<T>>
Generator<T>enumValues(Class<T> enumClass, Iterable<T> excludedValues)Create a generator of enumeration values.static <T extends Enum<T>>
Generator<T>enumValues(Class<T> enumClass, T... excluded)Create a generator of enumeration values.static <T> Generator<T>excludeValues(Generator<T> generator, Iterable<T> excluded)Create a generator that omits a given set of values.static <T> Generator<T>excludeValues(Generator<T> generator, T excluded)Create a generator that omits a given value.static <T> Generator<T>excludeValues(Generator<T> generator, T... excluded)Create a generator that omits a given set of values.static <T> Generator<T>excludeValues(Iterable<T> values, Iterable<T> excluded)Create a generator that omits a given set of values.static <T> Generator<T>excludeValues(Iterable<T> values, T... excluded)Create a generator that omits a given set of values.static <T> Generator<T>fixedValues(Iterable<T> values)Create a fixed value generator returning one of the values from the values.static <T> Generator<T>fixedValues(T value)Create a generator for fixed value generator.static <T> Generator<T>fixedValues(T... values)Create a fixed value generator returning one of the values from the values array.static <T> FrequencyGenerator<T>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 Generator<Integer>integers()Create a new integer generator which creates integers ranging fromInteger.MIN_VALUEtoInteger.MAX_VALUE.static Generator<Integer>integers(int low)Create a new integer generator which creates integers that are at equal or greater than low.static Generator<Integer>integers(int lo, int hi)Create a new integer generator which creates integers ranging from lo to hi.static Generator<Integer>integers(int lo, int hi, Distribution distribution)Create a new integer generator which creates integers ranging fromlotohibased on the givenDistribution.static <T> Generator<Iterator<T>>iterators(Generator<? extends T> content)Create a generator of iterators.static <T> Generator<Iterator<T>>iterators(Generator<? extends T> content, Generator<Integer> size)Create a generator of iterators.static Generator<Character>latin1SupplementCharacters()Create a new character generator which generates latin-1 supplement characters.static ExtendibleGenerator<Character,String>letterStrings()Create a new string generator which creates strings of characters from a-z and A-Z.static ExtendibleGenerator<Character,String>letterStrings(int min, int max)Create a new string generator which creates strings with sizes ranging from loLengh to hiLength of characters from a-z and A-Z.static <T> Generator<List<T>>lists(Generator<? extends T> content)Create a generator of lists with values from the content generator.static <T> Generator<List<T>>lists(Generator<? extends T> content, int low)Create a generator of lists with values from the content generator.static <T> Generator<List<T>>lists(Generator<? extends T> content, int low, int high)Create a generator of lists with values from the content generator.static <T> Generator<List<T>>lists(Generator<? extends T> content, Generator<Integer> size)Create a generator of lists with values from the content generator.static Generator<Long>longs()Create a new long generator which creates longs ranging fromLong.MIN_VALUEtoLong.MAX_VALUE.static Generator<Long>longs(long lo, long hi)Create a new long generator which creates longs ranging from lo to hi.static Generator<Long>longs(long lo, long hi, Distribution distribution)Create a new long generator which creates longs ranging from lo to hi based on the givenDistribution.static <K,V>
Generator<Map<K,V>>maps(Generator<K> keys, Generator<V> values)Create a generator ofmaps.static <K,V>
Generator<Map<K,V>>maps(Generator<K> keys, Generator<V> values, Generator<Integer> size)Create a generator ofmaps.static <K,V>
Generator<Map<K,V>>maps(Map<K,V> supermap)Create a generator of maps from a given map.static <K,V>
Generator<Map<K,V>>maps(Map<K,V> supermap, Generator<Integer> sizes)Create a generator of maps from a given map.static <T> Generator<T[]>nonEmptyArrays(Generator<? extends T> content, Class<T> type)Create a generator of arrays that are not empty.static <T> Generator<Iterator<T>>nonEmptyIterators(Generator<T> content)Create a generator of iterators.static <T> Generator<List<T>>nonEmptyLists(Generator<? extends T> content)Create a generator of non-empty lists with values from the content generator.static <T> Generator<Set<T>>nonEmptySets(Generator<? extends T> content)Create a generator of sets that are not empty.static ExtendibleGenerator<Character,String>nonEmptyStrings()Create a new string generator for strings that are not empty.static <T> Generator<T>nulls()Create a generator for null values.static <T> Generator<T>nullsAnd(Generator<T> generator)Create a generator as a combination of a null value generator and generator of type T.static <T> Generator<T>nullsAnd(Generator<T> generator, int weight)Create a generator as a combination of a null value generator and generator of type T.static <T> Generator<T>nullsAnd(T... values)Create a generator returning a combination of a null values and the given values.static Generator<Object>objects()Create a generator forjava.lang.Objectinstances.static <T> ObjectGenerator<T>objects(Class<T> objectType)Create a generator from adeclarative object generator definition.static <T> ExtendibleGenerator<T,T>oneOf(Generator<T> generator)OneOf is a convenience method forfrequency(Generator, int)when all generator share the same weight.static <A,B>
Generator<Pair<A,B>>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 Generator<Integer>positiveIntegers()Create a new integer generator which creates integers ranging from1toInteger.MAX_VALUE.static Generator<Integer>positiveIntegers(int hi)Create a new integer generator which creates integers ranging from1tomax(which must be at least 1).static Generator<Long>positiveLongs()Create a new long generator which creates long values ranging from 1 toLong.MAX_VALUE.static Generator<Long>positiveLongs(long hi)Create a new long generator which creates long values ranging from 1 to hi.static ExtendibleGenerator<Character,String>printableStrings()Create a new string generator which creates strings of characters generated bybasicLatinCharacters()andlatin1SupplementCharacters().static <T> Generator<Set<T>>sets(Generator<? extends T> content)Create a generator of sets with values from the content generator.static <T> Generator<Set<T>>sets(Generator<? extends T> content, int low, int high)Create a generator of sets with values from the content generator.static <T> Generator<Set<T>>sets(Generator<? extends T> content, Generator<Integer> size)Create a generator of sets with values from the content generator.static <T> Generator<Set<T>>sets(Iterable<T> superset)Create a generator of subsets from a given set.static <T> Generator<Set<T>>sets(Iterable<T> superset, Generator<Integer> size)Create a generator of subsets from a given set.static <T> Generator<Set<T>>sets(T... superset)static <T extends Comparable<T>>
Generator<List<T>>sortedLists(Generator<T> content)Create a generator of sorted lists with values from the content generator.static <T extends Comparable<T>>
Generator<List<T>>sortedLists(Generator<T> content, int low, int high)Create a generator of sorted lists with values from the content generator.static <T extends Comparable<T>>
Generator<List<T>>sortedLists(Generator<T> content, Generator<Integer> size)Create a generator of sorted lists with values from the content generator.static <T extends Comparable<T>>
Generator<Pair<T,T>>sortedPairs(Generator<T> content)Create a generator of pairs where first value <= second value.static <T extends Comparable<T>>
Generator<Triple<T,T,T>>sortedTriple(Generator<T> content)Create a generator of triples where first value <= second value <= third value.static <T extends Comparable<T>>
Generator<List<T>>strictlyOrdered(Generator<T> input)A generator for a lists.static <T extends Comparable<T>>
Generator<List<T>>strictlyOrdered(Generator<T> input, int low, int high)A generator for a lists.static <T> Generator<List<T>>strictlyOrdered(Generator<T> input, Comparator<T> comparator)A generator for a lists.static <T> Generator<List<T>>strictlyOrdered(Generator<T> input, Comparator<T> comparator, Generator<Integer> size)A generator for a lists.static ExtendibleGenerator<Character,String>strings()Create a new string generator.
The characters are from the Basic Latin and Latin-1 Supplement unicode blocks.static ExtendibleGenerator<Character,String>strings(char lo, char hi)Create a new string generator which generates strings of characters ranging from lo to hi.static ExtendibleGenerator<Character,String>strings(int max)Creates a new String genearator which generates strings whose length ranges from zero to given length.static ExtendibleGenerator<Character,String>strings(int min, int max)Create a new string generator which generates strings of sizes ranging from loLength to hiLength.static ExtendibleGenerator<Character,String>strings(Generator<Character> characterGenerator)Create a new string generator which creates strings of characters generated by the given character generator.static ExtendibleGenerator<Character,String>strings(Generator<Integer> length, Generator<Character> characters)Create a new string generator which creates strings of characters generated by the given character generator with a length generated by the length generator.static ExtendibleGenerator<Character,String>strings(String allowedCharacters)Create a new string generator which generates strings of characters from the given string.static ExtendibleGenerator<Character,String>strings(String allowedCharacters, int min, int max)Create a new string generator which generates strings of characters from the given string with a length between min and max.static Generator<String>substrings(String base)Create a new string generator for substrings of a base string.static Generator<String>substrings(String base, int size)Create a new string generator for substrings of a base string.static Generator<String>substrings(String base, int minSize, int maxSize)Create a new string generator for substrings of a base string.static <T> Iterable<T>toIterable(Generator<T> generator)static <T> Iterable<T>toIterable(Generator<T> generator, int numberOfRuns)Convert a generator into aniterable.static <A,B,C>
Generator<Triple<A,B,C>>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 <T> StatefulGenerator<T>uniqueValues(Generator<T> generator)Create a generator that ensures unique valuesstatic <T> StatefulGenerator<T>uniqueValues(Generator<T> generator, int tries)Create a generator that ensures unique values.static <T> StatefulGenerator<T>uniqueValues(Generator<T> generator, Comparator<? super T> comparator)Create a generator that ensures unique values.static <T> StatefulGenerator<T>uniqueValues(Generator<T> generator, Comparator<? super T> comparator, int tries)Create a generator that ensures unique values.static <T> Generator<List<T>>vectors(Generator<T> content, int size)Create a generator which will create vectors (here lists) of type T.
-
-
-
Field Detail
-
DEFAULT_STRING_MAX_LENGTH
public static final int DEFAULT_STRING_MAX_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_COLLECTION_MAX_SIZE
public static final int DEFAULT_COLLECTION_MAX_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_MAX_TRIES
public static final int DEFAULT_MAX_TRIES
- See Also:
- Constant Field Values
-
-
Method Detail
-
cast
public static <T> Generator<T> cast(Generator<? extends T> generator)
Cast a generator to a super type generator.This method can be used to cast a generator of type Generator<A> to a generator of type Generator<B> given that A extends B. This operator is valid as all Generator instances are covariant (are pure producers).
-
toIterable
public static <T> Iterable<T> toIterable(Generator<T> generator)
-
toIterable
public static <T> Iterable<T> toIterable(Generator<T> generator, int numberOfRuns)
Convert a generator into aniterable.- Parameters:
numberOfRuns- to execute the runner
-
strings
public static ExtendibleGenerator<Character,String> strings()
Create a new string generator.
The characters are from the Basic Latin and Latin-1 Supplement unicode blocks.
-
strings
public static ExtendibleGenerator<Character,String> strings(char lo, char hi)
Create a new string generator which generates strings of characters ranging from lo to hi.- Parameters:
lo- lower boundary characterhi- upper boundary character
-
strings
public static ExtendibleGenerator<Character,String> strings(String allowedCharacters)
Create a new string generator which generates strings of characters from the given string.
-
strings
public static ExtendibleGenerator<Character,String> strings(String allowedCharacters, int min, int max)
Create a new string generator which generates strings of characters from the given string with a length between min and max.
-
strings
public static ExtendibleGenerator<Character,String> strings(int max)
Creates a new String genearator which generates strings whose length ranges from zero to given length.
-
strings
public static ExtendibleGenerator<Character,String> strings(int min, int max)
Create a new string generator which generates strings of sizes ranging from loLength to hiLength.- Parameters:
min- lower size boundarymax- upper size boundary
-
strings
public static ExtendibleGenerator<Character,String> strings(Generator<Integer> length, Generator<Character> characters)
Create a new string generator which creates strings of characters generated by the given character generator with a length generated by the length generator.
-
strings
public static ExtendibleGenerator<Character,String> strings(Generator<Character> characterGenerator)
Create a new string generator which creates strings of characters generated by the given character generator.
-
letterStrings
public static ExtendibleGenerator<Character,String> letterStrings()
Create a new string generator which creates strings of characters from a-z and A-Z.
-
letterStrings
public static ExtendibleGenerator<Character,String> letterStrings(int min, int max)
Create a new string generator which creates strings with sizes ranging from loLengh to hiLength of characters from a-z and A-Z.
-
printableStrings
public static ExtendibleGenerator<Character,String> printableStrings()
Create a new string generator which creates strings of characters generated bybasicLatinCharacters()andlatin1SupplementCharacters().
-
nonEmptyStrings
public static ExtendibleGenerator<Character,String> nonEmptyStrings()
Create a new string generator for strings that are not empty.
-
substrings
public static Generator<String> substrings(String base)
Create a new string generator for substrings of a base string.base.contains(generated string) will always be true.
-
substrings
public static Generator<String> substrings(String base, int size)
Create a new string generator for substrings of a base string.base.contains(generated string) will always be true.
- Parameters:
size- of the generated string
-
substrings
public static Generator<String> substrings(String base, int minSize, int maxSize)
Create a new string generator for substrings of a base string.base.contains(generated string) will always be true.
- Parameters:
minSize- is the minimum size of the generated stringmaxSize- is the maximum size of the generated string
-
characters
public static Generator<Character> characters(char lo, char hi)
Create a new character generator which generates characters ranging from lo to hi.
-
characters
public static Generator<Character> characters()
Create a new character generator.
The characters are from the Basic Latin and Latin-1 Supplement unicode blocks.
-
characters
public static Generator<Character> characters(Character... chars)
Create a new character generator which generates characters from the given character array.
-
characters
public static Generator<Character> characters(String string)
Create a new character generator which generates characters from the given string.
-
characters
public static Generator<Character> characters(Iterable<Character> chars)
Create a new character generator which generates characters from the given characters.
-
latin1SupplementCharacters
public static Generator<Character> latin1SupplementCharacters()
Create a new character generator which generates latin-1 supplement characters.
-
basicLatinCharacters
public static Generator<Character> basicLatinCharacters()
Create a new character generator which generates latin characters.
-
integers
public static Generator<Integer> integers()
Create a new integer generator which creates integers ranging fromInteger.MIN_VALUEtoInteger.MAX_VALUE.
-
integers
public static Generator<Integer> integers(int low)
Create a new integer generator which creates integers that are at equal or greater than low.
-
integers
public static Generator<Integer> integers(int lo, int hi)
Create a new integer generator which creates integers ranging from lo to hi.
-
integers
public static Generator<Integer> integers(int lo, int hi, Distribution distribution)
Create a new integer generator which creates integers ranging fromlotohibased on the givenDistribution.
-
positiveIntegers
public static Generator<Integer> positiveIntegers()
Create a new integer generator which creates integers ranging from1toInteger.MAX_VALUE.
-
positiveIntegers
public static Generator<Integer> positiveIntegers(int hi)
Create a new integer generator which creates integers ranging from1tomax(which must be at least 1).
-
bytes
public static Generator<Byte> bytes()
Create a new byte generator which creates byte values ranging fromByte.MIN_VALUEtoByte.MAX_VALUE.
-
bytes
public static Generator<Byte> bytes(byte lo, byte hi)
Create a new byte generator which creates byte values ranging from lo to hi.
-
bytes
public static Generator<Byte> bytes(byte lo, byte hi, Distribution distribution)
Create a new integer generator which creates integers ranging from lo to hi based on the givenDistribution.
-
longs
public static Generator<Long> longs()
Create a new long generator which creates longs ranging fromLong.MIN_VALUEtoLong.MAX_VALUE.
-
longs
public static Generator<Long> longs(long lo, long hi)
Create a new long generator which creates longs ranging from lo to hi.
-
longs
public static Generator<Long> longs(long lo, long hi, Distribution distribution)
Create a new long generator which creates longs ranging from lo to hi based on the givenDistribution.
-
positiveLongs
public static Generator<Long> positiveLongs()
Create a new long generator which creates long values ranging from 1 toLong.MAX_VALUE.
-
positiveLongs
public static Generator<Long> positiveLongs(long hi)
Create a new long generator which creates long values ranging from 1 to hi.
-
doubles
public static Generator<Double> doubles()
Create a new double generator which creates doubles ranging fromDouble.MIN_VALUEtoDouble.MAX_VALUE.
-
doubles
public static Generator<Double> doubles(double lo, double hi)
Create a new double generator which creates doubles ranging from lo to hi.
-
doubles
public static Generator<Double> doubles(double lo, double hi, Distribution distribution)
Create a new double generator which creates doubles ranging from lo to hi based on the givenDistribution.
-
dates
public static Generator<Date> dates(TimeUnit precision)
Create a generator for date values with the given precision.
-
dates
public static Generator<Date> dates(Date low, Date high)
Create a generator for date values from low to high.
-
dates
public static Generator<Date> dates(long low, long high)
Create a generator for date values from low to high.
-
dates
public static Generator<Date> dates(Long low, Long high, TimeUnit precision)
Create a generator for date values from low to high with the given precision.
-
fixedValues
public static <T> Generator<T> fixedValues(T value)
Create a generator for fixed value generator.
-
fixedValues
@SafeVarargs public static <T> Generator<T> fixedValues(T... values)
Create a fixed value generator returning one of the values from the values array.
-
fixedValues
public static <T> Generator<T> fixedValues(Iterable<T> values)
Create a fixed value generator returning one of the values from the values.
-
clonedValues
public static <T> Generator<T> clonedValues(T prototype)
A cloning generator which uses object serialization to create clones of the prototype object. For each call a new copy of the prototype will be generated.
-
enumValues
public static <T extends Enum<T>> Generator<T> enumValues(Class<T> enumClass)
Create a generator of enumeration values.- Type Parameters:
T- Type of enumerations- Parameters:
enumClass- class of enumeration- Returns:
- generator of enum values
-
enumValues
@SafeVarargs public static <T extends Enum<T>> Generator<T> enumValues(Class<T> enumClass, T... excluded)
Create a generator of enumeration values.- Type Parameters:
T- Type of enumerations- Parameters:
enumClass- class of enumerationexcluded- excluded values of enumeration- Returns:
- generator of enum values
-
enumValues
public static <T extends Enum<T>> Generator<T> enumValues(Class<T> enumClass, Iterable<T> excludedValues)
Create a generator of enumeration values.- Type Parameters:
T- Type of enumerations- Parameters:
enumClass- class of enumerationexcludedValues- excluded values of enumeration- Returns:
- generator of enum values
-
objects
public static Generator<Object> objects()
Create a generator forjava.lang.Objectinstances.Note: every invocation of
Generator.next()creates a new instance.
-
objects
public static <T> ObjectGenerator<T> objects(Class<T> objectType)
Create a generator from adeclarative object generator definition.
-
defaultObjects
public static <T> ObjectGenerator<T> defaultObjects(Class<T> objectType)
Create a generator from adeclarative object generator definition.Default values will be used for all
undefined methods.
-
frequency
public static <T> FrequencyGenerator<T> frequency(Generator<T> generator, int weight)
Create a frequency generator. The frequency of
Generatorusage depends on the generator weight.- Type Parameters:
T- type of values generated by the generators.- Parameters:
generator- pairs of generators and their weights used to created the values
-
oneOf
public static <T> ExtendibleGenerator<T,T> oneOf(Generator<T> generator)
OneOf is a convenience method forfrequency(Generator, int)when all generator share the same weight.
-
vectors
public static <T> Generator<List<T>> vectors(Generator<T> content, int size)
Create a generator which will create vectors (here lists) of type T.- Type Parameters:
T- Type of the list values.- Parameters:
size- Number of element in the vector.
-
pairs
public static <A,B> Generator<Pair<A,B>> 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.- Type Parameters:
A- Type of left value.B- Type of right value.- Parameters:
first- Generator for left values.second- Generator for right values.
-
sortedPairs
public static <T extends Comparable<T>> Generator<Pair<T,T>> sortedPairs(Generator<T> content)
Create a generator of pairs where first value <= second value.- Type Parameters:
T- Type of the pair values.- Parameters:
content- Generator for content of the pair values.
-
triples
public static <A,B,C> Generator<Triple<A,B,C>> 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.- Type Parameters:
A- Type of first value.B- Type of second value.C- Type of third value.- Parameters:
first- Generator for first values.second- Generator for second values.third- Generator for third values.
-
nullsAnd
@SafeVarargs public static <T> Generator<T> nullsAnd(T... values)
Create a generator returning a combination of a null values and the given values.- Type Parameters:
T- Type of the values generated.
-
sortedTriple
public static <T extends Comparable<T>> Generator<Triple<T,T,T>> sortedTriple(Generator<T> content)
Create a generator of triples where first value <= second value <= third value.- Type Parameters:
T- Type of the triple values.- Parameters:
content- Generator for content of the triple values.
-
nullsAnd
public static <T> Generator<T> nullsAnd(Generator<T> generator)
Create a generator as a combination of a null value generator and generator of type T.- Type Parameters:
T- Type of the values generated.
-
nullsAnd
public static <T> Generator<T> nullsAnd(Generator<T> generator, int weight)
Create a generator as a combination of a null value generator and generator of type T.- Type Parameters:
T- Type of the values generated.- Parameters:
weight- weight of the provided generator
-
sets
public static <T> Generator<Set<T>> sets(Generator<? extends T> content)
Create a generator of sets with values from the content generator.- Type Parameters:
T- type of set elements generated- Parameters:
content- generator providing the content of sets generated
-
sets
public static <T> Generator<Set<T>> sets(Generator<? extends T> content, Generator<Integer> size)
Create a generator of sets with values from the content generator.- Type Parameters:
T- type of set elements generated- Parameters:
content- generator providing the content of sets generatedsize- size of the sets generated
-
sets
public static <T> Generator<Set<T>> sets(Generator<? extends T> content, int low, int high)
Create a generator of sets with values from the content generator. Length is between high and low.- Type Parameters:
T- type of set elements generated- Parameters:
content- generator providing the content of sets generatedlow- minimal sizehigh- max size
-
nonEmptySets
public static <T> Generator<Set<T>> nonEmptySets(Generator<? extends T> content)
Create a generator of sets that are not empty.- Type Parameters:
T- type of set elements generated- Parameters:
content- generator providing the content of sets generated
-
sets
@SafeVarargs public static <T> Generator<Set<T>> sets(T... superset)
-
sets
public static <T> Generator<Set<T>> sets(Iterable<T> superset)
Create a generator of subsets from a given set.- Type Parameters:
T- type of set elements generated- Parameters:
superset- of the generated set
-
sets
public static <T> Generator<Set<T>> sets(Iterable<T> superset, Generator<Integer> size)
Create a generator of subsets from a given set.- Type Parameters:
T- type of set elements generated- Parameters:
superset- of the generated setsize- of the generated set
-
duplicates
@SafeVarargs public static <T> Generator<List<T>> duplicates(T... input)
Create a generator that produces lists of duplicates.- Returns:
- a list derived from the input values. At least one input value is more than once in the resulting list.
-
duplicates
public static <T> Generator<List<T>> duplicates(Iterable<T> input)
Create a generator that produces lists of duplicates.- Returns:
- a list derived from the input values. At least one input value is more than once in the resulting list.
-
iterators
public static <T> Generator<Iterator<T>> iterators(Generator<? extends T> content)
Create a generator of iterators.Values of the elements will be taken from the content generator.
- Type Parameters:
T- type of iterator elements generated- Parameters:
content- generator providing the content of iterators generated
-
nonEmptyIterators
public static <T> Generator<Iterator<T>> nonEmptyIterators(Generator<T> content)
Create a generator of iterators.Values of the elements will be taken from the content generator. The generated iterator will have at least one element.
- Type Parameters:
T- type of iterator elements generated- Parameters:
content- generator providing the content of iterators generated
-
iterators
public static <T> Generator<Iterator<T>> iterators(Generator<? extends T> content, Generator<Integer> size)
Create a generator of iterators.Values of the elements will be taken from the content generator. The length of the iterators will be determined with the size generator.
- Type Parameters:
T- type of iterator elements generated- Parameters:
content- generator providing the content of iterators generatedsize- used to determine the number of elements of the iterator
-
lists
public static <T> Generator<List<T>> lists(Generator<? extends T> content)
Create a generator of lists with values from the content generator. Length values of lists generated will be created withDistribution.UNIFORM.- Type Parameters:
T- type of list elements generated- Parameters:
content- generator providing the content of lists generated
-
nonEmptyLists
public static <T> Generator<List<T>> nonEmptyLists(Generator<? extends T> content)
Create a generator of non-empty lists with values from the content generator. Length values of lists generated will be created withDistribution.UNIFORM.- Type Parameters:
T- type of list elements generated- Parameters:
content- generator providing the content of lists generated
-
lists
public static <T> Generator<List<T>> lists(Generator<? extends T> content, Generator<Integer> size)
Create a generator of lists with values from the content generator. Length values of lists generated will be created with size generator.- Type Parameters:
T- type of list elements generated- Parameters:
content- generator providing the content of lists generatedsize- integer used to determine the list size
-
lists
public static <T> Generator<List<T>> lists(Generator<? extends T> content, int low, int high)
Create a generator of lists with values from the content generator. Length is between high and low.- Type Parameters:
T- type of list elements generated- Parameters:
content- generator providing the content of lists generatedlow- minimal sizehigh- max size
-
lists
public static <T> Generator<List<T>> lists(Generator<? extends T> content, int low)
Create a generator of lists with values from the content generator. Length is at least low.- Type Parameters:
T- type of list elements generated- Parameters:
content- generator providing the content of lists generatedlow- minimal size. If low is larger thanDEFAULT_COLLECTION_MAX_SIZEthen it is the upper size bound as well.
-
sortedLists
public static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content)
Create a generator of sorted lists with values from the content generator.- Type Parameters:
T- type of list elements generated- Parameters:
content- generator providing the content of lists generated
-
sortedLists
public static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content, int low, int high)
Create a generator of sorted lists with values from the content generator. Length is between high and low.- Type Parameters:
T- type of list elements generated- Parameters:
content- generator providing the content of lists generatedlow- minimal sizehigh- max size
-
sortedLists
public static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content, Generator<Integer> size)
Create a generator of sorted lists with values from the content generator. Length is between high and low.- Type Parameters:
T- type of list elements generated- Parameters:
content- generator providing the content of lists generatedsize- integer used to determine the list size
-
arrays
public static <T> Generator<T[]> arrays(Generator<? extends T> content, Class<T> type)
Create a generator of arrays with values from the content generator. Length values of array generated will be created withDistribution.UNIFORM.- Type Parameters:
T- type of arrays elements generated- Parameters:
content- generator providing the content of arrays generatedtype- type of arrays generated
-
nonEmptyArrays
public static <T> Generator<T[]> nonEmptyArrays(Generator<? extends T> content, Class<T> type)
Create a generator of arrays that are not empty.- Type Parameters:
T- type of arrays elements generated- Parameters:
content- generator providing the content of arrays generatedtype- type of arrays generated
-
arrays
public static <T> Generator<T[]> arrays(Generator<? extends T> content, Generator<Integer> size, Class<T> type)
Create a generator of arrays with values from the content generator. Length values of arrays generated will be created with size generator.- Type Parameters:
T- type of arrays elements generated- Parameters:
content- generator providing the content of arrays generatedsize- integer used to determine the array sizetype- type of arrays generated
-
byteArrays
public static Generator<byte[]> byteArrays()
Create a generator of byte arrays. The length of arrays generated will be determined by theByteArrayGenerator.MIN_SIZEandByteArrayGenerator.MAX_SIZEconstants.
-
byteArrays
public static Generator<byte[]> byteArrays(Generator<Integer> size)
Create a generator of byte arrays. Length values of arrays generated will be created with size generator.- Parameters:
size- integer used to determine the array size
-
byteArrays
public static Generator<byte[]> byteArrays(Generator<Byte> content, Generator<Integer> size)
Create a generator of byte arrays. Length values of arrays generated will be created with size generator.- Parameters:
size- integer used to determine the array sizecontent- generator for the byte array content
-
intArrays
public static Generator<int[]> intArrays(Generator<Integer> size)
Create a generator of integer arrays. Length values of arrays generated will be created with size generator.- Parameters:
size- integer used to determine the array size
-
intArrays
public static Generator<int[]> intArrays(Generator<Integer> content, Generator<Integer> size)
Create a generator of integer arrays. Length values of arrays generated will be created with size generator.- Parameters:
size- integer used to determine the array sizecontent- generator for the integer array content
-
maps
public static <K,V> Generator<Map<K,V>> maps(Generator<K> keys, Generator<V> values)
Create a generator ofmaps.This is a generator for simple maps where the values are not related to the keys.
-
maps
public static <K,V> Generator<Map<K,V>> maps(Generator<K> keys, Generator<V> values, Generator<Integer> size)
Create a generator ofmaps.This is a generator for simple maps where the values are not related to the keys.
-
maps
public static <K,V> Generator<Map<K,V>> maps(Map<K,V> supermap)
Create a generator of maps from a given map.The entry set of the generated maps are subsets of the given map's entry set.
- Parameters:
supermap- of the generated maps
-
maps
public static <K,V> Generator<Map<K,V>> maps(Map<K,V> supermap, Generator<Integer> sizes)
Create a generator of maps from a given map.The entry set of the generated maps are subsets of the given map's entry set.
- Parameters:
supermap- of the generated mapssizes- of the generated maps
-
ensureValues
public static <T> StatefulGenerator<T> ensureValues(Iterable<T> ensuredValues)
Create a deterministic generator which guarantees that all values from the ensuredValues collection will be returned if enough calls toGenerator.next()are issued (i.e. ensuredValues.size() <= # of runs). The order of values is undefined.- Type Parameters:
T- type of values return by the generator
-
ensureValues
@SafeVarargs public static <T> StatefulGenerator<T> ensureValues(T... content)
Create a deterministic generator which guarantees that all values from the ensuredValues array will be returned if enough calls toGenerator.next()are issued (i.e. ensuredValues.size() <= # of runs). The order of values is undefined.- Type Parameters:
T- type of values return by the generator
-
ensureValues
public static <T> StatefulGenerator<T> ensureValues(Iterable<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.- Type Parameters:
T- type of values return by the generator
-
ensureValues
public static <T> StatefulGenerator<T> ensureValues(Iterable<T> ensuredValues, int window, Generator<T> otherValues)
Create a generator which guarantees that all values from the ensuredValues will be returned in a defined window when enough calls to
Generator.next()are issued.The order of values is undefined. All other values in the window and after the window are taken from the
generator otherValues.- Type Parameters:
T- type of values return by the generator- Parameters:
window- After window number of calls toGenerator.next()it is guaranteed that all ensured values were returned.
-
uniqueValues
public 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.
- Type Parameters:
T- type of values return by the generator- Parameters:
generator- 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 aGeneratorException.- Returns:
- unique generator instance
-
uniqueValues
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
Comparatorimplementation to decide if two instances are the same (i.e. when the comparator returns 0 forComparator.compare(Object, Object)).- Type Parameters:
T- type of values returned by the generator- Parameters:
generator- 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 aGeneratorException.- Returns:
- unique generator instance
-
uniqueValues
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
Comparatorimplementation to decide if two instances are the same (i.e. when the comparator returns 0 forComparator.compare(Object, Object)).- Type Parameters:
T- type of values returned by the generator- Parameters:
generator- used to create the raw values. This generator can create duplicate valuescomparator- that decides if two values are of the same equivalence class.- Returns:
- unique generator instance
-
uniqueValues
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.
- Type Parameters:
T- type of values return by the generator- Parameters:
generator- used to create the raw values. This generator can create duplicate values- Returns:
- unique generator instance
-
excludeValues
public static <T> Generator<T> excludeValues(Generator<T> generator, T excluded)
Create a generator that omits a given value.- Parameters:
generator- used to create the raw values.excluded- value. This value will not be returned.
-
excludeValues
@SafeVarargs public static <T> Generator<T> excludeValues(Generator<T> generator, T... excluded)
Create a generator that omits a given set of values.- Parameters:
generator- used to create the raw values.excluded- values. These values will not be returned.
-
excludeValues
@SafeVarargs public static <T> Generator<T> excludeValues(Iterable<T> values, T... excluded)
Create a generator that omits a given set of values.- Parameters:
values- of generatorexcluded- values. These values will not be returned.
-
excludeValues
public static <T> Generator<T> excludeValues(Iterable<T> values, Iterable<T> excluded)
Create a generator that omits a given set of values.- Parameters:
values- of generatorexcluded- values. These values will not be returned.
-
excludeValues
public static <T> Generator<T> excludeValues(Generator<T> generator, Iterable<T> excluded)
Create a generator that omits a given set of values.- Parameters:
generator- used to create the raw values.excluded- values. These values will not be returned.
-
strictlyOrdered
public static <T extends Comparable<T>> Generator<List<T>> strictlyOrdered(Generator<T> input)
A generator for a lists. The values in the lists are strictly increasing.For every element x in the list: x(n) < x(n+1).
- Parameters:
input- values generator
-
strictlyOrdered
public static <T extends Comparable<T>> Generator<List<T>> strictlyOrdered(Generator<T> input, int low, int high)
A generator for a lists. The values in the lists are strictly increasing.For every element x in the list: x(n) < x(n+1).
- Parameters:
input- values generatorlow- minimum size of the listshigh- maximum size of the lists
-
strictlyOrdered
public static <T> Generator<List<T>> strictlyOrdered(Generator<T> input, Comparator<T> comparator)
A generator for a lists. The values in the lists are strictly increasing.For every element x in the list: x(n) < x(n+1).
This
Generatorcan be used to generate a list of strictly decreasing values:Generators.strictlyOrdered(ts, Collections.<T> reverseOrder());- Parameters:
input- values generatorcomparator- that orders the values
-
strictlyOrdered
public static <T> Generator<List<T>> strictlyOrdered(Generator<T> input, Comparator<T> comparator, Generator<Integer> size)
A generator for a lists. The values in the lists are strictly increasing.For every element x in the list: x(n) < x(n+1).
- Parameters:
input- values generatorcomparator- that orders the valuessize- of the resulting lists
-
-