From 7c863773b16a08b4782a499972a8d0280e38f70e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 18 Mar 2018 22:47:10 +0100 Subject: [PATCH] Continued: - used new NumberUtils class for null-safe comparison MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/branchoffice/BranchOffices.java | 2 +- .../model/branchoffice/BusinessBranchOffice.java | 11 ++++++----- .../model/department/Departments.java | 2 +- .../model/headquarter/BusinessHeadquarter.java | 11 ++++++----- .../model/headquarter/Headquarters.java | 2 +- .../model/jobposition/JobPositions.java | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffices.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffices.java index 7054e4b..1227526 100644 --- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffices.java +++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffices.java @@ -52,7 +52,7 @@ public class BranchOffices implements Serializable { throw new NullPointerException("branchOffice1 is null"); //NOI18N } else if (null == branchOffice2) { // Second is null - return -1; + return 1; } // Invoke compareTo() method diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java index 9619c54..7f3c91a 100644 --- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java +++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java @@ -44,6 +44,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.jcoreee.utils.Comparables; +import org.mxchange.jcoreee.utils.NumberUtils; import org.mxchange.jcoreee.utils.StringUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; @@ -302,9 +303,9 @@ public class BusinessBranchOffice implements BranchOffice { // Init comparisons final int[] comparators = { // A different branch number is a clear indication ... - Long.compare(this.getBranchNumber(), branchOffice.getBranchNumber()), + NumberUtils.compare(this.getBranchNumber(), branchOffice.getBranchNumber()), // ... same with id ... - Long.compare(this.getBranchId(), branchOffice.getBranchId()), + NumberUtils.compare(this.getBranchId(), branchOffice.getBranchId()), // ... then country this.getBranchCountry().compareTo(branchOffice.getBranchCountry()), // ... next city @@ -316,13 +317,13 @@ public class BusinessBranchOffice implements BranchOffice { // ... and house number this.getBranchHouseNumber().compareTo(branchOffice.getBranchHouseNumber()), // ... and house number - Short.compare(this.getBranchLastHouseNumber(), branchOffice.getBranchLastHouseNumber()), + NumberUtils.compare(this.getBranchLastHouseNumber(), branchOffice.getBranchLastHouseNumber()), // ... and extension StringUtils.compareToIgnoreCase(this.getBranchHouseNumberExtension(), branchOffice.getBranchHouseNumberExtension()), // ... store ... - Short.compare(this.getBranchStore(), branchOffice.getBranchStore()), + NumberUtils.compare(this.getBranchStore(), branchOffice.getBranchStore()), // ... suite number ... - Short.compare(this.getBranchSuiteNumber(), branchOffice.getBranchSuiteNumber()) + NumberUtils.compare(this.getBranchSuiteNumber(), branchOffice.getBranchSuiteNumber()) }; // Check all values diff --git a/src/org/mxchange/jcontactsbusiness/model/department/Departments.java b/src/org/mxchange/jcontactsbusiness/model/department/Departments.java index 7786af3..7aa9a86 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/Departments.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/Departments.java @@ -55,7 +55,7 @@ public class Departments implements Serializable { throw new NullPointerException("department1 is null"); //NOI18N } else if (null == department2) { // Second is null - return -1; + return 1; } // Invoke compareTo() method diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java index 6391d47..04e225a 100644 --- a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java @@ -42,6 +42,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.jcoreee.utils.Comparables; +import org.mxchange.jcoreee.utils.NumberUtils; import org.mxchange.jcoreee.utils.StringUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; @@ -287,21 +288,21 @@ public class BusinessHeadquarter implements Headquarter { // ... next country this.getHeadquarterCountry().compareTo(headquarter.getHeadquarterCountry()), // ... then ZIP code - Integer.compare(this.getHeadquarterZipCode(), headquarter.getHeadquarterZipCode()), + NumberUtils.compare(this.getHeadquarterZipCode(), headquarter.getHeadquarterZipCode()), // ... and city this.getHeadquarterCity().compareTo(headquarter.getHeadquarterCity()), // ... street name StringUtils.compareToIgnoreCase(this.getHeadquarterStreet(), headquarter.getHeadquarterStreet()), // ... house number - Integer.compare(this.getHeadquarterHouseNumber(), headquarter.getHeadquarterHouseNumber()), + NumberUtils.compare(this.getHeadquarterHouseNumber(), headquarter.getHeadquarterHouseNumber()), // ... last house number - Integer.compare(this.getHeadquarterLastHouseNumber(), headquarter.getHeadquarterLastHouseNumber()), + NumberUtils.compare(this.getHeadquarterLastHouseNumber(), headquarter.getHeadquarterLastHouseNumber()), // ... extension StringUtils.compareToIgnoreCase(this.getHeadquarterHouseNumberExtension(), headquarter.getHeadquarterHouseNumberExtension()), // ... store number - Integer.compare(this.getHeadquarterStore(), headquarter.getHeadquarterStore()), + NumberUtils.compare(this.getHeadquarterStore(), headquarter.getHeadquarterStore()), // ... suite number - Integer.compare(this.getHeadquarterSuiteNumber(), headquarter.getHeadquarterSuiteNumber()), + NumberUtils.compare(this.getHeadquarterSuiteNumber(), headquarter.getHeadquarterSuiteNumber()), // ... last email address StringUtils.compareToIgnoreCase(this.getHeadquarterEmailAddress(), headquarter.getHeadquarterEmailAddress()) }; diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarters.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarters.java index 2d847b9..598290f 100644 --- a/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarters.java +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarters.java @@ -51,7 +51,7 @@ public class Headquarters implements Serializable { throw new NullPointerException("headquarter1 is null"); //NOI18N } else if (null == headquarter2) { // Second headquarter is null - return -1; + return 1; } // Now that both are not NULL, compare them diff --git a/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPositions.java b/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPositions.java index b94b6f2..1b523a9 100644 --- a/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPositions.java +++ b/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPositions.java @@ -52,7 +52,7 @@ public class JobPositions implements Serializable { throw new NullPointerException("jobPosition1 is null"); //NOI18N } else if (null == jobPosition2) { // Second is null - return -1; + return 1; } // Invoke compareTo() method -- 2.39.5