Преглед изворни кода

Entity interface now has sameAs instead of sameIdentityAs, which expresses the intent more clearly.

peter_backlund пре 17 година
родитељ
комит
370634a03f

+ 2
- 4
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Delivery.java Прегледај датотеку

5
 import org.apache.commons.lang.builder.HashCodeBuilder;
5
 import org.apache.commons.lang.builder.HashCodeBuilder;
6
 import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.*;
6
 import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.*;
7
 import static se.citerus.dddsample.domain.model.cargo.TransportStatus.ONBOARD_CARRIER;
7
 import static se.citerus.dddsample.domain.model.cargo.TransportStatus.ONBOARD_CARRIER;
8
-import se.citerus.dddsample.domain.model.handling.HandlingEvent;
9
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.CLAIM;
10
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.UNLOAD;
8
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.*;
11
 import se.citerus.dddsample.domain.model.location.Location;
9
 import se.citerus.dddsample.domain.model.location.Location;
12
 import se.citerus.dddsample.domain.model.shared.HandlingActivity;
10
 import se.citerus.dddsample.domain.model.shared.HandlingActivity;
13
 import se.citerus.dddsample.domain.model.voyage.Voyage;
11
 import se.citerus.dddsample.domain.model.voyage.Voyage;
95
       return false;
93
       return false;
96
     }
94
     }
97
 
95
 
98
-    if (mostRecentHandlingActivity.type().sameValueAs(HandlingEvent.Type.CUSTOMS)) {
96
+    if (CUSTOMS.sameValueAs(mostRecentHandlingActivity.type())) {
99
       return !routeSpecification.destination().sameAs(mostRecentHandlingActivity.location());
97
       return !routeSpecification.destination().sameAs(mostRecentHandlingActivity.location());
100
     } else {
98
     } else {
101
       return !itinerary.isExpected(mostRecentHandlingActivity);
99
       return !itinerary.isExpected(mostRecentHandlingActivity);

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/model/handling/HandlingHistory.java Прегледај датотеку

43
 
43
 
44
     while (it.hasNext()) {
44
     while (it.hasNext()) {
45
       final Cargo nextCargo = it.next().cargo();
45
       final Cargo nextCargo = it.next().cargo();
46
-      Validate.isTrue(firstCargo.sameIdentityAs(nextCargo),
46
+      Validate.isTrue(firstCargo.sameAs(nextCargo),
47
         "A handling history can only contain handling events for a unique cargo. " +
47
         "A handling history can only contain handling events for a unique cargo. " +
48
           "First event is for cargo " + firstCargo + ", also discovered cargo " + nextCargo
48
           "First event is for cargo " + firstCargo + ", also discovered cargo " + nextCargo
49
       );
49
       );

+ 2
- 2
dddsample/src/main/java/se/citerus/dddsample/domain/model/location/CustomsZone.java Прегледај датотеку

108
   }
108
   }
109
 
109
 
110
   @Override
110
   @Override
111
-  public boolean sameIdentityAs(CustomsZone other) {
111
+  public boolean sameAs(CustomsZone other) {
112
     return code.equals(other.code);
112
     return code.equals(other.code);
113
   }
113
   }
114
 
114
 
117
   }
117
   }
118
 
118
 
119
   public boolean includes(Location location) {
119
   public boolean includes(Location location) {
120
-    return this.sameIdentityAs(location.customsZone());
120
+    return this.sameAs(location.customsZone());
121
   }
121
   }
122
 
122
 
123
 
123
 

+ 2
- 2
dddsample/src/main/java/se/citerus/dddsample/domain/model/location/Location.java Прегледај датотеку

83
       return false;
83
       return false;
84
     }
84
     }
85
     Location other = (Location) object;
85
     Location other = (Location) object;
86
-    return sameIdentityAs(other);
86
+    return sameAs(other);
87
   }
87
   }
88
 
88
 
89
   @Override
89
   @Override
90
-  public boolean sameIdentityAs(final Location other) {
90
+  public boolean sameAs(final Location other) {
91
     return this.unLocode.sameValueAs(other.unLocode);
91
     return this.unLocode.sameValueAs(other.unLocode);
92
   }
92
   }
93
 
93
 

+ 2
- 2
dddsample/src/main/java/se/citerus/dddsample/domain/model/voyage/Schedule.java Прегледај датотеку

39
    */
39
    */
40
   public Date departureTimeAt(final Location location) {
40
   public Date departureTimeAt(final Location location) {
41
     for (CarrierMovement movement : carrierMovements) {
41
     for (CarrierMovement movement : carrierMovements) {
42
-      if (movement.departureLocation().sameIdentityAs(location)) {
42
+      if (movement.departureLocation().sameAs(location)) {
43
         return movement.departureTime();
43
         return movement.departureTime();
44
       }
44
       }
45
     }
45
     }
52
    */
52
    */
53
   public Date arrivalTimeAt(final Location location) {
53
   public Date arrivalTimeAt(final Location location) {
54
     for (CarrierMovement movement : carrierMovements) {
54
     for (CarrierMovement movement : carrierMovements) {
55
-      if (movement.arrivalLocation().sameIdentityAs(location)) {
55
+      if (movement.arrivalLocation().sameAs(location)) {
56
         return movement.arrivalTime();
56
         return movement.arrivalTime();
57
       }
57
       }
58
     }
58
     }

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CargoRepositoryTest.java Прегледај датотеку

166
     for (Cargo cargo : cargos) {
166
     for (Cargo cargo : cargos) {
167
       boolean found = false;
167
       boolean found = false;
168
       for (Leg leg : cargo.itinerary().legs()) {
168
       for (Leg leg : cargo.itinerary().legs()) {
169
-        if (leg.voyage().sameIdentityAs(voyage)) {
169
+        if (leg.voyage().sameAs(voyage)) {
170
           found = true;
170
           found = true;
171
         }
171
         }
172
       }
172
       }

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/infrastructure/persistence/inmemory/CargoRepositoryInMem.java Прегледај датотеку

37
   public List<Cargo> findCargosOnVoyage(Voyage voyage) {
37
   public List<Cargo> findCargosOnVoyage(Voyage voyage) {
38
     List<Cargo> onVoyage = new ArrayList<Cargo>();
38
     List<Cargo> onVoyage = new ArrayList<Cargo>();
39
     for (Cargo cargo : cargoDb.values()) {
39
     for (Cargo cargo : cargoDb.values()) {
40
-      if (voyage.sameIdentityAs(cargo.currentVoyage())) {
40
+      if (voyage.sameAs(cargo.currentVoyage())) {
41
         onVoyage.add(cargo);
41
         onVoyage.add(cargo);
42
       }
42
       }
43
     }
43
     }