View Javadoc

1   package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
2   
3   import se.citerus.dddsample.domain.model.location.Location;
4   import se.citerus.dddsample.interfaces.booking.facade.dto.LocationDTO;
5   
6   import java.util.ArrayList;
7   import java.util.List;
8   
9   public class LocationDTOAssembler {
10  
11    public LocationDTO toDTO(Location location) {
12      return new LocationDTO(location.unLocode().idString(), location.name());
13    }
14  
15    public List<LocationDTO> toDTOList(List<Location> allLocations) {
16      final List<LocationDTO> dtoList = new ArrayList<LocationDTO>(allLocations.size());
17      for (Location location : allLocations) {
18        dtoList.add(toDTO(location));
19      }
20      return dtoList;
21    }
22  }