From: Roland Haeder Date: Tue, 13 Oct 2015 13:01:23 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=79394dcc1aab9ce816b14f389cf4d7f952d98f87;p=jcontacts-business-core.git Continued: - added equals()/hashCode() for easy comparison - updated jar(s) Signed-off-by:Roland Häder --- diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index 680b3d1..a135b3e 100644 Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ diff --git a/lib/jcountry-core.jar b/lib/jcountry-core.jar index 049ef5f..7166776 100644 Binary files a/lib/jcountry-core.jar and b/lib/jcountry-core.jar differ diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar index 5fc3762..c2ea571 100644 Binary files a/lib/jphone-core.jar and b/lib/jphone-core.jar differ diff --git a/src/org/mxchange/jcontactsbusiness/BusinessContact.java b/src/org/mxchange/jcontactsbusiness/BusinessContact.java index 2cf5953..f0f9579 100644 --- a/src/org/mxchange/jcontactsbusiness/BusinessContact.java +++ b/src/org/mxchange/jcontactsbusiness/BusinessContact.java @@ -127,4 +127,10 @@ public interface BusinessContact extends Serializable { * @param headQuartersData Headquarters data */ public void setHeadQuartersData (final HeadQuartersData headQuartersData); + + @Override + public boolean equals (final Object object); + + @Override + public int hashCode (); } diff --git a/src/org/mxchange/jcontactsbusiness/CompanyContact.java b/src/org/mxchange/jcontactsbusiness/CompanyContact.java index 7685c6c..57142c5 100644 --- a/src/org/mxchange/jcontactsbusiness/CompanyContact.java +++ b/src/org/mxchange/jcontactsbusiness/CompanyContact.java @@ -17,6 +17,7 @@ package org.mxchange.jcontactsbusiness; import java.util.List; +import java.util.Objects; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -105,6 +106,19 @@ public class CompanyContact implements BusinessContact, Comparable { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + @Override + public boolean equals (final Object object) { + if (object == null) { + return false; + } else if (getClass() != object.getClass()) { + return false; + } + + final Department other = (Department) object; + + if (!Objects.equals(this.getDepartmentCompany(), other.getDepartmentCompany())) { + return false; + } else if (!Objects.equals(this.getDepartmentName(), other.getDepartmentName())) { + return false; + } + + return true; + } + @Override public BusinessContact getDepartmentCompany () { return this.departmentCompany; @@ -120,4 +140,12 @@ public class CompanyDepartment implements Department, Comparable { public void setDepartmentName (final String departmentName) { this.departmentName = departmentName; } + + @Override + public int hashCode () { + int hash = 5; + hash = 53 * hash + Objects.hashCode(this.getDepartmentCompany()); + hash = 53 * hash + Objects.hashCode(this.getDepartmentName()); + return hash; + } } diff --git a/src/org/mxchange/jcontactsbusiness/department/Department.java b/src/org/mxchange/jcontactsbusiness/department/Department.java index 6eca9b8..22a065a 100644 --- a/src/org/mxchange/jcontactsbusiness/department/Department.java +++ b/src/org/mxchange/jcontactsbusiness/department/Department.java @@ -82,4 +82,10 @@ public interface Department extends Serializable { * @param departmentName Department name */ public void setDepartmentName (final String departmentName); + + @Override + public boolean equals (final Object object); + + @Override + public int hashCode (); } diff --git a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java index 757a4f0..7922083 100644 --- a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java @@ -16,6 +16,7 @@ */ package org.mxchange.jcontactsbusiness.employee; +import java.util.Objects; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -28,6 +29,8 @@ import javax.persistence.OneToOne; import javax.persistence.Table; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.UserContact; +import org.mxchange.jcontactsbusiness.BusinessContact; +import org.mxchange.jcontactsbusiness.CompanyContact; import org.mxchange.jcontactsbusiness.branch.BranchOffice; import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice; import org.mxchange.jcontactsbusiness.department.CompanyDepartment; @@ -58,6 +61,13 @@ public class CompanyEmployee implements Employee, Comparable { @OneToOne (targetEntity = CompanyBranchOffice.class, cascade = CascadeType.ALL) private BranchOffice employeeBranchOffice; + /** + * Company the employee is working at + */ + @JoinColumn (name = "employee_company_id", nullable = false, updatable = false) + @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL, optional = false) + private BusinessContact employeeCompany; + /** * Department the employee works at */ @@ -117,6 +127,27 @@ public class CompanyEmployee implements Employee, Comparable { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + @Override + public boolean equals (final Object object) { + if (object == null) { + return false; + } else if (getClass() != object.getClass()) { + return false; + } + + final Employee other = (Employee) object; + + if (!Objects.equals(this.getEmployeeCompany(), other.getEmployeeCompany())) { + return false; + } else if (!Objects.equals(this.getEmployeeNumber(), other.getEmployeeNumber())) { + return false; + } else if (!Objects.equals(this.getEmployeePersonalData(), other.getEmployeePersonalData())) { + return false; + } + + return true; + } + @Override public BranchOffice getEmployeeBranchOffice () { return this.employeeBranchOffice; @@ -127,6 +158,16 @@ public class CompanyEmployee implements Employee, Comparable { this.employeeBranchOffice = employeeBranchOffice; } + @Override + public BusinessContact getEmployeeCompany () { + return this.employeeCompany; + } + + @Override + public void setEmployeeCompany (final BusinessContact employeeCompany) { + this.employeeCompany = employeeCompany; + } + @Override public Department getEmployeeDepartment () { return this.employeeDepartment; @@ -206,4 +247,13 @@ public class CompanyEmployee implements Employee, Comparable { public void setEmployeePosition (final JobPosition employeePosition) { this.employeePosition = employeePosition; } + + @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; + } } diff --git a/src/org/mxchange/jcontactsbusiness/employee/Employee.java b/src/org/mxchange/jcontactsbusiness/employee/Employee.java index ea64f1e..da67f3d 100644 --- a/src/org/mxchange/jcontactsbusiness/employee/Employee.java +++ b/src/org/mxchange/jcontactsbusiness/employee/Employee.java @@ -18,6 +18,7 @@ package org.mxchange.jcontactsbusiness.employee; import java.io.Serializable; import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jcontactsbusiness.BusinessContact; import org.mxchange.jcontactsbusiness.branch.BranchOffice; import org.mxchange.jcontactsbusiness.department.Department; import org.mxchange.jcontactsbusiness.jobposition.JobPosition; @@ -44,6 +45,20 @@ public interface Employee extends Serializable { */ public void setEmployeeBranchOffice (final BranchOffice employeeBranchOffice); + /** + * Getter for employee's company + *

+ * @return Company instance + */ + public BusinessContact getEmployeeCompany (); + + /** + * Setter for employee's company + *

+ * @param employeeCompany Company instance + */ + public void setEmployeeCompany (final BusinessContact employeeCompany); + /** * Getter for employee's department *

@@ -155,4 +170,10 @@ public interface Employee extends Serializable { * @param employeePosition Employee's position */ public void setEmployeePosition (final JobPosition employeePosition); + + @Override + public boolean equals (final Object object); + + @Override + public int hashCode (); } diff --git a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java index 259d691..5395fb7 100644 --- a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java +++ b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java @@ -16,6 +16,7 @@ */ package org.mxchange.jcontactsbusiness.headquarters; +import java.util.Objects; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -122,6 +123,35 @@ public class CompanyHeadQuartersData implements HeadQuartersData, Comparable { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + @Override + public boolean equals (final Object object) { + if (object == null) { + return false; + } else if (getClass() != object.getClass()) { + return false; + } + + final JobPosition other = (JobPosition) object; + + if (!Objects.equals(this.getJobPositionName(), other.getJobPositionName())) { + return false; + } + return true; + } + @Override public Long getJobPositionId () { return this.jobPositionId; @@ -78,4 +95,11 @@ public class EmployeePosition implements JobPosition, Comparable { this.jobPositionName = jobPositionName; } + @Override + public int hashCode () { + int hash = 7; + hash = 37 * hash + Objects.hashCode(this.getJobPositionName()); + return hash; + } + } diff --git a/src/org/mxchange/jcontactsbusiness/jobposition/JobPosition.java b/src/org/mxchange/jcontactsbusiness/jobposition/JobPosition.java index e9dc8f9..6a117ad 100644 --- a/src/org/mxchange/jcontactsbusiness/jobposition/JobPosition.java +++ b/src/org/mxchange/jcontactsbusiness/jobposition/JobPosition.java @@ -52,4 +52,10 @@ public interface JobPosition extends Serializable { * @param jobPositionName Job position name */ public void setJobPositionName (final String jobPositionName); + + @Override + public boolean equals (final Object object); + + @Override + public int hashCode (); } diff --git a/src/org/mxchange/jcontactsbusiness/logo/BusinessLogo.java b/src/org/mxchange/jcontactsbusiness/logo/BusinessLogo.java index 062259e..e76ce18 100644 --- a/src/org/mxchange/jcontactsbusiness/logo/BusinessLogo.java +++ b/src/org/mxchange/jcontactsbusiness/logo/BusinessLogo.java @@ -52,4 +52,10 @@ public interface BusinessLogo extends Serializable { * @param logoId Logo's id number */ public void setLogoId (final Long logoId); + + @Override + public boolean equals (final Object object); + + @Override + public int hashCode (); } diff --git a/src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java b/src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java index 59b3b86..9cb53fd 100644 --- a/src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java +++ b/src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java @@ -16,6 +16,7 @@ */ package org.mxchange.jcontactsbusiness.logo; +import java.util.Objects; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; @@ -58,6 +59,19 @@ public class CompanyLogo implements BusinessLogo, Comparable { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + @Override + public boolean equals (final Object object) { + if (object == null) { + return false; + } else if (getClass() != object.getClass()) { + return false; + } + + final BusinessLogo other = (BusinessLogo) object; + + return Objects.equals(this.getLogoFileName(), other.getLogoFileName()); + } + @Override public String getLogoFileName () { return this.logoFileName; @@ -77,4 +91,11 @@ public class CompanyLogo implements BusinessLogo, Comparable { public void setLogoId (final Long logoId) { this.logoId = logoId; } + + @Override + public int hashCode () { + int hash = 3; + hash = 53 * hash + Objects.hashCode(this.getLogoFileName()); + return hash; + } }