Class EntityDtoMapper<DTO>

java.lang.Object
org.litebridgedb.orm.persistence.EntityDtoMapper<DTO>
Type Parameters:
DTO - the type parameter of the Data Transfer Object (DTO)

public class EntityDtoMapper<DTO> extends Object
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 Details

  • Method Details

    • dtoClass

      public Class<DTO> dtoClass()
    • entityClasses

      public List<Class<?>> entityClasses()
    • entities

      public List<Object> entities(DTO dto)
      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 - if dto is null
    • dto

      public DTO dto(Object... entities)
      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 - if entities is null
    • dto

      public DTO dto(List<Object> entities)
      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 - if entities is null