]> git.mxchange.org Git - jphone-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 12 Nov 2022 20:55:31 +0000 (21:55 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 12 Nov 2022 20:55:31 +0000 (21:55 +0100)
- if both instances are null, this indicates a bad idea?

src/org/mxchange/jphone/model/utils/FaxNumberUtils.java
src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java

index 25b63f480f4fa2123e3e26faf505be6762ecf88e..8337de61006d45cf7ac52652a2461a78c6a71dba 100644 (file)
@@ -74,11 +74,16 @@ public class FaxNumberUtils implements Serializable {
                } else if (((null == faxNumber) && (otherNumber instanceof DialableFaxNumber)) || ((null == otherNumber) && (faxNumber instanceof DialableFaxNumber))) {
                        // One is null the other not
                        return false;
+               } else if (null == faxNumber && null == otherNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("Both faxNumber and otherNumber are null"); //NOI18N
                }
+
                // Now compare deeper
                final boolean sameCountry = Objects.equals(faxNumber.getPhoneCountry(), otherNumber.getPhoneCountry());
                final boolean sameAreaCode = Objects.equals(faxNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());
                final boolean sameNumber = Objects.equals(faxNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
+
                // All are the same?
                return sameCountry && sameAreaCode && sameNumber;
        }
index d7063ed315b7d54ab72025cc151ca484ba743b44..89fc25ec4fa9521643e426f62c4e8e4cdf9077d6 100644 (file)
@@ -74,11 +74,16 @@ public class LandLineNumberUtils implements Serializable {
                } else if (((null == landLineNumber) && (otherNumber instanceof DialableLandLineNumber)) || ((null == otherNumber) && (landLineNumber instanceof DialableLandLineNumber))) {
                        // One is null the other not
                        return false;
+               } else if (null == landLineNumber && null == otherNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("Both landLineNumber and otherNumber are null"); //NOI18N
                }
+
                // Now compare deeper
                final boolean sameCountry = Objects.equals(landLineNumber.getPhoneCountry(), otherNumber.getPhoneCountry());
                final boolean sameAreaCode = Objects.equals(landLineNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode());
                final boolean sameNumber = Objects.equals(landLineNumber.getPhoneNumber(), otherNumber.getPhoneNumber());
+
                // All are the same?
                return sameCountry && sameAreaCode && sameNumber;
        }