Interface EntityMapper<T,U,R,F,ID>

Type Parameters:
T - entity type
U - request/upsert/patch DTO type
R - full response DTO type
F - reference DTO type
ID - identifier type

public interface EntityMapper<T,U,R,F,ID>
Maps between JPA entities and Data Transfer Objects (DTOs). This interface defines methods for converting between:
  • T - the JPA entity type
  • U - the create/update/patch/upsert request DTO type
  • R - the full response DTO type
  • F - the reference DTO type
  • ID - the identifier type

Implementations must handle deep copies of properties and ID extraction. They may also consult @FieldSecurity annotations and use FieldSecurityUtil to omit or redact fields based on the current user's roles.

  • Method Summary

    Modifier and Type
    Method
    Description
    fromRequest(U request)
    Instantiate and populate a new entity from the request DTO.
    Extract the identifier value from the DTO (for upsert logic).
    patch(T entity, U request)
    Copy only non-null properties from the DTO into the entity.
    toRef(T entity)
    Instantiate and populate a reference DTO from the entity.
    toResponse(T entity)
    Instantiate and populate a full response DTO from the entity.
    update(T entity, U request)
    Copy all properties from the DTO into an existing entity.
  • Method Details

    • fromRequest

      T fromRequest(U request)
      Instantiate and populate a new entity from the request DTO.
    • update

      T update(T entity, U request)
      Copy all properties from the DTO into an existing entity.
      Returns:
      the updated entity
    • patch

      T patch(T entity, U request)
      Copy only non-null properties from the DTO into the entity.
      Returns:
      the patched entity
    • toResponse

      R toResponse(T entity)
      Instantiate and populate a full response DTO from the entity.
    • toRef

      F toRef(T entity)
      Instantiate and populate a reference DTO from the entity.
    • getIdFromRequest

      ID getIdFromRequest(U request)
      Extract the identifier value from the DTO (for upsert logic).