Package ru.objectsfill.object_param
Class Fill.FillBuilder
java.lang.Object
ru.objectsfill.object_param.Fill.FillBuilder
- Enclosing class:
- Fill
Fluent builder for constructing
Fill configurations.-
Constructor Summary
ConstructorsConstructorDescriptionFillBuilder(Class<?> clazz) Creates a builder from a class, attempting to instantiate it via the no-arg constructor.FillBuilder(T objectz) Creates a builder from an existing object instance. -
Method Summary
Modifier and TypeMethodDescriptioncollectionSize(Integer collectionSize) Sets the number of elements to generate for collections and arrays.excludeField(String... excludedFieldName) Sets the field names to exclude from generation.excludeField(List<String> excludedFieldName) Sets the list of field names to exclude from generation.fieldParams(List<Extend> parameter) Adds a list of per-field parameter overrides.fieldParams(Extend parameter) Adds a single per-field parameter override.fieldParams(Extend... parameter) Adds multiple per-field parameter overrides.gen()Builds and returns theFillconfiguration.Sets the maximum recursion depth for nested object generation.valueLength(Integer valueLength) Sets the length of randomly generated string values.withGeneric(String genericName, Class<?> genericClass) Registers a generic type parameter mapping by name using aClass.withGeneric(String genericName, Type genericType) Registers a generic type parameter mapping by name.withGeneric(Map<String, Type> genericType) Registers multiple generic type parameter mappings.
-
Constructor Details
-
FillBuilder
public FillBuilder(T objectz) Creates a builder from an existing object instance.- Type Parameters:
T- the object type- Parameters:
objectz- the object to fill
-
FillBuilder
Creates a builder from a class, attempting to instantiate it via the no-arg constructor. If instantiation fails (no public no-arg constructor, abstract class, etc.), the object will be created later via a parameterized constructor.- Parameters:
clazz- the class to instantiate and fill
-
-
Method Details
-
collectionSize
Sets the number of elements to generate for collections and arrays.- Parameters:
collectionSize- the collection size (must be >= 1)- Returns:
- this builder
- Throws:
FillException- if the value is less than 1
-
valueLength
Sets the length of randomly generated string values.- Parameters:
valueLength- the value length (must be >= 1)- Returns:
- this builder
- Throws:
FillException- if the value is less than 1
-
fieldParams
Adds a single per-field parameter override.- Parameters:
parameter- the field parameter override- Returns:
- this builder
-
fieldParams
Adds multiple per-field parameter overrides.- Parameters:
parameter- the field parameter overrides- Returns:
- this builder
-
fieldParams
Adds a list of per-field parameter overrides.- Parameters:
parameter- the field parameter overrides- Returns:
- this builder
-
withGeneric
Registers a generic type parameter mapping by name.- Parameters:
genericName- the type parameter name (e.g. "T")genericType- the resolved type- Returns:
- this builder
-
withGeneric
Registers multiple generic type parameter mappings.- Parameters:
genericType- map of type parameter names to resolved types- Returns:
- this builder
-
withGeneric
Registers a generic type parameter mapping by name using aClass.- Parameters:
genericName- the type parameter name (e.g. "T")genericClass- the resolved class (ignored if null)- Returns:
- this builder
-
excludeField
Sets the list of field names to exclude from generation.- Parameters:
excludedFieldName- the field names to exclude- Returns:
- this builder
-
excludeField
Sets the field names to exclude from generation.- Parameters:
excludedFieldName- the field names to exclude- Returns:
- this builder
-
setDeep
Sets the maximum recursion depth for nested object generation.- Parameters:
deep- the depth limit (must be >= 1)- Returns:
- this builder
- Throws:
FillException- if the value is less than 1
-
gen
Builds and returns theFillconfiguration.- Returns:
- the constructed Fill object
-