Przeglądaj źródła

Eliminated redundant check in equals()

peter_backlund 18 lat temu
rodzic
commit
41cd04b081

+ 5
- 3
dddsample/src/main/java/se/citerus/dddsample/domain/model/location/Location.java Wyświetl plik

@@ -18,7 +18,9 @@ public final class Location implements Entity<Location> {
18 18
   /**
19 19
    * Special Location object that marks an unknown location.
20 20
    */
21
-  public static final Location UNKNOWN = new Location(new UnLocode("XXXXX"), "Unknown location");
21
+  public static final Location UNKNOWN = new Location(
22
+    new UnLocode("XXXXX"), "Unknown location"
23
+  );
22 24
 
23 25
   /**
24 26
    * Package-level constructor, visible for test only.
@@ -58,8 +60,8 @@ public final class Location implements Entity<Location> {
58 60
     if (object == null) {
59 61
       return false;
60 62
     }
61
-    if (this == UNKNOWN || object == UNKNOWN) {
62
-      return this == object;
63
+    if (this == object) {
64
+      return true;
63 65
     }
64 66
     if (!(object instanceof Location)) {
65 67
       return false;