- if both instances are null, this indicates a bad idea?
} 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;
}
} 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;
}