Class CollectionElementCreationService

java.lang.Object
ru.objectsfill.service.CollectionElementCreationService

public class CollectionElementCreationService extends Object
Service responsible for generating collection, array, and single-value field contents. Resolves the field's element type, looks up the appropriate CollectionTypeFill handler, and delegates generation. Falls back to array handling or single-value generation if no collection handler matches.
  • Constructor Details

    • CollectionElementCreationService

      public CollectionElementCreationService()
      Constructs a new service instance and initializes the collection type registry by scanning for user-defined implementations and adding default mappings.
  • Method Details

    • generateCollection

      public Object generateCollection(Field field, Fill fill)
      Generates a value for the given field based on its type. Handles parameterized collections (List, Set, Map, Stream), arrays, and plain single values.
      Parameters:
      field - the field to generate a value for
      fill - the generation parameters
      Returns:
      the generated collection, array, or single value
    • getTypeClass

      public static Class<?> getTypeClass(Field field, Fill fill)
      Resolves the runtime class for a field's type, substituting generic type parameters from the Fill configuration when the declared type is Object.
      Parameters:
      field - the field whose type is being resolved
      fill - the Fill object containing generic type mappings
      Returns:
      the resolved class
      Throws:
      FillException - if a required generic type mapping is not found