Package ru.objectsfill.object_param
Class Fill
java.lang.Object
ru.objectsfill.object_param.Fill
Configuration object that holds all parameters for populating a POJO with random data.
Use the
Fill.FillBuilder (via object(Class) or object(Object)) to construct instances.
Example:
Fill fill = Fill.object(MyClass.class)
.collectionSize(10)
.valueLength(15)
.setDeep(5)
.excludeField("id", "createdAt")
.gen();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder for constructingFillconfigurations. -
Method Summary
Modifier and TypeMethodDescriptionClass<?>getClazz()Returns the class of the object being filled.Returns the number of elements to generate for collections.getDeep()Returns the maximum recursion depth.Returns the list of field names excluded from generation.Returns the list of per-field parameter overrides.Returns the generic type parameter mappings.Returns the object instance being filled.Returns the length of randomly generated string values.static Fill.FillBuilderStarts building aFillconfiguration for a class.static Fill.FillBuilderStarts building aFillconfiguration for an existing object instance.voidSets the maximum recursion depth for nested object generation.voidsetGenericType(String genericName, Type genericType) Adds a single generic type parameter mapping.voidsetGenericType(Map<String, Type> genericType) Replaces all generic type parameter mappings.voidsetObjectz(Object objectz) Replaces the target object instance.
-
Method Details
-
setObjectz
Replaces the target object instance. Used when the original class could not be instantiated via a no-arg constructor and a parameterized constructor was used instead.- Parameters:
objectz- the new object instance
-
getGenericType
Returns the generic type parameter mappings.- Returns:
- map of generic type names to their resolved
Typeinstances
-
setDeep
Sets the maximum recursion depth for nested object generation.- Parameters:
deep- the depth limit
-
setGenericType
Replaces all generic type parameter mappings.- Parameters:
genericType- the new generic type map
-
setGenericType
Adds a single generic type parameter mapping. Creates the map if it does not yet exist.- Parameters:
genericName- the type parameter name (e.g. "T")genericType- the resolved type
-
getClazz
Returns the class of the object being filled.- Returns:
- the target class
-
getObjectz
Returns the object instance being filled.- Returns:
- the target object
-
getExcludedField
Returns the list of field names excluded from generation.- Returns:
- excluded field names
-
getDeep
Returns the maximum recursion depth.- Returns:
- the depth limit
-
getCollectionSize
Returns the number of elements to generate for collections.- Returns:
- the collection size
-
getValueLength
Returns the length of randomly generated string values.- Returns:
- the value length
-
getExtendedFieldParams
Returns the list of per-field parameter overrides.- Returns:
- the extended field parameters
-
object
Starts building aFillconfiguration for an existing object instance.- Parameters:
object- the object to fill- Returns:
- a new
Fill.FillBuilder
-
object
Starts building aFillconfiguration for a class. The class will be instantiated automatically via its no-arg constructor.- Parameters:
clazz- the class to instantiate and fill- Returns:
- a new
Fill.FillBuilder
-