]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 5 Nov 2017 16:35:20 +0000 (17:35 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 5 Nov 2017 16:59:20 +0000 (17:59 +0100)
- 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

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jcontactsbusiness/model/branchoffice/BusinessBranchOffice.java
src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java
src/org/mxchange/jcontactsbusiness/model/department/Departments.java

index d52625aca19c56e0a86d8915aeb6b9117e6857c8..605c399c030e2d39aa076ad8b5d1665603805723 100644 (file)
@@ -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());
index 0f90dd77414776e5c41e8818d0373d3b4fd39c6f..fe4d4bb590f45c3e097338ca4ea93735581659ad 100644 (file)
@@ -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
index 1ca7605139deb506472b1cea58f744b20d4aac77..78691f0a791b3beb4911086308f461937f04ecd8 100644 (file)
 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