From 8376a80aef841f2a0ca0a89d85c625d2b794a59c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 19 Mar 2018 00:35:01 +0100 Subject: [PATCH] Continued: - added new depdendency Apache Commons Lang3 - used their StringUtils class for null-safe comparisons - but their NumberUtils class' compare() methods are not null-safe, so have to take own CoreNumberUtils class instead. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- lib/nblibraries.properties | 5 +++++ nbproject/project.properties | 1 + .../model/basicdata/BusinessBasicData.java | 6 +++--- .../branchoffice/BusinessBranchOffice.java | 18 +++++++++-------- .../model/employee/BusinessEmployee.java | 6 +++--- .../headquarter/BusinessHeadquarter.java | 20 +++++++++---------- 6 files changed, 32 insertions(+), 24 deletions(-) diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties index 8d00141..679f576 100644 --- a/lib/nblibraries.properties +++ b/lib/nblibraries.properties @@ -1,3 +1,8 @@ +libs.commons-lang3.classpath=\ + ${base}/commons-lang3/commons-lang3-3.5.jar +libs.commons-lang3.displayName=Commons Lang3 3.5 +libs.commons-lang3.javadoc=\ + https://commons.apache.org/proper/commons-lang/javadocs/api-release/ libs.CopyLibs.classpath=\ ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar libs.CopyLibs.displayName=CopyLibs Task diff --git a/nbproject/project.properties b/nbproject/project.properties index f07f0a8..a189763 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -45,6 +45,7 @@ javac.classpath=\ ${file.reference.jphone-core.jar}:\ ${file.reference.juser-core.jar}:\ ${file.reference.jcoreee.jar}:\ + ${libs.commons-lang3.classpath}:\ ${libs.jpa20-persistence.classpath} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked -Xlint:deprecation diff --git a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java index 1efd780..ec5415b 100644 --- a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java +++ b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java @@ -35,6 +35,7 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.commons.lang3.StringUtils; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; import org.mxchange.jcontactsbusiness.model.employee.Employable; @@ -44,7 +45,6 @@ import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters; import org.mxchange.jcontactsbusiness.model.logo.BusinessLogo; import org.mxchange.jcontactsbusiness.model.logo.Logo; import org.mxchange.jcoreee.utils.Comparables; -import org.mxchange.jcoreee.utils.StringUtils; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; @@ -217,9 +217,9 @@ public class BusinessBasicData implements BasicData { // First compare company name this.getCompanyName().compareToIgnoreCase(basicData.getCompanyName()), // ... next tax number - StringUtils.compareToIgnoreCase(this.getCompanyTaxNumber(), basicData.getCompanyTaxNumber()), + StringUtils.compareIgnoreCase(this.getCompanyTaxNumber(), basicData.getCompanyTaxNumber()), // ... and email address - StringUtils.compareToIgnoreCase(this.getCompanyEmailAddress(), basicData.getCompanyEmailAddress()), + StringUtils.compareIgnoreCase(this.getCompanyEmailAddress(), basicData.getCompanyEmailAddress()), // ... head quarter data Headquarters.compare(this.getCompanyHeadquarterData(), basicData.getCompanyHeadquarterData()) }; diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java index 12815f0..79b76c7 100644 --- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java +++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java @@ -37,6 +37,7 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.commons.lang3.StringUtils; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; @@ -45,8 +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.jcoreee.utils.Comparables; -import org.mxchange.jcoreee.utils.NumberUtils; -import org.mxchange.jcoreee.utils.StringUtils; +import org.mxchange.jcoreee.utils.CoreNumberUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -169,7 +169,9 @@ public class BusinessBranchOffice implements BranchOffice { /** * Opening times for this branch office */ - @JoinTable (name = "branch_opening_times", joinColumns = @JoinColumn(name = "branch_opening_id", referencedColumnName = "branch_id"), inverseJoinColumns = @JoinColumn(name = "opening_branch_id", referencedColumnName = "opening_times_id")) + @JoinTable (name = "branch_opening_times", joinColumns = + @JoinColumn (name = "branch_opening_id", referencedColumnName = "branch_id"), inverseJoinColumns = + @JoinColumn (name = "opening_branch_id", referencedColumnName = "opening_times_id")) @ManyToMany (targetEntity = BusinessOpeningTime.class, cascade = CascadeType.ALL) private List branchOpeningTimes; @@ -306,7 +308,7 @@ public class BusinessBranchOffice implements BranchOffice { // First compare basic data this.getBranchCompany().compareTo(branchOffice.getBranchCompany()), // ... branch office number - NumberUtils.compare(this.getBranchNumber(), branchOffice.getBranchNumber()), + CoreNumberUtils.compare(this.getBranchNumber(), branchOffice.getBranchNumber()), // ... contact person Employees.compare(this.getBranchContactEmployee(), branchOffice.getBranchContactEmployee()), // ... then country @@ -320,13 +322,13 @@ public class BusinessBranchOffice implements BranchOffice { // ... and house number this.getBranchHouseNumber().compareTo(branchOffice.getBranchHouseNumber()), // ... and house number - NumberUtils.compare(this.getBranchLastHouseNumber(), branchOffice.getBranchLastHouseNumber()), + CoreNumberUtils.compare(this.getBranchLastHouseNumber(), branchOffice.getBranchLastHouseNumber()), // ... and extension - StringUtils.compareToIgnoreCase(this.getBranchHouseNumberExtension(), branchOffice.getBranchHouseNumberExtension()), + StringUtils.compareIgnoreCase(this.getBranchHouseNumberExtension(), branchOffice.getBranchHouseNumberExtension()), // ... store ... - NumberUtils.compare(this.getBranchStore(), branchOffice.getBranchStore()), + CoreNumberUtils.compare(this.getBranchStore(), branchOffice.getBranchStore()), // ... suite number ... - NumberUtils.compare(this.getBranchSuiteNumber(), branchOffice.getBranchSuiteNumber()) + CoreNumberUtils.compare(this.getBranchSuiteNumber(), branchOffice.getBranchSuiteNumber()) }; // Check all values diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java index cf87e93..b0e34a7 100644 --- a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java @@ -33,6 +33,7 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.commons.lang3.StringUtils; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.Contacts; import org.mxchange.jcontacts.model.contact.UserContact; @@ -51,7 +52,6 @@ import org.mxchange.jcontactsbusiness.model.jobposition.EmployeePosition; import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; import org.mxchange.jcontactsbusiness.model.jobposition.JobPositions; import org.mxchange.jcoreee.utils.Comparables; -import org.mxchange.jcoreee.utils.StringUtils; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber; import org.mxchange.jusercore.model.user.LoginUser; @@ -224,9 +224,9 @@ public class BusinessEmployee implements Employable { // ... job position JobPositions.compare(this.getEmployeeJobPosition(), employable.getEmployeeJobPosition()), // ... employee's number - StringUtils.compareToIgnoreCase(this.getEmployeeNumber(), employable.getEmployeeNumber()), + StringUtils.compareIgnoreCase(this.getEmployeeNumber(), employable.getEmployeeNumber()), // ... employee's email address - StringUtils.compareToIgnoreCase(this.getEmployeeEmailAddress(), employable.getEmployeeEmailAddress()), + StringUtils.compareIgnoreCase(this.getEmployeeEmailAddress(), employable.getEmployeeEmailAddress()), // ... finally contact data Contacts.compare(this.getEmployeePersonalData(), employable.getEmployeePersonalData()) }; diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java index 04e225a..21f36cf 100644 --- a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java @@ -37,13 +37,13 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.commons.lang3.StringUtils; import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; 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.jcoreee.utils.CoreNumberUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -288,23 +288,23 @@ public class BusinessHeadquarter implements Headquarter { // ... next country this.getHeadquarterCountry().compareTo(headquarter.getHeadquarterCountry()), // ... then ZIP code - NumberUtils.compare(this.getHeadquarterZipCode(), headquarter.getHeadquarterZipCode()), + CoreNumberUtils.compare(this.getHeadquarterZipCode(), headquarter.getHeadquarterZipCode()), // ... and city this.getHeadquarterCity().compareTo(headquarter.getHeadquarterCity()), // ... street name - StringUtils.compareToIgnoreCase(this.getHeadquarterStreet(), headquarter.getHeadquarterStreet()), + StringUtils.compareIgnoreCase(this.getHeadquarterStreet(), headquarter.getHeadquarterStreet()), // ... house number - NumberUtils.compare(this.getHeadquarterHouseNumber(), headquarter.getHeadquarterHouseNumber()), + CoreNumberUtils.compare(this.getHeadquarterHouseNumber(), headquarter.getHeadquarterHouseNumber()), // ... last house number - NumberUtils.compare(this.getHeadquarterLastHouseNumber(), headquarter.getHeadquarterLastHouseNumber()), + CoreNumberUtils.compare(this.getHeadquarterLastHouseNumber(), headquarter.getHeadquarterLastHouseNumber()), // ... extension - StringUtils.compareToIgnoreCase(this.getHeadquarterHouseNumberExtension(), headquarter.getHeadquarterHouseNumberExtension()), + StringUtils.compareIgnoreCase(this.getHeadquarterHouseNumberExtension(), headquarter.getHeadquarterHouseNumberExtension()), // ... store number - NumberUtils.compare(this.getHeadquarterStore(), headquarter.getHeadquarterStore()), + CoreNumberUtils.compare(this.getHeadquarterStore(), headquarter.getHeadquarterStore()), // ... suite number - NumberUtils.compare(this.getHeadquarterSuiteNumber(), headquarter.getHeadquarterSuiteNumber()), + CoreNumberUtils.compare(this.getHeadquarterSuiteNumber(), headquarter.getHeadquarterSuiteNumber()), // ... last email address - StringUtils.compareToIgnoreCase(this.getHeadquarterEmailAddress(), headquarter.getHeadquarterEmailAddress()) + StringUtils.compareIgnoreCase(this.getHeadquarterEmailAddress(), headquarter.getHeadquarterEmailAddress()) }; // Check all values -- 2.39.5