Class Extend

java.lang.Object
ru.objectsfill.object_param.Extend

public class Extend extends Object
Per-field parameter override for customizing how individual fields are populated. Allows setting custom collection sizes, value lengths, and mutation functions that target specific fields by name, by class type, or apply globally.

Example:


 Extend.field("name").addMutationFunction(n -> "Custom").gen()
 Extend.clazz(String.class).valueLength(20).gen()
 Extend.wrapByFunction(obj -> transform(obj)).gen()
 
  • Constructor Details

    • Extend

      public Extend(String fieldName, Integer collectionSize, Integer valueLength, UnaryOperator<Object> singleChangeFunction, Class<?> clazz)
      Constructs a new Extend with all parameters.
      Parameters:
      fieldName - the target field name (or null)
      collectionSize - the collection size override (or null)
      valueLength - the value length override (or null)
      singleChangeFunction - the mutation function (or null)
      clazz - the target class type (or null)
  • Method Details

    • getClazz

      public Class<?> getClazz()
      Returns the class type used for field matching.
      Returns:
      the class type, or null if matching by field name
    • getFieldChangeFunction

      public UnaryOperator<Object> getFieldChangeFunction()
      Returns the mutation function applied to generated values.
      Returns:
      the mutation function, or null if none is set
    • getFieldName

      public String getFieldName()
      Returns the field name used for matching.
      Returns:
      the field name, or null if matching by class type
    • getCollectionSize

      public Integer getCollectionSize()
      Returns the custom collection size for this field.
      Returns:
      the collection size override, or null to use the default
    • getValueLength

      public Integer getValueLength()
      Returns the custom value length for this field.
      Returns:
      the value length override, or null to use the default
    • field

      public static Extend.FillFieldParametersBuilder field(String fieldName)
      Starts building an Extend that targets a specific field by name.
      Parameters:
      fieldName - the name of the field to customize
      Returns:
      a new builder
    • clazz

      public static Extend.FillFieldParametersBuilder clazz(Class<?> clazz)
      Starts building an Extend that targets all fields of a specific class type.
      Parameters:
      clazz - the class type to match fields against
      Returns:
      a new builder
    • wrapByFunction

      public static Extend.FillFieldParametersBuilder wrapByFunction(UnaryOperator<Object> singleChangeFunction)
      Starts building an Extend with a global mutation function applied to every generated value (when no field name or class is specified).
      Parameters:
      singleChangeFunction - the mutation function
      Returns:
      a new builder