]> git.mxchange.org Git - jphone-core.git/commitdiff
Always include primary key (id number) in equal() method
authorRoland Häder <roland@mxchange.org>
Tue, 23 Aug 2016 14:07:56 +0000 (16:07 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 23 Aug 2016 14:07:56 +0000 (16:07 +0200)
src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java
src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java
src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java

index 9d7bcdaf02c10f991b1b2979ed44d54d6cd9a674..e9774de0affcf6873601956088422f9f6dce9d17 100644 (file)
@@ -147,6 +147,8 @@ public class FaxNumber implements DialableFaxNumber {
 
                if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) {
                        return false;
+               } else if (!Objects.equals(this.getPhoneId(), other.getPhoneId())) {
+                       return false;
                } else if (!Objects.equals(this.getPhoneAreaCode(), other.getPhoneAreaCode())) {
                        return false;
                } else if (!Objects.equals(this.getPhoneCountry(), other.getPhoneCountry())) {
@@ -156,15 +158,6 @@ public class FaxNumber implements DialableFaxNumber {
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 3;
-               hash = 23 * hash + Objects.hashCode(this.getPhoneNumber());
-               hash = 23 * hash + Objects.hashCode(this.getPhoneAreaCode());
-               hash = 23 * hash + Objects.hashCode(this.getPhoneCountry());
-               return hash;
-       }
-
        @Override
        public Integer getPhoneAreaCode () {
                return this.faxAreaCode;
@@ -229,4 +222,16 @@ public class FaxNumber implements DialableFaxNumber {
                this.phoneNumber = phoneNumber;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 3;
+
+               hash = 23 * hash + Objects.hashCode(this.getPhoneId());
+               hash = 23 * hash + Objects.hashCode(this.getPhoneNumber());
+               hash = 23 * hash + Objects.hashCode(this.getPhoneAreaCode());
+               hash = 23 * hash + Objects.hashCode(this.getPhoneCountry());
+
+               return hash;
+       }
+
 }
index df183505b9a0ddb353cc4da16041fc3564c82f6a..7411cf5894eceea4ecad2ac7bb721d787e1924b8 100644 (file)
@@ -145,7 +145,9 @@ public class LandLineNumber implements DialableLandLineNumber {
 
                final DialableLandLineNumber other = (DialableLandLineNumber) object;
 
-               if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) {
+               if (!Objects.equals(this.getPhoneId(), other.getPhoneId())) {
+                       return false;
+               } else if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) {
                        return false;
                } else if (!Objects.equals(this.getPhoneAreaCode(), other.getPhoneAreaCode())) {
                        return false;
@@ -224,6 +226,7 @@ public class LandLineNumber implements DialableLandLineNumber {
        public int hashCode () {
                int hash = 7;
 
+               hash = 47 * hash + Objects.hashCode(this.getPhoneId());
                hash = 47 * hash + Objects.hashCode(this.getPhoneNumber());
                hash = 47 * hash + Objects.hashCode(this.getPhoneAreaCode());
                hash = 47 * hash + Objects.hashCode(this.getPhoneCountry());
index 4f33f9904f573c8d0c70f91486e78ffc55e4d7a3..ac2a0c2b1c91f9e1603959f68c464655b6a19422 100644 (file)
@@ -136,7 +136,9 @@ public class MobileNumber implements DialableMobileNumber {
 
                final DialableMobileNumber other = (DialableMobileNumber) object;
 
-               if (!Objects.equals(this.getMobileProvider(), other.getMobileProvider())) {
+               if (!Objects.equals(this.getPhoneId(), other.getPhoneId())) {
+                       return false;
+               } else if (!Objects.equals(this.getMobileProvider(), other.getMobileProvider())) {
                        return false;
                } else if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) {
                        return false;
@@ -227,6 +229,7 @@ public class MobileNumber implements DialableMobileNumber {
        public int hashCode () {
                int hash = 5;
 
+               hash = 97 * hash + Objects.hashCode(this.getPhoneId());
                hash = 97 * hash + Objects.hashCode(this.getMobileProvider());
                hash = 97 * hash + Objects.hashCode(this.getPhoneNumber());