java.lang.Object
org.litebridgedb.orm.persistence.EntityDtoMapper<DTO>
- Type Parameters:
DTO- the type parameter of the Data Transfer Object (DTO)
Mapper for converting between complex Data Transfer Objects (DTOs) and their corresponding "entity" objects.
Provides functionality for converting a DTO to a list of entities and vice versa, based on a set of field mappings
specified via
DtoEntityMapping.-
Constructor Summary
ConstructorsConstructorDescriptionEntityDtoMapper(Class<DTO> dtoClass, List<DtoEntityMapping> dtoEntityMappings, ClassFieldAccessorCache classFieldAccessorCache) -
Method Summary
Modifier and TypeMethodDescriptionConverts the specified entity objects into a Data Transfer Object (DTO).Converts a list of entity objects into a Data Transfer Object (DTO).dtoClass()Converts the given DTO into a list of entity objects based on the mappings defined in the class.
-
Constructor Details
-
EntityDtoMapper
public EntityDtoMapper(Class<DTO> dtoClass, List<DtoEntityMapping> dtoEntityMappings, ClassFieldAccessorCache classFieldAccessorCache)
-
-
Method Details
-
dtoClass
-
entityClasses
-
entities
Converts the given DTO into a list of entity objects based on the mappings defined in the class. The entities are constructed and populated with field values fetched from the DTO. This method ensures that composite relationships and intermediate entities are properly handled.- Parameters:
dto- the data transfer object (DTO) to be converted into entities; must not be null- Returns:
- a list of constructed and populated entity objects
- Throws:
IllegalArgumentException- ifdtois null
-
dto
Converts the specified entity objects into a Data Transfer Object (DTO). Maps the fields of the entities into the corresponding fields of the DTO based on the predefined entity-to-DTO field mappings. Also handles nested DTO fields if present.- Parameters:
entities- the array of entity objects to be converted; must not be null- Returns:
- a DTO populated with field values extracted from the given entities
- Throws:
IllegalArgumentException- ifentitiesis null
-
dto
Converts a list of entity objects into a Data Transfer Object (DTO). Maps the fields of the entities into the corresponding fields of the DTO based on the predefined entity-to-DTO field mappings. Also handles nested DTO fields if present.- Parameters:
entities- the list of entity objects to be converted; must not be null- Returns:
- a DTO populated with field values extracted from the given entities
- Throws:
IllegalArgumentException- ifentitiesis null
-