|
|
@@ -47,19 +47,21 @@ public class Cargo implements Entity<Cargo> {
|
|
47
|
47
|
|
|
48
|
48
|
/**
|
|
49
|
49
|
* @param trackingId tracking id
|
|
50
|
|
- * @param origin origin location
|
|
51
|
|
- * @param destination destination location
|
|
|
50
|
+ * @param routeSpecification route specification
|
|
52
|
51
|
*/
|
|
53
|
|
- public Cargo(TrackingId trackingId, Location origin, Location destination) {
|
|
|
52
|
+ public Cargo(TrackingId trackingId, RouteSpecification routeSpecification) {
|
|
54
|
53
|
Validate.notNull(trackingId);
|
|
55
|
|
- Validate.notNull(origin);
|
|
56
|
|
- Validate.notNull(destination);
|
|
57
|
|
-
|
|
|
54
|
+ Validate.notNull(routeSpecification);
|
|
58
|
55
|
this.trackingId = trackingId;
|
|
59
|
|
- // TODO this is temporary
|
|
60
|
|
- this.routeSpecification = new RouteSpecification(origin, destination, new Date());
|
|
|
56
|
+ this.routeSpecification = routeSpecification;
|
|
|
57
|
+ }
|
|
|
58
|
+
|
|
|
59
|
+ // TODO remove this, only present during migration to other ctor
|
|
|
60
|
+ public Cargo(TrackingId trackingId, Location origin, Location destination) {
|
|
|
61
|
+ this(trackingId, new RouteSpecification(origin, destination, new Date()));
|
|
61
|
62
|
}
|
|
62
|
63
|
|
|
|
64
|
+
|
|
63
|
65
|
/**
|
|
64
|
66
|
* The tracking id is the identity of this entity, and is unique.
|
|
65
|
67
|
*
|
|
|
@@ -98,7 +100,7 @@ public class Cargo implements Entity<Cargo> {
|
|
98
|
100
|
}
|
|
99
|
101
|
|
|
100
|
102
|
/**
|
|
101
|
|
- * @return True if the cargo has arrived at its final destination.
|
|
|
103
|
+ * @return True if the cargo has arrived at its destination.
|
|
102
|
104
|
*/
|
|
103
|
105
|
public boolean hasArrived() {
|
|
104
|
106
|
return destination().equals(delivery.lastKnownLocation());
|
|
|
@@ -122,13 +124,7 @@ public class Cargo implements Entity<Cargo> {
|
|
122
|
124
|
*/
|
|
123
|
125
|
public void assignToRoute(final Itinerary itinerary) {
|
|
124
|
126
|
Validate.notNull(itinerary);
|
|
125
|
|
-
|
|
126
|
|
- // Decouple the old itinerary (which may or may not exist) from this cargo
|
|
127
|
|
- //itinerary().setCargo(null);
|
|
128
|
|
-
|
|
129
|
|
- // Couple this cargo and the new itinerary
|
|
130
|
127
|
this.itinerary = itinerary;
|
|
131
|
|
- //this.itinerary.setCargo(this);
|
|
132
|
128
|
}
|
|
133
|
129
|
|
|
134
|
130
|
/**
|