From 60e3c86aaf4b1a7f05faf027d515a0eca7ce0975 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 6 Oct 2022 16:01:20 +0200 Subject: [PATCH] Continued: - use own *Utils' methods instead of direct invocation (null-safe) - used more Objects.equals() (yes, a bit silly here) --- .../model/basicdata/BusinessBasicData.java | 2 +- .../model/branchoffice/BusinessBranchOffice.java | 6 +++--- .../model/headquarter/BusinessHeadquarter.java | 5 +++-- .../mxchange/jcontactsbusiness/model/logo/BusinessLogo.java | 2 +- .../model/opening_time/BusinessOpeningTime.java | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java index dbd25c5..9eb4a4e 100644 --- a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java +++ b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java @@ -225,7 +225,7 @@ public class BusinessBasicData implements BasicData { if (null == basicData) { // Should not happen throw new NullPointerException("basicData is null"); //NOI18N - } else if (basicData.equals(this)) { + } else if (Objects.equals(this, basicData)) { // Same object return 0; } diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java index 66f9200..2beb8f2 100644 --- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java +++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java @@ -50,6 +50,7 @@ import org.mxchange.jcoreutils.Comparables; import org.mxchange.jcoreutils.SafeNumberUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; +import org.mxchange.jcountry.model.utils.CountryUtils; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; @@ -317,14 +318,13 @@ public class BusinessBranchOffice implements BranchOffice { if (null == branchOffice) { // Should not happen throw new NullPointerException("branchOffice is null"); //NOI18N - } else if (branchOffice.equals(this)) { + } else if (Objects.equals(this, branchOffice)) { // Same object return 0; } // Init comparisons final int[] comparators = { - // First compare basic data // First compare basic data this.getBranchCompany().compareTo(branchOffice.getBranchCompany()), // ... branch office number @@ -334,7 +334,7 @@ public class BusinessBranchOffice implements BranchOffice { // ... contact person ContactUtils.compare(this.getBranchContactEmployee(), branchOffice.getBranchContactEmployee()), // ... then country - this.getBranchCountry().compareTo(branchOffice.getBranchCountry()), + CountryUtils.compare(this.getBranchCountry(), branchOffice.getBranchCountry()), // ... next city this.getBranchCity().compareToIgnoreCase(branchOffice.getBranchCity()), // ... then ZIP code diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java index 36c8f20..7d90754 100644 --- a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java @@ -46,6 +46,7 @@ import org.mxchange.jcoreutils.Comparables; import org.mxchange.jcoreutils.SafeNumberUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; +import org.mxchange.jcountry.model.utils.CountryUtils; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; @@ -294,7 +295,7 @@ public class BusinessHeadquarter implements Headquarter { if (null == headquarter) { // Should not happen throw new NullPointerException("headquarter is null"); //NOI18N - } else if (headquarter.equals(this)) { + } else if (Objects.equals(this, headquarter)) { // Same object return 0; } @@ -304,7 +305,7 @@ public class BusinessHeadquarter implements Headquarter { // First check company name this.getHeadquarterCompanyName().compareTo(headquarter.getHeadquarterCompanyName()), // ... next country - this.getHeadquarterCountry().compareTo(headquarter.getHeadquarterCountry()), + CountryUtils.compare(this.getHeadquarterCountry(), headquarter.getHeadquarterCountry()), // ... then ZIP code SafeNumberUtils.compare(this.getHeadquarterZipCode(), headquarter.getHeadquarterZipCode()), // ... and city diff --git a/src/org/mxchange/jcontactsbusiness/model/logo/BusinessLogo.java b/src/org/mxchange/jcontactsbusiness/model/logo/BusinessLogo.java index ae98fde..ba49402 100644 --- a/src/org/mxchange/jcontactsbusiness/model/logo/BusinessLogo.java +++ b/src/org/mxchange/jcontactsbusiness/model/logo/BusinessLogo.java @@ -96,7 +96,7 @@ public class BusinessLogo implements Logo { if (null == logo) { // Should not happen throw new NullPointerException("logo is null"); //NOI18N - } else if (logo.equals(this)) { + } else if (Objects.equals(this, logo)) { // Same object return 0; } diff --git a/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java b/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java index 6720514..5b70ede 100644 --- a/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java +++ b/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java @@ -157,7 +157,7 @@ public class BusinessOpeningTime implements OpeningTime { if (null == openingTime) { // Should not happen throw new NullPointerException("openingTime is null"); //NOI18N - } else if (openingTime.equals(this)) { + } else if (Objects.equals(this, openingTime)) { // Same object return 0; } -- 2.39.5