Class PrimitiveGenerators
- java.lang.Object
-
- de.cuioss.test.generator.internal.net.java.quickcheck.generator.PrimitiveGenerators
-
public class PrimitiveGenerators extends Object
PrimitiveGeneratorscontains factory methods for primitive value generators. These can be used to build custom test case generators.The default distribution for generators is
Distribution.UNIFORM.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_STRING_MAX_LENGTH
-
Constructor Summary
Constructors Constructor Description PrimitiveGenerators()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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>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 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 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>fixedValues(Iterable<T> values)Create a fixed value generator return 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 return values array.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 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 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 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 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 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 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.
-
-
-
Field Detail
-
DEFAULT_STRING_MAX_LENGTH
public static final int DEFAULT_STRING_MAX_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PrimitiveGenerators
public PrimitiveGenerators()
-
-
Method Detail
-
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 return values array.
-
fixedValues
public static <T> Generator<T> fixedValues(Iterable<T> values)
Create a fixed value generator return 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.
-
-