From bc9e851c4dd03dfd365e6d4432741dcb29473121 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 5 Nov 2017 17:35:20 +0100 Subject: [PATCH] Continued: - also need to check branch office or headquarter when checking if same department, need to check department's branch office/headquarter only when one is at least not null - also compare last house number and extension - sorted members MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../branchoffice/BusinessBranchOffice.java | 26 ++++++++++++------- .../model/department/BusinessDepartment.java | 6 ++--- .../model/department/Departments.java | 19 ++++++++++++++ 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java index d52625a..605c399 100644 --- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java +++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java @@ -294,25 +294,29 @@ public class BusinessBranchOffice implements BranchOffice { return false; } - final BranchOffice other = (BranchOffice) object; + final BranchOffice branchOffice = (BranchOffice) object; - if (!Objects.equals(this.getBranchId(), other.getBranchId())) { + if (!Objects.equals(this.getBranchId(), branchOffice.getBranchId())) { return false; - } else if (!Objects.equals(this.getBranchCity(), other.getBranchCity())) { + } else if (!Objects.equals(this.getBranchCity(), branchOffice.getBranchCity())) { return false; - } else if (!Objects.equals(this.getBranchCountry(), other.getBranchCountry())) { + } else if (!Objects.equals(this.getBranchCountry(), branchOffice.getBranchCountry())) { return false; - } else if (!Objects.equals(this.getBranchHouseNumber(), other.getBranchHouseNumber())) { + } else if (!Objects.equals(this.getBranchHouseNumber(), branchOffice.getBranchHouseNumber())) { return false; - } else if (!Objects.equals(this.getBranchNumber(), other.getBranchNumber())) { + } else if (!Objects.equals(this.getBranchHouseNumberExtension(), branchOffice.getBranchHouseNumberExtension())) { return false; - } else if (!Objects.equals(this.getBranchStore(), other.getBranchStore())) { + } else if (!Objects.equals(this.getBranchLastHouseNumber(), branchOffice.getBranchLastHouseNumber())) { return false; - } else if (!Objects.equals(this.getBranchStreet(), other.getBranchStreet())) { + } else if (!Objects.equals(this.getBranchNumber(), branchOffice.getBranchNumber())) { return false; - } else if (!Objects.equals(this.getBranchSuiteNumber(), other.getBranchSuiteNumber())) { + } else if (!Objects.equals(this.getBranchStore(), branchOffice.getBranchStore())) { return false; - } else if (!Objects.equals(this.getBranchZipCode(), other.getBranchZipCode())) { + } else if (!Objects.equals(this.getBranchStreet(), branchOffice.getBranchStreet())) { + return false; + } else if (!Objects.equals(this.getBranchSuiteNumber(), branchOffice.getBranchSuiteNumber())) { + return false; + } else if (!Objects.equals(this.getBranchZipCode(), branchOffice.getBranchZipCode())) { return false; } @@ -532,6 +536,8 @@ public class BusinessBranchOffice implements BranchOffice { hash = 53 * hash + Objects.hashCode(this.getBranchCountry()); hash = 53 * hash + Objects.hashCode(this.getBranchNumber()); hash = 53 * hash + Objects.hashCode(this.getBranchHouseNumber()); + hash = 53 * hash + Objects.hashCode(this.getBranchHouseNumberExtension()); + hash = 53 * hash + Objects.hashCode(this.getBranchLastHouseNumber()); hash = 53 * hash + Objects.hashCode(this.getBranchStore()); hash = 53 * hash + Objects.hashCode(this.getBranchStreet()); hash = 53 * hash + Objects.hashCode(this.getBranchSuiteNumber()); diff --git a/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java b/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java index 0f90dd7..fe4d4bb 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java @@ -34,16 +34,16 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; +import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; /** * A POJO for company departments diff --git a/src/org/mxchange/jcontactsbusiness/model/department/Departments.java b/src/org/mxchange/jcontactsbusiness/model/department/Departments.java index 1ca7605..78691f0 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/Departments.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/Departments.java @@ -17,7 +17,10 @@ package org.mxchange.jcontactsbusiness.model.department; import java.io.Serializable; +import java.text.MessageFormat; import java.util.Objects; +import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; /** * Utilities class for departments @@ -54,6 +57,12 @@ public class Departments implements Serializable { } else if (department1.getDepartmentCompany() == null) { // Throw NPE again throw new NullPointerException("department1.departmentCompany is null"); //NOI18N + } else if (department1.getDepartmentCompany().getBasicDataId() == null) { + // Throw NPE again + throw new NullPointerException("department1.departmentCompany.basicDataId is null"); //NOI18N + } else if (department1.getDepartmentCompany().getBasicDataId() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("department1.departmentCompany.basicDataId={0} is valid.", department1.getDepartmentCompany().getBasicDataId())); //NOI18N } else if (department1.getDepartmentI18nKey() == null) { // Throw it again throw new NullPointerException("department1.departmentName is null"); //NOI18N @@ -63,6 +72,12 @@ public class Departments implements Serializable { } else if (department2.getDepartmentCompany() == null) { // Throw NPE again throw new NullPointerException("department2.departmentCompany is null"); //NOI18N + } else if (department2.getDepartmentCompany().getBasicDataId() == null) { + // Throw NPE again + throw new NullPointerException("department2.departmentCompany.basicDataId is null"); //NOI18N + } else if (department2.getDepartmentCompany().getBasicDataId() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("department2.departmentCompany.basicDataId={0} is valid.", department2.getDepartmentCompany().getBasicDataId())); //NOI18N } else if (department2.getDepartmentI18nKey() == null) { // Throw it again throw new NullPointerException("department2.departmentName is null"); //NOI18N @@ -73,6 +88,10 @@ public class Departments implements Serializable { // Same company and same name? boolean isSame = ((Objects.equals(department1.getDepartmentCompany(), department2.getDepartmentCompany())) && + (((department1.getDepartmentBranchOffice() instanceof BranchOffice) && + (Objects.equals(department1.getDepartmentBranchOffice(), department2.getDepartmentBranchOffice()))) || + ((department1.getDepartmentHeadquarter() instanceof Headquarter) && + (Objects.equals(department1.getDepartmentHeadquarter(), department2.getDepartmentHeadquarter())))) && (Objects.equals(department1.getDepartmentI18nKey(), department2.getDepartmentI18nKey()))); // Return it -- 2.39.5