]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
equals() is for object-comparison (entitiy included), so always include id number
authorRoland Häder <roland@mxchange.org>
Tue, 23 Aug 2016 14:35:54 +0000 (16:35 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 23 Aug 2016 14:35:54 +0000 (16:35 +0200)
src/org/mxchange/jcontactsbusiness/CompanyContact.java
src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java
src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java
src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java
src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java
src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java
src/org/mxchange/jcontactsbusiness/jobposition/EmployeePosition.java
src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java
src/org/mxchange/jcontactsbusiness/opening_times/BusinessOpeningTimes.java

index 99012d4b45373e5b9f4e165e5c3380b53c1d34c1..fa0a1487aefcae8aff7432f333a5730d21599bf7 100644 (file)
@@ -125,7 +125,19 @@ public class CompanyContact implements BusinessContact {
 
                final BusinessContact other = (BusinessContact) object;
 
-               return Objects.equals(this.getBasicBusinessData(), other.getBasicBusinessData());
+               if (!Objects.equals(this.getCompanyContactId(), other.getCompanyContactId())) {
+                       return false;
+               } else if (!Objects.equals(this.getCompanyContact(), other.getCompanyContact())) {
+                       return false;
+               } else if (!Objects.equals(this.getCompanyFounder(), other.getCompanyFounder())) {
+                       return false;
+               } else if (!Objects.equals(this.getBasicBusinessData(), other.getBasicBusinessData())) {
+                       return false;
+               } else if (!Objects.equals(this.getHeadQuartersData(), other.getHeadQuartersData())) {
+                       return false;
+               }
+
+               return true;
        }
 
        @Override
@@ -215,7 +227,13 @@ public class CompanyContact implements BusinessContact {
        @Override
        public int hashCode () {
                int hash = 3;
+
+               hash = 37 * hash + Objects.hashCode(this.getCompanyContactId());
+               hash = 37 * hash + Objects.hashCode(this.getCompanyContact());
+               hash = 37 * hash + Objects.hashCode(this.getCompanyFounder());
                hash = 37 * hash + Objects.hashCode(this.getBasicBusinessData());
+               hash = 37 * hash + Objects.hashCode(this.getHeadQuartersData());
+
                return hash;
        }
 }
index bc011d41008adf62eb50358d3ef2cab2c9681f41..6e5e04e37172558b5b9b69679e8964e4843222e8 100644 (file)
@@ -175,14 +175,14 @@ public interface BusinessBasicData extends Serializable {
         * <p>
         * @return User owner instance
         */
-       User getBasicUserOwner ();
+       User getCompanyBasicUserOwner ();
 
        /**
         * Setter for user owner instance
         * <p>
-        * @param basicUserOwner User owner instance
+        * @param companyBasicUserOwner User owner instance
         */
-       void setBasicUserOwner (final User basicUserOwner);
+       void setCompanyBasicUserOwner (final User companyBasicUserOwner);
 
        /**
         * Getter for timestamp when this entry has been created
index 4135815a5c1d760973de328fe0457c054b1540a9..ac26e7a66babc16ca60f8cdaf8656a7008caadc0 100644 (file)
@@ -70,7 +70,7 @@ public class CompanyBasicData implements BusinessBasicData {
         */
        @JoinColumn (name = "company_user_id", nullable = false, updatable = false)
        @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
-       private User basicUserOwner;
+       private User companyBasicUserOwner;
 
        /**
         * Id number
@@ -150,26 +150,21 @@ public class CompanyBasicData implements BusinessBasicData {
 
                final BusinessBasicData other = (BusinessBasicData) object;
 
-               if (!Objects.equals(this.getCompanyLegalStatus(), other.getCompanyLegalStatus())) {
+               if (!Objects.equals(this.getCompanyBasicId(), other.getCompanyBasicId())) {
+                       return false;
+               } else if (!Objects.equals(this.getCompanyLegalStatus(), other.getCompanyLegalStatus())) {
                        return false;
                } else if (!Objects.equals(this.getCompanyName(), other.getCompanyName())) {
                        return false;
                } else if (!Objects.equals(this.getCompanyTaxNumber(), other.getCompanyTaxNumber())) {
                        return false;
+               } else if (!Objects.equals(this.getCompanyBasicUserOwner(), other.getCompanyBasicUserOwner())) {
+                       return false;
                }
 
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 5;
-               hash = 53 * hash + Objects.hashCode(this.getCompanyLegalStatus());
-               hash = 53 * hash + Objects.hashCode(this.getCompanyName());
-               hash = 53 * hash + Objects.hashCode(this.getCompanyTaxNumber());
-               return hash;
-       }
-
        @Override
        @SuppressWarnings ("ReturnOfDateField")
        public Calendar getBasicCreated () {
@@ -183,13 +178,13 @@ public class CompanyBasicData implements BusinessBasicData {
        }
 
        @Override
-       public User getBasicUserOwner () {
-               return this.basicUserOwner;
+       public User getCompanyBasicUserOwner () {
+               return this.companyBasicUserOwner;
        }
 
        @Override
-       public void setBasicUserOwner (final User basicUserOwner) {
-               this.basicUserOwner = basicUserOwner;
+       public void setCompanyBasicUserOwner (final User companyBasicUserOwner) {
+               this.companyBasicUserOwner = companyBasicUserOwner;
        }
 
        @Override
@@ -292,4 +287,17 @@ public class CompanyBasicData implements BusinessBasicData {
                this.companyWebsiteUrl = companyWebsiteUrl;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 5;
+
+               hash = 53 * hash + Objects.hashCode(this.getCompanyBasicId());
+               hash = 53 * hash + Objects.hashCode(this.getCompanyLegalStatus());
+               hash = 53 * hash + Objects.hashCode(this.getCompanyName());
+               hash = 53 * hash + Objects.hashCode(this.getCompanyTaxNumber());
+               hash = 53 * hash + Objects.hashCode(this.getCompanyBasicUserOwner());
+
+               return hash;
+       }
+
 }
index c3526671b3c442f14b64a3d1e3ce52444bc7a090..69e90e42fbfe1a49671c717d79d684f81e4331c8 100644 (file)
@@ -165,7 +165,9 @@ public class CompanyBranchOffice implements BranchOffice {
 
                final BranchOffice other = (BranchOffice) object;
 
-               if (!Objects.equals(this.getBranchCity(), other.getBranchCity())) {
+               if (!Objects.equals(this.getBranchId(), other.getBranchId())) {
+                       return false;
+               } else if (!Objects.equals(this.getBranchCity(), other.getBranchCity())) {
                        return false;
                } else if (!Objects.equals(this.getBranchCountry(), other.getBranchCountry())) {
                        return false;
@@ -184,19 +186,6 @@ public class CompanyBranchOffice implements BranchOffice {
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 7;
-               hash = 53 * hash + Objects.hashCode(this.getBranchCity());
-               hash = 53 * hash + Objects.hashCode(this.getBranchCountry());
-               hash = 53 * hash + Objects.hashCode(this.getBranchHouseNumber());
-               hash = 53 * hash + Objects.hashCode(this.getBranchStore());
-               hash = 53 * hash + Objects.hashCode(this.getBranchStreet());
-               hash = 53 * hash + Objects.hashCode(this.getBranchSuiteNumber());
-               hash = 53 * hash + Objects.hashCode(this.getBranchZipCode());
-               return hash;
-       }
-
        @Override
        public String getBranchCity () {
                return this.branchCity;
@@ -339,4 +328,20 @@ public class CompanyBranchOffice implements BranchOffice {
                this.branchZipCode = branchZipCode;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 7;
+
+               hash = 53 * hash + Objects.hashCode(this.getBranchId());
+               hash = 53 * hash + Objects.hashCode(this.getBranchCity());
+               hash = 53 * hash + Objects.hashCode(this.getBranchCountry());
+               hash = 53 * hash + Objects.hashCode(this.getBranchHouseNumber());
+               hash = 53 * hash + Objects.hashCode(this.getBranchStore());
+               hash = 53 * hash + Objects.hashCode(this.getBranchStreet());
+               hash = 53 * hash + Objects.hashCode(this.getBranchSuiteNumber());
+               hash = 53 * hash + Objects.hashCode(this.getBranchZipCode());
+
+               return hash;
+       }
+
 }
index 3fb5a8c7fcff658ff4790885809afe1b3a909534..56321668502f40da46abe5c89304ab892db908f4 100644 (file)
@@ -127,7 +127,9 @@ public class CompanyDepartment implements Department {
 
                final Department other = (Department) object;
 
-               if (!Objects.equals(this.getDepartmentCompany(), other.getDepartmentCompany())) {
+               if (!Objects.equals(this.getDepartmentId(), other.getDepartmentId())) {
+                       return false;
+               } else if (!Objects.equals(this.getDepartmentCompany(), other.getDepartmentCompany())) {
                        return false;
                } else if (!Objects.equals(this.getDepartmentName(), other.getDepartmentName())) {
                        return false;
@@ -136,14 +138,6 @@ public class CompanyDepartment implements Department {
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 5;
-               hash = 53 * hash + Objects.hashCode(this.getDepartmentCompany());
-               hash = 53 * hash + Objects.hashCode(this.getDepartmentName());
-               return hash;
-       }
-
        @Override
        public HeadQuartersData getDepartentHeadquarters () {
                return this.departentHeadquarters;
@@ -226,4 +220,15 @@ public class CompanyDepartment implements Department {
                this.departmentUserOwner = departmentUserOwner;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 5;
+
+               hash = 53 * hash + Objects.hashCode(this.getDepartmentId());
+               hash = 53 * hash + Objects.hashCode(this.getDepartmentCompany());
+               hash = 53 * hash + Objects.hashCode(this.getDepartmentName());
+
+               return hash;
+       }
+
 }
index 5a73f08e635d65d1f3cf75d66568a5cd477874a4..dce162eec9d5e9a981233f434e7f4dc7b0581450 100644 (file)
@@ -164,7 +164,9 @@ public class CompanyEmployee implements Employee {
 
                final Employee other = (Employee) object;
 
-               if (!Objects.equals(this.getEmployeeCompany(), other.getEmployeeCompany())) {
+               if (!Objects.equals(this.getEmployeeId(), other.getEmployeeId())) {
+                       return false;
+               } else if (!Objects.equals(this.getEmployeeCompany(), other.getEmployeeCompany())) {
                        return false;
                } else if (!Objects.equals(this.getEmployeeNumber(), other.getEmployeeNumber())) {
                        return false;
@@ -175,15 +177,6 @@ public class CompanyEmployee implements Employee {
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 3;
-               hash = 97 * hash + Objects.hashCode(this.getEmployeeCompany());
-               hash = 97 * hash + Objects.hashCode(this.getEmployeeNumber());
-               hash = 97 * hash + Objects.hashCode(this.getEmployeePersonalData());
-               return hash;
-       }
-
        @Override
        public BranchOffice getEmployeeBranchOffice () {
                return this.employeeBranchOffice;
@@ -316,4 +309,16 @@ public class CompanyEmployee implements Employee {
                this.employeeUserOwner = employeeUserOwner;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 3;
+
+               hash = 97 * hash + Objects.hashCode(this.getEmployeeId());
+               hash = 97 * hash + Objects.hashCode(this.getEmployeeCompany());
+               hash = 97 * hash + Objects.hashCode(this.getEmployeeNumber());
+               hash = 97 * hash + Objects.hashCode(this.getEmployeePersonalData());
+
+               return hash;
+       }
+
 }
index 70b61f01c26da60eb0d757e326658a7f991f94dd..0e28493b9e87454b4a0d4f690226e6d6495aa799 100644 (file)
@@ -150,7 +150,9 @@ public class CompanyHeadQuartersData implements HeadQuartersData {
 
                final HeadQuartersData other = (HeadQuartersData) object;
 
-               if (!Objects.equals(this.getHeadquartersCity(), other.getHeadquartersCity())) {
+               if (!Objects.equals(this.getHeadquartersId(), other.getHeadquartersId())) {
+                       return false;
+               } else if (!Objects.equals(this.getHeadquartersCity(), other.getHeadquartersCity())) {
                        return false;
                } else if (!Objects.equals(this.getHeadquartersCountry(), other.getHeadquartersCountry())) {
                        return false;
@@ -169,19 +171,6 @@ public class CompanyHeadQuartersData implements HeadQuartersData {
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 7;
-               hash = 47 * hash + Objects.hashCode(this.getHeadquartersCity());
-               hash = 47 * hash + Objects.hashCode(this.getHeadquartersCountry());
-               hash = 47 * hash + Objects.hashCode(this.getHeadquartersHouseNumber());
-               hash = 47 * hash + Objects.hashCode(this.getHeadquartersStore());
-               hash = 47 * hash + Objects.hashCode(this.getHeadquartersStreet());
-               hash = 47 * hash + Objects.hashCode(this.getHeadquartersSuiteNumber());
-               hash = 47 * hash + Objects.hashCode(this.getHeadquartersZipCode());
-               return hash;
-       }
-
        @Override
        public String getHeadquartersCity () {
                return this.headquartersCity;
@@ -304,4 +293,20 @@ public class CompanyHeadQuartersData implements HeadQuartersData {
                this.headquartersZipCode = headquartersZipCode;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 7;
+
+               hash = 47 * hash + Objects.hashCode(this.getHeadquartersId());
+               hash = 47 * hash + Objects.hashCode(this.getHeadquartersCity());
+               hash = 47 * hash + Objects.hashCode(this.getHeadquartersCountry());
+               hash = 47 * hash + Objects.hashCode(this.getHeadquartersHouseNumber());
+               hash = 47 * hash + Objects.hashCode(this.getHeadquartersStore());
+               hash = 47 * hash + Objects.hashCode(this.getHeadquartersStreet());
+               hash = 47 * hash + Objects.hashCode(this.getHeadquartersSuiteNumber());
+               hash = 47 * hash + Objects.hashCode(this.getHeadquartersZipCode());
+
+               return hash;
+       }
+
 }
index 1ef9618ed0efe80aa30beb9dcfb2cd9f0f3738f4..e9b08d9a76ac1e03f210ef8eba81501ac08e2b5e 100644 (file)
@@ -97,25 +97,15 @@ public class EmployeePosition implements JobPosition {
 
                final JobPosition other = (JobPosition) object;
 
-               if (!Objects.equals(this.getJobPositionName(), other.getJobPositionName())) {
+               if (!Objects.equals(this.getJobPositionId(), other.getJobPositionId())) {
                        return false;
-               } else if (!Objects.equals(this.getJobPositionId(), other.getJobPositionId())) {
+               } else if (!Objects.equals(this.getJobPositionName(), other.getJobPositionName())) {
                        return false;
                }
 
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 7;
-
-               hash = 37 * hash + Objects.hashCode(this.getJobPositionId());
-               hash = 37 * hash + Objects.hashCode(this.getJobPositionName());
-
-               return hash;
-       }
-
        @Override
        @SuppressWarnings ("ReturnOfDateField")
        public Calendar getJobPositionCreated () {
@@ -160,4 +150,14 @@ public class EmployeePosition implements JobPosition {
                this.jobPositionUpdated = jobPositionUpdated;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 7;
+
+               hash = 37 * hash + Objects.hashCode(this.getJobPositionId());
+               hash = 37 * hash + Objects.hashCode(this.getJobPositionName());
+
+               return hash;
+       }
+
 }
index c11510944bfcd7e7006bdb481eaf5b32425c4e4f..07c7a8e99097682ce771c7e4a9ad5619a6d76de9 100644 (file)
@@ -90,14 +90,15 @@ public class CompanyLogo implements BusinessLogo {
 
                final BusinessLogo other = (BusinessLogo) object;
 
-               return Objects.equals(this.getLogoFileName(), other.getLogoFileName());
-       }
+               if (!Objects.equals(this.getLogoId(), other.getLogoId())) {
+                       return false;
+               } else if (!Objects.equals(this.getLogoUploader(), other.getLogoUploader())) {
+                       return false;
+               } else if (!Objects.equals(this.getLogoFileName(), other.getLogoFileName())) {
+                       return false;
+               }
 
-       @Override
-       public int hashCode () {
-               int hash = 3;
-               hash = 53 * hash + Objects.hashCode(this.getLogoFileName());
-               return hash;
+               return true;
        }
 
        @Override
@@ -142,4 +143,15 @@ public class CompanyLogo implements BusinessLogo {
                this.logoUploader = logoUploader;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 3;
+
+               hash = 53 * hash + Objects.hashCode(this.getLogoId());
+               hash = 53 * hash + Objects.hashCode(this.getLogoFileName());
+               hash = 53 * hash + Objects.hashCode(this.getLogoUploader());
+
+               return hash;
+       }
+
 }
index d297db2637a00614cb7f1658a9f45d4b7cab4c93..60cada6bf23ff565bd43fd6450cfb79c595cb05e 100644 (file)
@@ -96,10 +96,10 @@ public class BusinessOpeningTimes implements OpeningTimes {
        /**
         * Constructor with all field
         * <p>
-        * @param endDay    End day
-        * @param endTime   End time
-        * @param id        Id number
-        * @param startDay  Start day
+        * @param endDay End day
+        * @param endTime End time
+        * @param id Id number
+        * @param startDay Start day
         * @param startTime Start time
         */
        public BusinessOpeningTimes (final DayOfWeek endDay, final Calendar endTime, final Long id, final DayOfWeek startDay, final Calendar startTime) {
@@ -113,9 +113,9 @@ public class BusinessOpeningTimes implements OpeningTimes {
        /**
         * Constructor with all fields except id number
         * <p>
-        * @param endDay    End day
-        * @param endTime   End time
-        * @param startDay  Start day
+        * @param endDay End day
+        * @param endTime End time
+        * @param startDay Start day
         * @param startTime Start time
         */
        public BusinessOpeningTimes (final DayOfWeek endDay, final Calendar endTime, final DayOfWeek startDay, final Calendar startTime) {
@@ -153,19 +153,6 @@ public class BusinessOpeningTimes implements OpeningTimes {
                return true;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 7;
-
-               hash = 97 * hash + Objects.hashCode(this.getId());
-               hash = 97 * hash + Objects.hashCode(this.getStartDay());
-               hash = 97 * hash + Objects.hashCode(this.getEndDay());
-               hash = 97 * hash + Objects.hashCode(this.getStartTime());
-               hash = 97 * hash + Objects.hashCode(this.getEndTime());
-
-               return hash;
-       }
-
        @Override
        public DayOfWeek getEndDay () {
                return this.endDay;
@@ -220,4 +207,17 @@ public class BusinessOpeningTimes implements OpeningTimes {
                this.startTime = startTime;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 7;
+
+               hash = 97 * hash + Objects.hashCode(this.getId());
+               hash = 97 * hash + Objects.hashCode(this.getStartDay());
+               hash = 97 * hash + Objects.hashCode(this.getEndDay());
+               hash = 97 * hash + Objects.hashCode(this.getStartTime());
+               hash = 97 * hash + Objects.hashCode(this.getEndTime());
+
+               return hash;
+       }
+
 }