Package de.cuioss.test.generator
Class Generators
- java.lang.Object
-
- de.cuioss.test.generator.Generators
-
public final class Generators extends Object
Provides a number ofTypedGeneratorfor arbitrary java-types- Author:
- Oliver Wolff
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> CollectionGenerator<T>asCollectionGenerator(TypedGenerator<T> source)Factory method for creating aCollectionGeneratorgeneratingCollections from the givenTypedGenerator.static TypedGenerator<Boolean>booleanObjects()Factory method for creating aTypedGeneratorforBoolean.static TypedGenerator<Boolean>booleans()Factory method for creating aTypedGeneratorfor boolean primitives.static TypedGenerator<Byte>byteObjects()Factory method for creating aTypedGeneratorforByte.static TypedGenerator<Byte>bytes()Factory method for creating aTypedGeneratorfor byte primitives.static TypedGenerator<Character>characterObjects()Factory method for creating aTypedGeneratorforCharacter.static TypedGenerator<Character>characters()Factory method for creating aTypedGeneratorfor char primitives.static TypedGenerator<Class>classTypes()Factory method for creating aTypedGeneratorarbitraryClassObjectsstatic TypedGenerator<Date>dates()Factory method for creating aTypedGeneratorforDate.static TypedGenerator<Double>doubleObjects()Factory method for creating aTypedGeneratorforDouble.static TypedGenerator<Double>doubles()Factory method for creating aTypedGeneratorfor double primitives.static TypedGenerator<Double>doubles(double low, double high)Factory method for creating aTypedGeneratorforDouble.static <T extends Enum<T>>
TypedGenerator<T>enumValues(Class<T> type)Factory method for creating a generator for a given enum.static <T> Optional<TypedGenerator<T>>enumValuesIfAvailable(Class<T> type)Factory method for creating a generator for a possible given enum.static <T> TypedGenerator<T>fixedValues(Class<T> type, Iterable<T> values)Factory method for creating aTypedGeneratorfor a number of fixed values.static <T> TypedGenerator<T>fixedValues(Class<T> type, T... values)Factory method for creating aTypedGeneratorfor a number of fixed values.static <T> TypedGenerator<T>fixedValues(Iterable<T> values)Factory method for creating aTypedGeneratorfor a number of fixed values.static <T> TypedGenerator<T>fixedValues(T... values)Factory method for creating aTypedGeneratorfor a number of fixed values.static TypedGenerator<Float>floatObjects()Factory method for creating aTypedGeneratorforFloat.static TypedGenerator<Float>floats()Factory method for creating aTypedGeneratorfor float primitives.static TypedGenerator<Float>floats(float low, float high)Factory method for creating aTypedGeneratorforFloat.static TypedGenerator<Integer>integerObjects()Factory method for creating aTypedGeneratorforInteger.static TypedGenerator<Integer>integers()Factory method for creating aTypedGeneratorfor integer primitives.static TypedGenerator<Integer>integers(int low, int high)Factory method for creating aTypedGeneratorforInteger.static TypedGenerator<String>letterStrings()Factory method for creating aTypedGeneratorfor sensible / simple non empty letter Strings.static TypedGenerator<String>letterStrings(int minSize, int maxSize)Factory method for creating aTypedGeneratorfor letter Strings.static TypedGenerator<LocalDate>localDates()Factory method for creating aTypedGeneratorforLocalDate.static TypedGenerator<LocalDateTime>localDateTimes()Factory method for creating aTypedGeneratorforLocalDateTime.static TypedGenerator<Locale>locales()Factory method for creating aTypedGeneratorarbitraryLocaleObjectsstatic TypedGenerator<LocalTime>localTimes()Factory method for creating aTypedGeneratorforLocalTime.static TypedGenerator<Long>longObjects()Factory method for creating aTypedGeneratorforLong.static TypedGenerator<Long>longs()Factory method for creating aTypedGeneratorfor long primitives.static TypedGenerator<Long>longs(long low, long high)Factory method for creating aTypedGeneratorfor Long primitives.static TypedGenerator<String>nonBlankStrings()Factory method for creating aTypedGeneratorfor non-blank Strings.static TypedGenerator<String>nonEmptyStrings()Factory method for creating aTypedGeneratorfor non-empty Strings.static TypedGenerator<Number>numbers()Factory method for creating aTypedGeneratorforNumber.static TypedGenerator<RuntimeException>runtimeExceptions()Factory method for creating aTypedGeneratorarbitraryRuntimeExceptionObjectsstatic TypedGenerator<Serializable>serializables()Factory method for creating aTypedGeneratorarbitrarySerializableObjectsstatic TypedGenerator<Short>shortObjects()Factory method for creating aTypedGeneratorforShort.static TypedGenerator<Short>shorts()Factory method for creating aTypedGeneratorfor short primitives.static TypedGenerator<String>strings()Factory method for creating aTypedGeneratorfor any Strings, may be null or empty.static TypedGenerator<String>strings(int minSize, int maxSize)Factory method for creating aTypedGeneratorfor Strings.static TypedGenerator<String>strings(String chars, int minSize, int maxSize)Factory method for creating strings with given characters and size.static TypedGenerator<Temporal>temporals()Factory method for creating aTypedGeneratorforTemporals.static TypedGenerator<Throwable>throwables()Factory method for creating aTypedGeneratorarbitraryThrowableObjectsstatic TypedGenerator<TimeZone>timeZones()Factory method for creating aTypedGeneratorforTimeZone.static <T> TypedGenerator<T>uniqueValues(TypedGenerator<T> source)Factory method for creating aTypedGeneratorgenerating unique values.static TypedGenerator<URL>urls()Factory method for creating aTypedGeneratorarbitraryURLs Objectsstatic TypedGenerator<ZonedDateTime>zonedDateTimes()Factory method for creating aTypedGeneratorforZonedDateTime.static TypedGenerator<ZoneId>zoneIds()Factory method for creating aTypedGeneratorforZoneId.static TypedGenerator<ZoneOffset>zoneOffsets()Factory method for creating aTypedGeneratorforZoneOffset.
-
-
-
Method Detail
-
enumValuesIfAvailable
public static <T> Optional<TypedGenerator<T>> enumValuesIfAvailable(Class<T> type)
Factory method for creating a generator for a possible given enum.- Parameters:
type- to be checked must represent an enum- Returns:
- an
Optionalon the correspondingTypedGeneratorif the given type is an enum can be found,Optional.empty()otherwise
-
enumValues
public static <T extends Enum<T>> TypedGenerator<T> enumValues(Class<T> type)
Factory method for creating a generator for a given enum.- Parameters:
type- to be checked must represent an enum- Returns:
- A
TypedGeneratorfor the given enmu
-
nonEmptyStrings
public static TypedGenerator<String> nonEmptyStrings()
Factory method for creating aTypedGeneratorfor non-empty Strings.- Returns:
- a
TypedGeneratorfor non-empty Strings
-
nonBlankStrings
public static TypedGenerator<String> nonBlankStrings()
Factory method for creating aTypedGeneratorfor non-blank Strings.- Returns:
- a
TypedGeneratorfor non-blank Strings.
-
strings
public static TypedGenerator<String> strings(int minSize, int maxSize)
Factory method for creating aTypedGeneratorfor Strings.- Parameters:
minSize- lower bound of sizemaxSize- upper bound of size- Returns:
- a
TypedGeneratorfor Strings
-
strings
public static TypedGenerator<String> strings(String chars, int minSize, int maxSize)
Factory method for creating strings with given characters and size.- Parameters:
chars- to be generatedminSize- lower bound of sizemaxSize- upper bound of size- Returns:
- a
TypedGeneratorfor Strings
-
strings
public static TypedGenerator<String> strings()
Factory method for creating aTypedGeneratorfor any Strings, may be null or empty.- Returns:
- a
TypedGeneratorfor Strings
-
letterStrings
public static TypedGenerator<String> letterStrings(int minSize, int maxSize)
Factory method for creating aTypedGeneratorfor letter Strings.- Parameters:
minSize- lower bound of sizemaxSize- upper bound of size- Returns:
- a
TypedGeneratorfor Strings
-
letterStrings
public static TypedGenerator<String> letterStrings()
Factory method for creating aTypedGeneratorfor sensible / simple non empty letter Strings. The mininmal size is 3, the maximal size between 3 and 256 characters- Returns:
- a
TypedGeneratorfor Strings
-
fixedValues
@SafeVarargs public static <T> TypedGenerator<T> fixedValues(Class<T> type, T... values)
Factory method for creating aTypedGeneratorfor a number of fixed values.- Parameters:
type- of the valuevalues- to be generated from.- Returns:
- a
TypedGeneratorfor the given values
-
fixedValues
@SafeVarargs public static <T> TypedGenerator<T> fixedValues(T... values)
Factory method for creating aTypedGeneratorfor a number of fixed values.- Parameters:
values- to be generated from.- Returns:
- a
TypedGeneratorfor the given values
-
fixedValues
public static <T> TypedGenerator<T> fixedValues(Class<T> type, Iterable<T> values)
Factory method for creating aTypedGeneratorfor a number of fixed values.- Parameters:
type- of the valuevalues- to be generated from.- Returns:
- a
TypedGeneratorfor the given values
-
fixedValues
public static <T> TypedGenerator<T> fixedValues(Iterable<T> values)
Factory method for creating aTypedGeneratorfor a number of fixed values.- Parameters:
values- to be generated from.- Returns:
- a
TypedGeneratorfor the given values
-
uniqueValues
public static <T> TypedGenerator<T> uniqueValues(TypedGenerator<T> source)
Factory method for creating aTypedGeneratorgenerating unique values. In case this does not work it will throw anRuntimeException- Parameters:
source- to be generated from.- Returns:
- a
TypedGeneratorfor the given values
-
asCollectionGenerator
public static <T> CollectionGenerator<T> asCollectionGenerator(TypedGenerator<T> source)
Factory method for creating aCollectionGeneratorgeneratingCollections from the givenTypedGenerator.- Parameters:
source- to be generated from.- Returns:
- a
TypedGeneratorfor the given values
-
booleans
public static TypedGenerator<Boolean> booleans()
Factory method for creating aTypedGeneratorfor boolean primitives.- Returns:
- a
TypedGeneratorfor boolean primitives
-
booleanObjects
public static TypedGenerator<Boolean> booleanObjects()
Factory method for creating aTypedGeneratorforBoolean.- Returns:
- a
TypedGeneratorforBoolean
-
bytes
public static TypedGenerator<Byte> bytes()
Factory method for creating aTypedGeneratorfor byte primitives.- Returns:
- a
TypedGeneratorfor byte primitives
-
byteObjects
public static TypedGenerator<Byte> byteObjects()
Factory method for creating aTypedGeneratorforByte.- Returns:
- a
TypedGeneratorforByte
-
characters
public static TypedGenerator<Character> characters()
Factory method for creating aTypedGeneratorfor char primitives.- Returns:
- a
TypedGeneratorfor char primitives
-
characterObjects
public static TypedGenerator<Character> characterObjects()
Factory method for creating aTypedGeneratorforCharacter.- Returns:
- a
TypedGeneratorforCharacter
-
doubles
public static TypedGenerator<Double> doubles()
Factory method for creating aTypedGeneratorfor double primitives.- Returns:
- a
TypedGeneratorfor double primitives
-
doubles
public static TypedGenerator<Double> doubles(double low, double high)
Factory method for creating aTypedGeneratorforDouble.- Parameters:
low- lower bound of rangehigh- upper bound of range- Returns:
- a
TypedGeneratorforDouble
-
doubleObjects
public static TypedGenerator<Double> doubleObjects()
Factory method for creating aTypedGeneratorforDouble.- Returns:
- a
TypedGeneratorforDouble
-
floats
public static TypedGenerator<Float> floats()
Factory method for creating aTypedGeneratorfor float primitives.- Returns:
- a
TypedGeneratorfor float primitives
-
floats
public static TypedGenerator<Float> floats(float low, float high)
Factory method for creating aTypedGeneratorforFloat.- Parameters:
low- lower bound of rangehigh- upper bound of range- Returns:
- a
TypedGeneratorforFloat
-
floatObjects
public static TypedGenerator<Float> floatObjects()
Factory method for creating aTypedGeneratorforFloat.- Returns:
- a
TypedGeneratorforFloat
-
integers
public static TypedGenerator<Integer> integers()
Factory method for creating aTypedGeneratorfor integer primitives.- Returns:
- a
TypedGeneratorfor integer primitives
-
integers
public static TypedGenerator<Integer> integers(int low, int high)
Factory method for creating aTypedGeneratorforInteger.- Parameters:
low- lower bound of rangehigh- upper bound of range- Returns:
- a
TypedGeneratorforInteger
-
integerObjects
public static TypedGenerator<Integer> integerObjects()
Factory method for creating aTypedGeneratorforInteger.- Returns:
- a
TypedGeneratorforInteger
-
numbers
public static TypedGenerator<Number> numbers()
Factory method for creating aTypedGeneratorforNumber.- Returns:
- a
TypedGeneratorforNumber
-
shorts
public static TypedGenerator<Short> shorts()
Factory method for creating aTypedGeneratorfor short primitives.- Returns:
- a
TypedGeneratorfor short primitives
-
shortObjects
public static TypedGenerator<Short> shortObjects()
Factory method for creating aTypedGeneratorforShort.- Returns:
- a
TypedGeneratorforShort
-
longs
public static TypedGenerator<Long> longs()
Factory method for creating aTypedGeneratorfor long primitives.- Returns:
- a
TypedGeneratorfor long primitives
-
longs
public static TypedGenerator<Long> longs(long low, long high)
Factory method for creating aTypedGeneratorfor Long primitives.- Parameters:
low- lower bound of rangehigh- upper bound of range- Returns:
- a
TypedGeneratorfor long primitives
-
longObjects
public static TypedGenerator<Long> longObjects()
Factory method for creating aTypedGeneratorforLong.- Returns:
- a
TypedGeneratorforLong
-
dates
public static TypedGenerator<Date> dates()
Factory method for creating aTypedGeneratorforDate.- Returns:
- a
TypedGeneratorforDate
-
localDates
public static TypedGenerator<LocalDate> localDates()
Factory method for creating aTypedGeneratorforLocalDate.- Returns:
- a
TypedGeneratorforLocalDate
-
localTimes
public static TypedGenerator<LocalTime> localTimes()
Factory method for creating aTypedGeneratorforLocalTime.- Returns:
- a
TypedGeneratorforLocalTime
-
localDateTimes
public static TypedGenerator<LocalDateTime> localDateTimes()
Factory method for creating aTypedGeneratorforLocalDateTime.- Returns:
- a
TypedGeneratorforLocalDateTime
-
zonedDateTimes
public static TypedGenerator<ZonedDateTime> zonedDateTimes()
Factory method for creating aTypedGeneratorforZonedDateTime.- Returns:
- a
TypedGeneratorforZonedDateTime
-
timeZones
public static TypedGenerator<TimeZone> timeZones()
Factory method for creating aTypedGeneratorforTimeZone.- Returns:
- a
TypedGeneratorforTimeZone
-
zoneIds
public static TypedGenerator<ZoneId> zoneIds()
Factory method for creating aTypedGeneratorforZoneId.- Returns:
- a
TypedGeneratorforZoneId
-
zoneOffsets
public static TypedGenerator<ZoneOffset> zoneOffsets()
Factory method for creating aTypedGeneratorforZoneOffset.- Returns:
- a
TypedGeneratorforZoneOffset
-
temporals
public static TypedGenerator<Temporal> temporals()
Factory method for creating aTypedGeneratorforTemporals.- Returns:
- a
TypedGeneratorforTemporals
-
classTypes
public static TypedGenerator<Class> classTypes()
Factory method for creating aTypedGeneratorarbitraryClassObjects- Returns:
- a
TypedGeneratorfor the given values
-
locales
public static TypedGenerator<Locale> locales()
Factory method for creating aTypedGeneratorarbitraryLocaleObjects- Returns:
- a
TypedGeneratorfor allLocales
-
serializables
public static TypedGenerator<Serializable> serializables()
Factory method for creating aTypedGeneratorarbitrarySerializableObjects- Returns:
- a
TypedGeneratorfor allSerializables
-
runtimeExceptions
public static TypedGenerator<RuntimeException> runtimeExceptions()
Factory method for creating aTypedGeneratorarbitraryRuntimeExceptionObjects- Returns:
- a
TypedGeneratorfor allRuntimeExceptions
-
throwables
public static TypedGenerator<Throwable> throwables()
Factory method for creating aTypedGeneratorarbitraryThrowableObjects- Returns:
- a
TypedGeneratorfor allThrowables
-
urls
public static TypedGenerator<URL> urls()
Factory method for creating aTypedGeneratorarbitraryURLs Objects- Returns:
- a
TypedGeneratorfor allURLs
-
-