Package ru.objectsfill.service
Class CollectionElementCreationService
java.lang.Object
ru.objectsfill.service.CollectionElementCreationService
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 Summary
ConstructorsConstructorDescriptionConstructs a new service instance and initializes the collection type registry by scanning for user-defined implementations and adding default mappings. -
Method Summary
Modifier and TypeMethodDescriptiongenerateCollection(Field field, Fill fill) Generates a value for the given field based on its type.static Class<?>getTypeClass(Field field, Fill fill) Resolves the runtime class for a field's type, substituting generic type parameters from theFillconfiguration when the declared type isObject.
-
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
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 forfill- the generation parameters- Returns:
- the generated collection, array, or single value
-
getTypeClass
Resolves the runtime class for a field's type, substituting generic type parameters from theFillconfiguration when the declared type isObject.- Parameters:
field- the field whose type is being resolvedfill- the Fill object containing generic type mappings- Returns:
- the resolved class
- Throws:
FillException- if a required generic type mapping is not found
-