|
|
@@ -5,11 +5,10 @@ import org.apache.commons.lang.builder.EqualsBuilder;
|
|
5
|
5
|
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
6
|
6
|
|
|
7
|
7
|
/**
|
|
8
|
|
- * Identifies a particular cargo.
|
|
9
|
|
- * <p/>
|
|
10
|
|
- * Make sure to put a constraint in the database to make sure TrackingId is unique.
|
|
|
8
|
+ * Uniquely identifies a particular cargo. Automatically generated by the application.
|
|
|
9
|
+ *
|
|
11
|
10
|
*/
|
|
12
|
|
-public final class TrackingId {
|
|
|
11
|
+public final class TrackingId implements ValueObject<TrackingId> {
|
|
13
|
12
|
|
|
14
|
13
|
private String id;
|
|
15
|
14
|
|
|
|
@@ -31,8 +30,13 @@ public final class TrackingId {
|
|
31
|
30
|
}
|
|
32
|
31
|
|
|
33
|
32
|
@Override
|
|
34
|
|
- public boolean equals(final Object obj) {
|
|
35
|
|
- return EqualsBuilder.reflectionEquals(this, obj);
|
|
|
33
|
+ public boolean equals(Object o) {
|
|
|
34
|
+ if (this == o) return true;
|
|
|
35
|
+ if (o == null || getClass() != o.getClass()) return false;
|
|
|
36
|
+
|
|
|
37
|
+ TrackingId other = (TrackingId) o;
|
|
|
38
|
+
|
|
|
39
|
+ return sameValueAs(other);
|
|
36
|
40
|
}
|
|
37
|
41
|
|
|
38
|
42
|
@Override
|
|
|
@@ -40,9 +44,11 @@ public final class TrackingId {
|
|
40
|
44
|
return HashCodeBuilder.reflectionHashCode(this);
|
|
41
|
45
|
}
|
|
42
|
46
|
|
|
|
47
|
+ public boolean sameValueAs(TrackingId other) {
|
|
|
48
|
+ return other != null && EqualsBuilder.reflectionEquals(this, other);
|
|
|
49
|
+ }
|
|
43
|
50
|
|
|
44
|
51
|
TrackingId() {
|
|
45
|
52
|
// Needed by Hibernate
|
|
46
|
53
|
}
|
|
47
|
|
-
|
|
48
|
54
|
}
|