|
|
@@ -2,6 +2,7 @@ package se.citerus.dddsample.tracking.core.domain.model.shared;
|
|
2
|
2
|
|
|
3
|
3
|
import org.apache.commons.lang.Validate;
|
|
4
|
4
|
import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
|
|
|
5
|
+import static se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent.Type.*;
|
|
5
|
6
|
import se.citerus.dddsample.tracking.core.domain.model.location.Location;
|
|
6
|
7
|
import se.citerus.dddsample.tracking.core.domain.model.voyage.Voyage;
|
|
7
|
8
|
import se.citerus.dddsample.tracking.core.domain.patterns.valueobject.ValueObjectSupport;
|
|
|
@@ -13,10 +14,6 @@ import se.citerus.dddsample.tracking.core.domain.patterns.valueobject.ValueObjec
|
|
13
|
14
|
*/
|
|
14
|
15
|
public class HandlingActivity extends ValueObjectSupport<HandlingActivity> {
|
|
15
|
16
|
|
|
16
|
|
- // TODO introduce something like this (?):
|
|
17
|
|
- // HandlingActivity.loadOnto(voyage).in(location)
|
|
18
|
|
- // HandlingActivity.claimIn(location)
|
|
19
|
|
-
|
|
20
|
17
|
private final HandlingEvent.Type type;
|
|
21
|
18
|
private final Location location;
|
|
22
|
19
|
private final Voyage voyage;
|
|
|
@@ -64,4 +61,40 @@ public class HandlingActivity extends ValueObjectSupport<HandlingActivity> {
|
|
64
|
61
|
voyage = null;
|
|
65
|
62
|
}
|
|
66
|
63
|
|
|
|
64
|
+ // DSL-like factory methods
|
|
|
65
|
+
|
|
|
66
|
+ public static InLocation loadedOnto(Voyage voyage) {
|
|
|
67
|
+ return new InLocation(LOAD, voyage);
|
|
|
68
|
+ }
|
|
|
69
|
+
|
|
|
70
|
+ public static InLocation unloadedOff(Voyage voyage) {
|
|
|
71
|
+ return new InLocation(UNLOAD, voyage);
|
|
|
72
|
+ }
|
|
|
73
|
+
|
|
|
74
|
+ public static HandlingActivity receivedIn(Location location) {
|
|
|
75
|
+ return new HandlingActivity(RECEIVE, location);
|
|
|
76
|
+ }
|
|
|
77
|
+
|
|
|
78
|
+ public static HandlingActivity claimedIn(Location location) {
|
|
|
79
|
+ return new HandlingActivity(CLAIM, location);
|
|
|
80
|
+ }
|
|
|
81
|
+
|
|
|
82
|
+ public static HandlingActivity customsIn(Location location) {
|
|
|
83
|
+ return new HandlingActivity(CUSTOMS, location);
|
|
|
84
|
+ }
|
|
|
85
|
+
|
|
|
86
|
+ public static class InLocation {
|
|
|
87
|
+ private final HandlingEvent.Type type;
|
|
|
88
|
+ private final Voyage voyage;
|
|
|
89
|
+
|
|
|
90
|
+ public InLocation(HandlingEvent.Type type, Voyage voyage) {
|
|
|
91
|
+ this.type = type;
|
|
|
92
|
+ this.voyage = voyage;
|
|
|
93
|
+ }
|
|
|
94
|
+
|
|
|
95
|
+ public HandlingActivity in(Location location) {
|
|
|
96
|
+ return new HandlingActivity(type, location, voyage);
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
|
|
99
|
+
|
|
67
|
100
|
}
|