Pārlūkot izejas kodu

Improved a few sameValueAs/sameIdentityAs, added some TODOS for stuff to remove after branching off 1.0

peter_backlund 18 gadus atpakaļ
vecāks
revīzija
ef45a376f9

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Cargo.java Parādīt failu

@@ -190,7 +190,7 @@ public final class Cargo implements Entity<Cargo> {
190 190
   }
191 191
 
192 192
   public boolean sameIdentityAs(final Cargo other) {
193
-    return other != null && trackingId.equals(other.trackingId);
193
+    return other != null && trackingId.sameValueAs(other.trackingId);
194 194
   }
195 195
 
196 196
   /**

+ 4
- 0
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/CargoRepository.java Parādīt failu

@@ -27,6 +27,10 @@ public interface CargoRepository {
27 27
   void save(Cargo cargo);
28 28
 
29 29
   /**
30
+   * TODO
31
+   * this is too complex a procedure to belong in the repository -
32
+   * introduce a TrackingIdFactory (or perhaps a CargoFactory).
33
+   *
30 34
    * @return A new generated tracking Id.
31 35
    */
32 36
   TrackingId nextTrackingId();

+ 2
- 4
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/TrackingId.java Parādīt failu

@@ -1,8 +1,6 @@
1 1
 package se.citerus.dddsample.domain.model.cargo;
2 2
 
3 3
 import org.apache.commons.lang.Validate;
4
-import org.apache.commons.lang.builder.EqualsBuilder;
5
-import org.apache.commons.lang.builder.HashCodeBuilder;
6 4
 import se.citerus.dddsample.domain.model.ValueObject;
7 5
 
8 6
 /**
@@ -42,11 +40,11 @@ public final class TrackingId implements ValueObject<TrackingId> {
42 40
 
43 41
   @Override
44 42
   public int hashCode() {
45
-    return HashCodeBuilder.reflectionHashCode(this);
43
+    return id.hashCode();
46 44
   }
47 45
 
48 46
   public boolean sameValueAs(TrackingId other) {
49
-    return other != null && EqualsBuilder.reflectionEquals(this, other);
47
+    return other != null && this.id.equals(other.id);
50 48
   }
51 49
 
52 50
   TrackingId() {

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/model/carrier/CarrierMovement.java Parādīt failu

@@ -41,7 +41,7 @@ public final class CarrierMovement implements Entity<CarrierMovement> {
41 41
   }
42 42
 
43 43
   public boolean sameIdentityAs(final CarrierMovement other) {
44
-    return carrierMovementId.equals(other.carrierMovementId);
44
+    return carrierMovementId.sameValueAs(other.carrierMovementId);
45 45
   }
46 46
 
47 47
   @Override

+ 2
- 0
dddsample/src/main/java/se/citerus/dddsample/domain/model/handling/HandlingEventRepository.java Parādīt failu

@@ -16,6 +16,8 @@ public interface HandlingEventRepository {
16 16
    */
17 17
   void save(final HandlingEvent event);
18 18
 
19
+
20
+  // TODO: remove this in 1.0 branch, it's not used anywhere
19 21
   /**
20 22
    * @param trackingId cargo tracking id
21 23
    * @return All handling events for this cargo, ordered by completion time.

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/model/location/Location.java Parādīt failu

@@ -69,7 +69,7 @@ public final class Location implements Entity<Location> {
69 69
   }
70 70
 
71 71
   public boolean sameIdentityAs(final Location other) {
72
-    return this.unLocode.equals(other.unLocode);
72
+    return this.unLocode.sameValueAs(other.unLocode);
73 73
   }
74 74
 
75 75
   /**