1 package info.ejava.examples.ejb.ejbjpa.dto; 2 3 import java.io.Serializable; 4 import java.util.LinkedList; 5 import java.util.List; 6 7 public class FloorDTO implements Serializable { 8 private static final long serialVersionUID = 1L; 9 private int level; 10 private List<RoomDTO> rooms; 11 12 public FloorDTO() {} 13 public FloorDTO(int level) { 14 this.level = level; 15 } 16 17 18 public int getLevel() { return level; } 19 public void setLevel(int level) { 20 this.level = level; 21 } 22 23 public List<RoomDTO> getRooms() { return rooms; } 24 public void setRooms(List<RoomDTO> rooms) { 25 this.rooms = rooms; 26 } 27 public FloorDTO withRoom(RoomDTO room) { 28 if (rooms == null) { 29 rooms = new LinkedList<RoomDTO>(); 30 } 31 if (room != null) { 32 rooms.add(room); 33 } 34 return this; 35 } 36 @Override 37 public String toString() { 38 StringBuilder builder = new StringBuilder(); 39 builder.append("FloorDTO [level=").append(level) 40 .append(", rooms={"); 41 if (rooms!=null) { for (RoomDTO room: rooms) { 42 builder.append(room).append("\n"); 43 }} 44 builder.append("}]"); 45 return builder.toString(); 46 } 47 48 49 50 }