From: Roland Häder Date: Sat, 12 Nov 2022 20:55:31 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2f9b9aac2f2cae5a27e23d0427644552bd3396b1;p=jphone-core.git Continued: - if both instances are null, this indicates a bad idea? --- diff --git a/src/org/mxchange/jphone/model/utils/FaxNumberUtils.java b/src/org/mxchange/jphone/model/utils/FaxNumberUtils.java index 25b63f4..8337de6 100644 --- a/src/org/mxchange/jphone/model/utils/FaxNumberUtils.java +++ b/src/org/mxchange/jphone/model/utils/FaxNumberUtils.java @@ -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; } diff --git a/src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java b/src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java index d7063ed..89fc25e 100644 --- a/src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java +++ b/src/org/mxchange/jphone/model/utils/LandLineNumberUtils.java @@ -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; }