Просмотр исходного кода

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

peter_backlund 17 лет назад
Родитель
Сommit
370634a03f

+ 2
- 4
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Delivery.java Просмотреть файл

@@ -5,9 +5,7 @@ import org.apache.commons.lang.builder.EqualsBuilder;
5 5
 import org.apache.commons.lang.builder.HashCodeBuilder;
6 6
 import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.*;
7 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 9
 import se.citerus.dddsample.domain.model.location.Location;
12 10
 import se.citerus.dddsample.domain.model.shared.HandlingActivity;
13 11
 import se.citerus.dddsample.domain.model.voyage.Voyage;
@@ -95,7 +93,7 @@ public class Delivery implements ValueObject<Delivery> {
95 93
       return false;
96 94
     }
97 95
 
98
-    if (mostRecentHandlingActivity.type().sameValueAs(HandlingEvent.Type.CUSTOMS)) {
96
+    if (CUSTOMS.sameValueAs(mostRecentHandlingActivity.type())) {
99 97
       return !routeSpecification.destination().sameAs(mostRecentHandlingActivity.location());
100 98
     } else {
101 99
       return !itinerary.isExpected(mostRecentHandlingActivity);

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/model/handling/HandlingHistory.java Просмотреть файл

@@ -43,7 +43,7 @@ public class HandlingHistory implements ValueObject<HandlingHistory> {
43 43
 
44 44
     while (it.hasNext()) {
45 45
       final Cargo nextCargo = it.next().cargo();
46
-      Validate.isTrue(firstCargo.sameIdentityAs(nextCargo),
46
+      Validate.isTrue(firstCargo.sameAs(nextCargo),
47 47
         "A handling history can only contain handling events for a unique cargo. " +
48 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,7 +108,7 @@ public class CustomsZone implements Entity<CustomsZone> {
108 108
   }
109 109
 
110 110
   @Override
111
-  public boolean sameIdentityAs(CustomsZone other) {
111
+  public boolean sameAs(CustomsZone other) {
112 112
     return code.equals(other.code);
113 113
   }
114 114
 
@@ -117,7 +117,7 @@ public class CustomsZone implements Entity<CustomsZone> {
117 117
   }
118 118
 
119 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,11 +83,11 @@ public final class Location implements Entity<Location> {
83 83
       return false;
84 84
     }
85 85
     Location other = (Location) object;
86
-    return sameIdentityAs(other);
86
+    return sameAs(other);
87 87
   }
88 88
 
89 89
   @Override
90
-  public boolean sameIdentityAs(final Location other) {
90
+  public boolean sameAs(final Location other) {
91 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,7 +39,7 @@ public class Schedule implements ValueObject<Schedule> {
39 39
    */
40 40
   public Date departureTimeAt(final Location location) {
41 41
     for (CarrierMovement movement : carrierMovements) {
42
-      if (movement.departureLocation().sameIdentityAs(location)) {
42
+      if (movement.departureLocation().sameAs(location)) {
43 43
         return movement.departureTime();
44 44
       }
45 45
     }
@@ -52,7 +52,7 @@ public class Schedule implements ValueObject<Schedule> {
52 52
    */
53 53
   public Date arrivalTimeAt(final Location location) {
54 54
     for (CarrierMovement movement : carrierMovements) {
55
-      if (movement.arrivalLocation().sameIdentityAs(location)) {
55
+      if (movement.arrivalLocation().sameAs(location)) {
56 56
         return movement.arrivalTime();
57 57
       }
58 58
     }

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CargoRepositoryTest.java Просмотреть файл

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

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/infrastructure/persistence/inmemory/CargoRepositoryInMem.java Просмотреть файл

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