From: Roland Häder Date: Mon, 19 Mar 2018 21:59:06 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=debf158c89d83a8d9a3c1479222c50b0bc6d5b71;p=jcontacts-business-core.git Continued: - Objects.equals() is an overdose here, as a possible null-reference has already been checked before - CoreNumberUtils was a bad name, SafeNumberUtils is maybe better? Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java index 8537001..f2d83a3 100644 --- a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java +++ b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java @@ -203,11 +203,11 @@ public class BusinessBasicData implements BasicData { @Override public int compareTo (final BasicData basicData) { - // For performance reasons + // Check parameter on null-reference and equality to this if (null == basicData) { // Should not happen throw new NullPointerException("basicData is null"); //NOI18N - } else if (Objects.equals(this, basicData)) { + } else if (basicData.equals(this)) { // 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 e5e1877..d7c4ae6 100644 --- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java +++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java @@ -46,7 +46,7 @@ import org.mxchange.jcontactsbusiness.model.employee.Employees; import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcoreutils.Comparables; -import org.mxchange.jcoreutils.CoreNumberUtils; +import org.mxchange.jcoreutils.SafeNumberUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -294,11 +294,11 @@ public class BusinessBranchOffice implements BranchOffice { @Override public int compareTo (final BranchOffice branchOffice) { - // For performance reasons + // Check parameter on null-reference and equality to this if (null == branchOffice) { // Should not happen throw new NullPointerException("branchOffice is null"); //NOI18N - } else if (Objects.equals(this, branchOffice)) { + } else if (branchOffice.equals(this)) { // Same object return 0; } @@ -308,7 +308,7 @@ public class BusinessBranchOffice implements BranchOffice { // First compare basic data this.getBranchCompany().compareTo(branchOffice.getBranchCompany()), // ... branch office number - CoreNumberUtils.compare(this.getBranchNumber(), branchOffice.getBranchNumber()), + SafeNumberUtils.compare(this.getBranchNumber(), branchOffice.getBranchNumber()), // ... contact person Employees.compare(this.getBranchContactEmployee(), branchOffice.getBranchContactEmployee()), // ... then country @@ -322,13 +322,13 @@ public class BusinessBranchOffice implements BranchOffice { // ... and house number this.getBranchHouseNumber().compareTo(branchOffice.getBranchHouseNumber()), // ... and house number - CoreNumberUtils.compare(this.getBranchLastHouseNumber(), branchOffice.getBranchLastHouseNumber()), + SafeNumberUtils.compare(this.getBranchLastHouseNumber(), branchOffice.getBranchLastHouseNumber()), // ... and extension StringUtils.compareIgnoreCase(this.getBranchHouseNumberExtension(), branchOffice.getBranchHouseNumberExtension()), // ... store ... - CoreNumberUtils.compare(this.getBranchStore(), branchOffice.getBranchStore()), + SafeNumberUtils.compare(this.getBranchStore(), branchOffice.getBranchStore()), // ... suite number ... - CoreNumberUtils.compare(this.getBranchSuiteNumber(), branchOffice.getBranchSuiteNumber()) + SafeNumberUtils.compare(this.getBranchSuiteNumber(), branchOffice.getBranchSuiteNumber()) }; // Check all values diff --git a/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java b/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java index ce7d515..b41bf9d 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java @@ -162,11 +162,11 @@ public class BusinessDepartment implements Department { @Override public int compareTo (final Department department) { - // For performance reasons + // Check parameter on null-reference and equality to this if (null == department) { // Should not happen throw new NullPointerException("department is null"); //NOI18N - } else if (Objects.equals(this, department)) { + } else if (department.equals(this)) { // Same object return 0; } diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java index 63b3257..4d4da0a 100644 --- a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java @@ -202,11 +202,11 @@ public class BusinessEmployee implements Employable { @Override public int compareTo (final Employable employable) { - // For performance reasons + // Check parameter on null-reference and equality to this if (null == employable) { // Should not happen throw new NullPointerException("employable is null"); //NOI18N - } else if (Objects.equals(this, employable)) { + } else if (employable.equals(this)) { // Same object return 0; } diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java index e4ed13b..7a546ae 100644 --- a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java @@ -43,7 +43,7 @@ import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcoreutils.Comparables; -import org.mxchange.jcoreutils.CoreNumberUtils; +import org.mxchange.jcoreutils.SafeNumberUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -272,11 +272,11 @@ public class BusinessHeadquarter implements Headquarter { @Override public int compareTo (final Headquarter headquarter) { - // For performance reasons + // Check parameter on null-reference and equality to this if (null == headquarter) { // Should not happen throw new NullPointerException("headquarter is null"); //NOI18N - } else if (Objects.equals(this, headquarter)) { + } else if (headquarter.equals(this)) { // Same object return 0; } @@ -288,21 +288,21 @@ public class BusinessHeadquarter implements Headquarter { // ... next country this.getHeadquarterCountry().compareTo(headquarter.getHeadquarterCountry()), // ... then ZIP code - CoreNumberUtils.compare(this.getHeadquarterZipCode(), headquarter.getHeadquarterZipCode()), + SafeNumberUtils.compare(this.getHeadquarterZipCode(), headquarter.getHeadquarterZipCode()), // ... and city this.getHeadquarterCity().compareTo(headquarter.getHeadquarterCity()), // ... street name StringUtils.compareIgnoreCase(this.getHeadquarterStreet(), headquarter.getHeadquarterStreet()), // ... house number - CoreNumberUtils.compare(this.getHeadquarterHouseNumber(), headquarter.getHeadquarterHouseNumber()), + SafeNumberUtils.compare(this.getHeadquarterHouseNumber(), headquarter.getHeadquarterHouseNumber()), // ... last house number - CoreNumberUtils.compare(this.getHeadquarterLastHouseNumber(), headquarter.getHeadquarterLastHouseNumber()), + SafeNumberUtils.compare(this.getHeadquarterLastHouseNumber(), headquarter.getHeadquarterLastHouseNumber()), // ... extension StringUtils.compareIgnoreCase(this.getHeadquarterHouseNumberExtension(), headquarter.getHeadquarterHouseNumberExtension()), // ... store number - CoreNumberUtils.compare(this.getHeadquarterStore(), headquarter.getHeadquarterStore()), + SafeNumberUtils.compare(this.getHeadquarterStore(), headquarter.getHeadquarterStore()), // ... suite number - CoreNumberUtils.compare(this.getHeadquarterSuiteNumber(), headquarter.getHeadquarterSuiteNumber()), + SafeNumberUtils.compare(this.getHeadquarterSuiteNumber(), headquarter.getHeadquarterSuiteNumber()), // ... last email address StringUtils.compareIgnoreCase(this.getHeadquarterEmailAddress(), headquarter.getHeadquarterEmailAddress()) }; diff --git a/src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java b/src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java index c4b06c3..7c6e933 100644 --- a/src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java +++ b/src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java @@ -80,11 +80,11 @@ public class EmployeePosition implements JobPosition { @Override public int compareTo (final JobPosition jobPosition) { - // For performance reasons + // Check parameter on null-reference and equality to this if (null == jobPosition) { // Should not happen throw new NullPointerException("jobPosition is null"); //NOI18N - } else if (Objects.equals(this, jobPosition)) { + } else if (jobPosition.equals(this)) { // Same object return 0; } diff --git a/src/org/mxchange/jcontactsbusiness/model/logo/BusinessLogo.java b/src/org/mxchange/jcontactsbusiness/model/logo/BusinessLogo.java index 1b3cc9e..6dba172 100644 --- a/src/org/mxchange/jcontactsbusiness/model/logo/BusinessLogo.java +++ b/src/org/mxchange/jcontactsbusiness/model/logo/BusinessLogo.java @@ -83,11 +83,11 @@ public class BusinessLogo implements Logo { @Override public int compareTo (final Logo logo) { - // For performance reasons + // Check parameter on null-reference and equality to this if (null == logo) { // Should not happen throw new NullPointerException("logo is null"); //NOI18N - } else if (Objects.equals(this, logo)) { + } else if (logo.equals(this)) { // 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 16d0554..5c10af7 100644 --- a/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java +++ b/src/org/mxchange/jcontactsbusiness/model/opening_time/BusinessOpeningTime.java @@ -128,11 +128,11 @@ public class BusinessOpeningTime implements OpeningTime { @Override public int compareTo (final OpeningTime openingTime) { - // For performance reasons + // Check parameter on null-reference and equality to this if (null == openingTime) { // Should not happen throw new NullPointerException("openingTime is null"); //NOI18N - } else if (Objects.equals(this, openingTime)) { + } else if (openingTime.equals(this)) { // Same object return 0; }