1:package is346; 2: 3:import java.util.ArrayList; 4:import java.util.Iterator; 5:import java.util.Collection; 6:import java.util.List; 7: 8:public class ArtistDtoAssembler { 9: public static ArtistDto createDto(Artist artist) { 10: ArtistDto artistDto = new ArtistDto(); 11: if (artist != null) { 12: artistDto.setId(artist.getId()); 13: artistDto.setName(artist.getName()); 14: } 15: return artistDto; 16: } 17: 18: public static ArtistDto[] createDtos(Collection artists) { 19: List list = new ArrayList(); 20: if (artists != null) { 21: Iterator iterator = artists.iterator(); 22: while (iterator.hasNext()) { 23: list.add(createDto( (Artist) iterator.next())); 24: } 25: } 26: ArtistDto[] returnArray = new ArtistDto[list.size()]; 27: return (ArtistDto[]) list.toArray(returnArray); 28: } 29:}