Class RaceMapper

java.lang.Object
com.endurancetrio.business.event.mapper.RaceMapper

@Component public class RaceMapper extends Object
  • Constructor Details

    • RaceMapper

      public RaceMapper()
  • Method Details

    • map

      public RaceDTO map(Race entity)
      Maps a Race entity to a RaceDTO.

      This method navigates through the race's courses and its distance to populate the sports and distance metadata fields. The caller must ensure that courses and their distances are eagerly fetched to avoid lazy-initialization errors. This method doesn't populate the RaceDTO.event() field in the RaceDTO; use mapWithEvent(Race) if event data is needed.

      Parameters:
      entity - the Race entity to be mapped
      Returns:
      the corresponding RaceDTO, or null if the entity is null
    • mapWithEvent

      public RaceDTO mapWithEvent(Race entity)
      Maps a Race entity to a RaceDTO including the parent Event data.

      Unlike map(Race), this method navigates through the race's courses to populate the RaceDTO.event() field with the associated Event information. The caller must ensure that courses and their events and distances are eagerly fetched to avoid lazy-initialization errors.

      Parameters:
      entity - the Race entity to be mapped
      Returns:
      the corresponding RaceDTO with event data, or null if the entity is null
    • mapWithoutDistanceWithEvent

      public RaceDTO mapWithoutDistanceWithEvent(Race entity)
      Maps a Race entity to a RaceDTO with courses and event data but without distance information.

      Unlike mapWithEvent(Race), this method does not navigate through the courses' distances. The resulting RaceDTO has a null distance metadata, and the event populated from the first course. The caller must ensure that courses and their events are eagerly fetched to avoid lazy-initialization errors.

      Parameters:
      entity - the Race entity to be mapped
      Returns:
      the corresponding RaceDTO with event data, or null if the entity is null