Skip to main content


net.java.quickcheck.generator
Class PrimitiveGenerators

java.lang.Object
  
extended by net.java.quickcheck.generator.PrimitiveGenerators
@Samples
@Iterables
public class PrimitiveGenerators
extends Object

PrimitiveGenerators contains 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
static int DEFAULT_STRING_MAX_LENGTH
           
 
Constructor Summary
PrimitiveGenerators()
           
 
Method Summary
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 from Byte.MIN_VALUE to Byte.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 given Distribution.
static Generator<Character> characters()
          Create a new character generator.
static Generator<Character> characters(Character... chars)
          Create a new character generator which generates characters from the given character array.
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(Collection<Character> chars)
          Create a new character generator which generates characters from the given character collection.
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(Date low, Date high)
          Create a generator for date values from low to high.
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
<T> ObjectGenerator<T>
defaultObjects(Class<T> objectType)
          Create a generator from a declarative object generator definition.
static Generator<Double> doubles()
          Create a new double generator which creates doubles ranging from Double.MIN_VALUE to Double.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 given Distribution.
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, Collection<T> excludedCollection)
          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(Collection<T> values)
          Create a fixed value generator returning one of the values from the values collection.
static
<T> Generator<T>
fixedValues(T... values)
          Create a fixed value generator returning one of the values from the values array.
static
<T> Generator<T>
fixedValues(T value)
          Create a generator for fixed value generator.
static Generator<Integer> integers()
          Create a new integer generator which creates integers ranging from Integer.MIN_VALUE to Integer.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 from lo to hi based on the given Distribution.
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 from Long.MIN_VALUE to Long.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 given Distribution.
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 for java.lang.Object instances.
static
<T> ObjectGenerator<T>
objects(Class<T> objectType)
          Create a generator from a declarative object generator definition.
static Generator<Integer> positiveIntegers()
          Create a new integer generator which creates positive integers.
static Generator<Integer> positiveIntegers(int high)
          Create a new integer generator which creates positive integers than are equal or smaller than high.
static Generator<Long> positiveLongs()
          Create a new long generator which creates long values ranging from 1 to Long.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 by basicLatinCharacters() and latin1SupplementCharacters().
static ExtendibleGenerator<Character,String> strings()
          Create a new string generator.
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(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(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(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 character
hi - 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 boundary
max - 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 by basicLatinCharacters() and latin1SupplementCharacters().


nonEmptyStrings

public static ExtendibleGenerator<Character,String> nonEmptyStrings()
Create a new string generator for strings that are not empty.


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(Collection<Character> chars)
Create a new character generator which generates characters from the given character collection.


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 from Integer.MIN_VALUE to Integer.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 from lo to hi based on the given Distribution.


positiveIntegers

public static Generator<Integer> positiveIntegers()
Create a new integer generator which creates positive integers.


positiveIntegers

public static Generator<Integer> positiveIntegers(int high)
Create a new integer generator which creates positive integers than are equal or smaller than high.


bytes

public static Generator<Byte> bytes()
Create a new byte generator which creates byte values ranging from Byte.MIN_VALUE to Byte.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 given Distribution.


longs

public static Generator<Long> longs()
Create a new long generator which creates longs ranging from Long.MIN_VALUE to Long.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 given Distribution.


positiveLongs

public static Generator<Long> positiveLongs()
Create a new long generator which creates long values ranging from 1 to Long.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 from Double.MIN_VALUE to Double.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 given Distribution.


booleans

public static Generator<Boolean> booleans()
Create a generator for boolean values.


nulls

public static <T> Generator<T> nulls()
Create a generator for null values.


dates

public static Generator<Date> dates()
Create a generator for date values.


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

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(Collection<T> values)
Create a fixed value generator returning one of the values from the values collection.


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

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 enumeration
excluded - excluded values of enumeration
Returns:
generator of enum values

enumValues

public static <T extends Enum<T>> Generator<T> enumValues(Class<T> enumClass,
                                                          Collection<T> excludedCollection)
Create a generator of enumeration values.

Type Parameters:
T - Type of enumerations
Parameters:
enumClass - class of enumeration
excludedCollection - excluded values of enumeration
Returns:
generator of enum values

objects

public static Generator<Object> objects()
Create a generator for java.lang.Object instances.

Note: every invocation of Generator.next() creates a new instance.


objects

public static <T> ObjectGenerator<T> objects(Class<T> objectType)
Create a generator from a declarative object generator definition.


defaultObjects

public static <T> ObjectGenerator<T> defaultObjects(Class<T> objectType)
Create a generator from a declarative object generator definition.
Default values will be used for all undefined methods.



Copyright © 2011. All Rights Reserved.
 
 
Close
loading
Please Confirm
Close