Package org.kurtymckurt.TestPojo
Class TestPojoBuilder<T>
- java.lang.Object
-
- org.kurtymckurt.TestPojo.TestPojoBuilder<T>
-
public class TestPojoBuilder<T> extends Object
-
-
Constructor Summary
Constructors Constructor Description TestPojoBuilder(Class<T> clazz)TestPojoBuilder(Class<T> clazz, ProviderFunction providerFunction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TestPojoBuilder<T>addExcludedField(String fieldName)Adds a field name to the builder so that this field will not be generated.TestPojoBuilder<T>addExcludedFields(String fieldName, String... fields)Adds multiple fields to be excluded from generation.TestPojoBuilder<T>addGenerator(Generator generator)Adds a custom generator for a type that isn't currently supported out of the box.TestPojoBuilder<T>addLimiter(String fieldName, Limiter limiter)Adds a new Limiter per field name that will limit and control the randomness of the generated field.TestPojoBuilder<T>addProviderFunction(ProviderFunction providerFunction, Class<?> clazz, Class<?>... clazzes)Adds a custom provider in order to allow the builder to know how to create a *New* object of that type.Tbuild()Builds the object with the random data generated.TestPojoBuilder<T>setRandomGeneratorSeed(long seed)
-
-
-
Constructor Detail
-
TestPojoBuilder
public TestPojoBuilder(Class<T> clazz, ProviderFunction providerFunction)
-
-
Method Detail
-
addGenerator
public TestPojoBuilder<T> addGenerator(Generator generator)
Adds a custom generator for a type that isn't currently supported out of the box. This allows the builder to know how to build an object it otherwise wouldn't know how. For example, if there's a new type of collection interface that isn't currently supported.- Parameters:
generator- generator for generating the new type of class.- Returns:
- the builder
-
addProviderFunction
public TestPojoBuilder<T> addProviderFunction(ProviderFunction providerFunction, Class<?> clazz, Class<?>... clazzes)
Adds a custom provider in order to allow the builder to know how to create a *New* object of that type. Requires at least one class for each provider. If the provider creates for multiple classes, you can provide more classes. I.E ( a concurrent map creation can provide for ConcurrentMap, Map, etc)- Parameters:
providerFunction- a provider that news an object of a provided typeclazz- a mandatory class that will be created by the provider function.clazzes- additional classes that can be created by provider function.- Returns:
- the builder
-
addLimiter
public TestPojoBuilder<T> addLimiter(String fieldName, Limiter limiter)
Adds a new Limiter per field name that will limit and control the randomness of the generated field.- Parameters:
fieldName- the name of the fieldlimiter- the limiter for the field- Returns:
- the builder
-
addExcludedField
public TestPojoBuilder<T> addExcludedField(String fieldName)
Adds a field name to the builder so that this field will not be generated. This field will likely be null but can depend on the constructor or builder used to provide the new object. You can also control this via a provider.- Parameters:
fieldName- the field name- Returns:
- the builder
-
addExcludedFields
public TestPojoBuilder<T> addExcludedFields(String fieldName, String... fields)
Adds multiple fields to be excluded from generation. This field will likely be null but can depend on the constructor or builder used to provide the new object. You can also control this via a provider.- Parameters:
fieldName- the field name to ignorefields- the additional field names to ignore- Returns:
- the builder
-
setRandomGeneratorSeed
public TestPojoBuilder<T> setRandomGeneratorSeed(long seed)
-
build
public T build()
Builds the object with the random data generated.- Returns:
- T the object asked to build
-
-