1 package se.citerus.dddsample.interfaces.booking.facade.dto;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.Collections;
6 import java.util.Date;
7 import java.util.List;
8
9
10
11
12 public final class CargoRoutingDTO implements Serializable {
13
14 private final String trackingId;
15 private final String origin;
16 private final String finalDestination;
17 private final Date arrivalDeadline;
18 private final boolean misrouted;
19 private final List<LegDTO> legs;
20
21
22
23
24
25
26
27
28
29
30 public CargoRoutingDTO(String trackingId, String origin, String finalDestination, Date arrivalDeadline, boolean misrouted) {
31 this.trackingId = trackingId;
32 this.origin = origin;
33 this.finalDestination = finalDestination;
34 this.arrivalDeadline = arrivalDeadline;
35 this.misrouted = misrouted;
36 this.legs = new ArrayList<LegDTO>();
37 }
38
39 public String getTrackingId() {
40 return trackingId;
41 }
42
43 public String getOrigin() {
44 return origin;
45 }
46
47 public String getFinalDestination() {
48 return finalDestination;
49 }
50
51 public void addLeg(String voyageNumber, String from, String to, Date loadTime, Date unloadTime) {
52 legs.add(new LegDTO(voyageNumber, from, to, loadTime, unloadTime));
53 }
54
55
56
57
58 public List<LegDTO> getLegs() {
59 return Collections.unmodifiableList(legs);
60 }
61
62 public boolean isMisrouted() {
63 return misrouted;
64 }
65
66 public boolean isRouted() {
67 return !legs.isEmpty();
68 }
69
70 public Date getArrivalDeadline() {
71 return arrivalDeadline;
72 }
73
74 }