Interface EntityMapper<T,U,R,F,ID>
- Type Parameters:
T
- entity typeU
- request/upsert/patch DTO typeR
- full response DTO typeF
- reference DTO typeID
- 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 TypeMethodDescriptionfromRequest
(U request) Instantiate and populate a new entity from the request DTO.getIdFromRequest
(U request) Extract the identifier value from the DTO (for upsert logic).Copy only non-null properties from the DTO into the entity.Instantiate and populate a reference DTO from the entity.toResponse
(T entity) Instantiate and populate a full response DTO from the entity.Copy all properties from the DTO into an existing entity.
-
Method Details
-
fromRequest
Instantiate and populate a new entity from the request DTO. -
update
Copy all properties from the DTO into an existing entity.- Returns:
- the updated entity
-
patch
Copy only non-null properties from the DTO into the entity.- Returns:
- the patched entity
-
toResponse
Instantiate and populate a full response DTO from the entity. -
toRef
Instantiate and populate a reference DTO from the entity. -
getIdFromRequest
Extract the identifier value from the DTO (for upsert logic).
-