public class EnhancedRandomBuilder
extends java.lang.Object
EnhancedRandom instances.| Constructor and Description |
|---|
EnhancedRandomBuilder()
Create a new
EnhancedRandomBuilder. |
| Modifier and Type | Method and Description |
|---|---|
static EnhancedRandom |
aNewEnhancedRandom()
Create a new
EnhancedRandom instance with default parameters. |
static EnhancedRandomBuilder |
aNewEnhancedRandomBuilder()
Create a new
EnhancedRandomBuilder. |
EnhancedRandom |
build()
Build a
EnhancedRandom instance. |
EnhancedRandomBuilder |
charset(java.nio.charset.Charset charset)
Set the charset to use for character based fields.
|
EnhancedRandomBuilder |
collectionSizeRange(int minCollectionSize,
int maxCollectionSize)
Set the collection size range.
|
EnhancedRandomBuilder |
dateRange(java.time.LocalDate min,
java.time.LocalDate max)
Set the date range.
|
EnhancedRandomBuilder |
exclude(java.lang.Class<?>... types)
Exclude types from being populated.
|
<T,F> EnhancedRandomBuilder |
exclude(FieldDefinition<T,F> fieldDefinition)
Exclude a field from being populated.
|
EnhancedRandomBuilder |
maxCollectionSize(int maxCollectionSize)
Deprecated.
use
collectionSizeRange(int, int) instead |
EnhancedRandomBuilder |
maxObjectPoolSize(int maxObjectPoolSize)
Deprecated.
use
objectPoolSize(int) instead |
EnhancedRandomBuilder |
maxRandomizationDepth(int maxRandomizationDepth)
Deprecated.
use
randomizationDepth(int) instead |
EnhancedRandomBuilder |
maxStringLength(int maxStringLength)
Deprecated.
use
stringLengthRange(int, int) instead |
EnhancedRandomBuilder |
minCollectionSize(int minCollectionSize)
Deprecated.
use
collectionSizeRange(int, int) instead |
EnhancedRandomBuilder |
minStringLength(int minStringLength)
Deprecated.
use
stringLengthRange(int, int) instead |
EnhancedRandomBuilder |
objectPoolSize(int objectPoolSize)
Set the number of different objects to generate for a type.
|
EnhancedRandomBuilder |
overrideDefaultInitialization(boolean overrideDefaultInitialization)
Should default initialization of field values be overridden?
E.g.
|
EnhancedRandomBuilder |
randomizationDepth(int randomizationDepth)
Set the randomization depth for objects tree.
|
<T,R> EnhancedRandomBuilder |
randomize(java.lang.Class<T> type,
Randomizer<R> randomizer)
Register a custom randomizer for a given type.
|
<T,R> EnhancedRandomBuilder |
randomize(java.lang.Class<T> type,
java.util.function.Supplier<R> supplier)
Register a supplier as randomizer for a given type.
|
<T,F,R> EnhancedRandomBuilder |
randomize(FieldDefinition<T,F> fieldDefinition,
Randomizer<R> randomizer)
Register a custom randomizer for a given field.
|
<T,F,R> EnhancedRandomBuilder |
randomize(FieldDefinition<T,F> fieldDefinition,
java.util.function.Supplier<R> supplier)
Register a supplier as randomizer for a given field.
|
EnhancedRandomBuilder |
registerRandomizerRegistry(RandomizerRegistry registry)
Register a
RandomizerRegistry. |
EnhancedRandomBuilder |
scanClasspathForConcreteTypes(boolean scanClasspathForConcreteTypes)
Should the classpath be scanned for concrete types when a field with an interface or abstract
class type is encountered?
Deactivated by default.
|
EnhancedRandomBuilder |
seed(long seed)
Set the initial random seed.
|
EnhancedRandomBuilder |
stringLengthRange(int minStringLength,
int maxStringLength)
Set the string length range.
|
EnhancedRandomBuilder |
timeRange(java.time.LocalTime min,
java.time.LocalTime max)
Set the time range.
|
public EnhancedRandomBuilder()
EnhancedRandomBuilder.public static EnhancedRandomBuilder aNewEnhancedRandomBuilder()
EnhancedRandomBuilder.EnhancedRandomBuilderpublic static EnhancedRandom aNewEnhancedRandom()
EnhancedRandom instance with default parameters.EnhancedRandompublic <T,F,R> EnhancedRandomBuilder randomize(FieldDefinition<T,F> fieldDefinition, Randomizer<R> randomizer)
T - The target class typeF - The target field typeR - The type generated by the randomizerfieldDefinition - definition of the field to randomizerandomizer - the custom Randomizer to useEnhancedRandomBuilder instancepublic <T,F,R> EnhancedRandomBuilder randomize(FieldDefinition<T,F> fieldDefinition, java.util.function.Supplier<R> supplier)
T - The target class typeF - The target field typeR - The type generated by the supplierfieldDefinition - definition of the field to randomizesupplier - the custom Supplier to useEnhancedRandomBuilder instancepublic <T,R> EnhancedRandomBuilder randomize(java.lang.Class<T> type, Randomizer<R> randomizer)
T - The field typeR - The type generated by the randomizertype - class of the type to randomizerandomizer - the custom Randomizer to useEnhancedRandomBuilder instancepublic <T,R> EnhancedRandomBuilder randomize(java.lang.Class<T> type, java.util.function.Supplier<R> supplier)
T - The field typeR - The type generated by the suppliertype - class of the type to randomizesupplier - the custom Supplier to useEnhancedRandomBuilder instancepublic <T,F> EnhancedRandomBuilder exclude(FieldDefinition<T,F> fieldDefinition)
T - The target class typeF - The target field typefieldDefinition - definition of the field to excludeEnhancedRandomBuilder instancepublic EnhancedRandomBuilder exclude(java.lang.Class<?>... types)
types - the types to excludeEnhancedRandomBuilder instancepublic EnhancedRandomBuilder seed(long seed)
seed - the initial seedEnhancedRandomBuilder instance@Deprecated public EnhancedRandomBuilder minCollectionSize(int minCollectionSize)
collectionSizeRange(int, int) insteadminCollectionSize - the minimum collection sizeEnhancedRandomBuilder instance@Deprecated public EnhancedRandomBuilder maxCollectionSize(int maxCollectionSize)
collectionSizeRange(int, int) insteadmaxCollectionSize - the maximum collection sizeEnhancedRandomBuilder instancepublic EnhancedRandomBuilder collectionSizeRange(int minCollectionSize, int maxCollectionSize)
minCollectionSize - the minimum collection sizemaxCollectionSize - the maximum collection sizeEnhancedRandomBuilder instancepublic EnhancedRandomBuilder stringLengthRange(int minStringLength, int maxStringLength)
minStringLength - the minimum string lengthmaxStringLength - the maximum string lengthEnhancedRandomBuilder instance@Deprecated public EnhancedRandomBuilder maxStringLength(int maxStringLength)
stringLengthRange(int, int) insteadmaxStringLength - the maximum string lengthEnhancedRandomBuilder instance@Deprecated public EnhancedRandomBuilder minStringLength(int minStringLength)
stringLengthRange(int, int) insteadminStringLength - the minimum string lengthEnhancedRandomBuilder instance@Deprecated public EnhancedRandomBuilder maxObjectPoolSize(int maxObjectPoolSize)
objectPoolSize(int) insteadmaxObjectPoolSize - the maximum number of objectsEnhancedRandomBuilder instancepublic EnhancedRandomBuilder objectPoolSize(int objectPoolSize)
objectPoolSize - the number of objects to generate in the poolEnhancedRandomBuilder instance@Deprecated public EnhancedRandomBuilder maxRandomizationDepth(int maxRandomizationDepth)
randomizationDepth(int) insteadmaxRandomizationDepth - the maximum randomization depthEnhancedRandomBuilder instancepublic EnhancedRandomBuilder randomizationDepth(int randomizationDepth)
randomizationDepth - the maximum randomization depthEnhancedRandomBuilder instancepublic EnhancedRandomBuilder charset(java.nio.charset.Charset charset)
charset - the charset to useEnhancedRandomBuilder instancepublic EnhancedRandomBuilder dateRange(java.time.LocalDate min, java.time.LocalDate max)
min - datemax - dateEnhancedRandomBuilder instancepublic EnhancedRandomBuilder timeRange(java.time.LocalTime min, java.time.LocalTime max)
min - timemax - timeEnhancedRandomBuilder instancepublic EnhancedRandomBuilder registerRandomizerRegistry(RandomizerRegistry registry)
RandomizerRegistry.registry - the RandomizerRegistry to registerEnhancedRandomBuilder instancepublic EnhancedRandomBuilder scanClasspathForConcreteTypes(boolean scanClasspathForConcreteTypes)
scanClasspathForConcreteTypes - whether to scan the classpath or notEnhancedRandomBuilder instancepublic EnhancedRandomBuilder overrideDefaultInitialization(boolean overrideDefaultInitialization)
strings and integers fields below be kept untouched
or should they be randomized.
public class Bean {
Set<String> strings = new HashSet<>();
List<Integer> integers;
public Bean() {
integers = Arrays.asList(1, 2, 3);
}
}
Deactivated by default.overrideDefaultInitialization - whether to override default initialization of field values or notEnhancedRandomBuilder instancepublic EnhancedRandom build()
EnhancedRandom instance.EnhancedRandom instanceCopyright © 2019. All Rights Reserved.