From: Roland Häder Date: Thu, 6 Oct 2022 14:04:38 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=061015f94ca8397549fb0f32f45f76d8db5203bc;p=jphone-core.git Continued: - Objects.equals() might be a small overdoze here ... --- diff --git a/src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumber.java b/src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumber.java index 4f39bcd..fdb6c0b 100644 --- a/src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumber.java +++ b/src/org/mxchange/jphone/model/phonenumbers/landline/LandLineNumber.java @@ -151,12 +151,12 @@ public class LandLineNumber implements DialableLandLineNumber { } @Override - public int compareTo (final DialableLandLineNumber otherNumber) { + public int compareTo (final DialableLandLineNumber landLineNumber) { // Is the parameter given? - if (null == otherNumber) { + if (null == landLineNumber) { // Throw NPE - throw new NullPointerException("otherNumber is null"); //NOI18N - } else if (otherNumber.equals(this)) { + throw new NullPointerException("Parameter 'landLineNumber' is null"); //NOI18N + } else if (Objects.equals(this, landLineNumber)) { // Same object return 0; } @@ -164,11 +164,11 @@ public class LandLineNumber implements DialableLandLineNumber { // Init comparisons final int[] comparators = { // First country - this.getPhoneCountry().compareTo(otherNumber.getPhoneCountry()), + this.getPhoneCountry().compareTo(landLineNumber.getPhoneCountry()), // Next area code - this.getPhoneAreaCode().compareTo(otherNumber.getPhoneAreaCode()), + this.getPhoneAreaCode().compareTo(landLineNumber.getPhoneAreaCode()), // Last number - this.getPhoneNumber().compareTo(otherNumber.getPhoneNumber()) + this.getPhoneNumber().compareTo(landLineNumber.getPhoneNumber()) }; // Check all values diff --git a/src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumber.java b/src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumber.java index eb369b6..acd7b4a 100644 --- a/src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumber.java +++ b/src/org/mxchange/jphone/model/phonenumbers/mobile/MobileNumber.java @@ -138,12 +138,12 @@ public class MobileNumber implements DialableMobileNumber { } @Override - public int compareTo (final DialableMobileNumber otherNumber) { + public int compareTo (final DialableMobileNumber mobileNumber) { // Is the parameter given? - if (null == otherNumber) { + if (null == mobileNumber) { // Throw NPE - throw new NullPointerException("otherNumber is null"); //NOI18N - } else if (otherNumber.equals(this)) { + throw new NullPointerException("Paramegter 'mobileNumber' is null"); //NOI18N + } else if (Objects.equals(this, mobileNumber)) { // Same object return 0; } @@ -151,9 +151,9 @@ public class MobileNumber implements DialableMobileNumber { // Init comparisons final int[] comparators = { // First compare provider - MobileProviderUtils.compare(this.getMobileProvider(), otherNumber.getMobileProvider()), + MobileProviderUtils.compare(this.getMobileProvider(), mobileNumber.getMobileProvider()), // Last number - SafeNumberUtils.compare(this.getMobileNumber(), otherNumber.getMobileNumber()) + SafeNumberUtils.compare(this.getMobileNumber(), mobileNumber.getMobileNumber()) }; // Check all values diff --git a/src/org/mxchange/jphone/model/phonenumbers/mobileprovider/CellphoneProvider.java b/src/org/mxchange/jphone/model/phonenumbers/mobileprovider/CellphoneProvider.java index e58d2d7..803b368 100644 --- a/src/org/mxchange/jphone/model/phonenumbers/mobileprovider/CellphoneProvider.java +++ b/src/org/mxchange/jphone/model/phonenumbers/mobileprovider/CellphoneProvider.java @@ -171,7 +171,7 @@ public class CellphoneProvider implements MobileProvider { if (null == provider) { // Throw NPE throw new NullPointerException("Parameter 'provider' is null"); //NOI18N - } else if (provider.equals(this)) { + } else if (Objects.equals(this, provider)) { // Same object return 0; }