Class Fill

java.lang.Object
ru.objectsfill.object_param.Fill

public final class Fill extends Object
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();
 
  • Method Details

    • setObjectz

      public void setObjectz(Object objectz)
      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

      public Map<String,Type> getGenericType()
      Returns the generic type parameter mappings.
      Returns:
      map of generic type names to their resolved Type instances
    • setDeep

      public void setDeep(Integer deep)
      Sets the maximum recursion depth for nested object generation.
      Parameters:
      deep - the depth limit
    • setGenericType

      public void setGenericType(Map<String,Type> genericType)
      Replaces all generic type parameter mappings.
      Parameters:
      genericType - the new generic type map
    • setGenericType

      public void setGenericType(String genericName, Type genericType)
      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

      public Class<?> getClazz()
      Returns the class of the object being filled.
      Returns:
      the target class
    • getObjectz

      public Object getObjectz()
      Returns the object instance being filled.
      Returns:
      the target object
    • getExcludedField

      public List<String> getExcludedField()
      Returns the list of field names excluded from generation.
      Returns:
      excluded field names
    • getDeep

      public Integer getDeep()
      Returns the maximum recursion depth.
      Returns:
      the depth limit
    • getCollectionSize

      public Integer getCollectionSize()
      Returns the number of elements to generate for collections.
      Returns:
      the collection size
    • getValueLength

      public Integer getValueLength()
      Returns the length of randomly generated string values.
      Returns:
      the value length
    • getExtendedFieldParams

      public List<Extend> getExtendedFieldParams()
      Returns the list of per-field parameter overrides.
      Returns:
      the extended field parameters
    • object

      public static Fill.FillBuilder object(Object object)
      Starts building a Fill configuration for an existing object instance.
      Parameters:
      object - the object to fill
      Returns:
      a new Fill.FillBuilder
    • object

      public static Fill.FillBuilder object(Class<?> clazz)
      Starts building a Fill configuration 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