From bd1c3d5d09169ee37d723b148244b6662786321f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 12 Oct 2017 21:58:59 +0200 Subject: [PATCH] Continued: - departmentName was not localizable, let's rename it to departmentI18nKey then MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../DepartmentAlreadyAddedException.java | 2 +- .../model/department/CompanyDepartment.java | 40 +++++++++---------- .../model/department/Department.java | 12 +++--- .../model/department/Departments.java | 10 ++--- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/department/DepartmentAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/department/DepartmentAlreadyAddedException.java index fcd231b..0f679b9 100644 --- a/src/org/mxchange/jcontactsbusiness/exceptions/department/DepartmentAlreadyAddedException.java +++ b/src/org/mxchange/jcontactsbusiness/exceptions/department/DepartmentAlreadyAddedException.java @@ -37,7 +37,7 @@ public class DepartmentAlreadyAddedException extends Exception { * @param department Company department that is already found */ public DepartmentAlreadyAddedException (final Department department) { - super(MessageFormat.format("Company department with name {0} already created.", department.getDepartmentName())); + super(MessageFormat.format("Company department with i18n key {0} already created.", department.getDepartmentI18nKey())); } /** diff --git a/src/org/mxchange/jcontactsbusiness/model/department/CompanyDepartment.java b/src/org/mxchange/jcontactsbusiness/model/department/CompanyDepartment.java index 90a7f85..be6fd1d 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/CompanyDepartment.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/CompanyDepartment.java @@ -95,6 +95,13 @@ public class CompanyDepartment implements Department { @OneToOne (targetEntity = CompanyHeadquartersData.class, cascade = CascadeType.ALL) private HeadquartersData departmentHeadquarters; + /** + * Department i18n key + */ + @Basic (optional = false) + @Column (name = "department_i18n_key", length = 100, nullable = false) + private String departmentI18nKey; + /** * Id number */ @@ -110,13 +117,6 @@ public class CompanyDepartment implements Department { @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL) private Employee departmentLead; - /** - * Department name - */ - @Basic (optional = false) - @Column (name = "department_name", length = 100, nullable = false) - private String departmentName; - /** * User owner instance */ @@ -154,7 +154,7 @@ public class CompanyDepartment implements Department { // Set all fields this.departmentCompany = departmentCompany; - this.departmentName = departmentName; + this.departmentI18nKey = departmentName; } @Override @@ -171,7 +171,7 @@ public class CompanyDepartment implements Department { return false; } else if (!Objects.equals(this.getDepartmentCompany(), other.getDepartmentCompany())) { return false; - } else if (!Objects.equals(this.getDepartmentName(), other.getDepartmentName())) { + } else if (!Objects.equals(this.getDepartmentI18nKey(), other.getDepartmentI18nKey())) { return false; } @@ -220,6 +220,16 @@ public class CompanyDepartment implements Department { this.departmentHeadquarters = departmentHeadquarters; } + @Override + public String getDepartmentI18nKey () { + return this.departmentI18nKey; + } + + @Override + public void setDepartmentI18nKey (final String departmentI18nKey) { + this.departmentI18nKey = departmentI18nKey; + } + @Override public Long getDepartmentId () { return this.departmentId; @@ -240,16 +250,6 @@ public class CompanyDepartment implements Department { this.departmentLead = departmentLead; } - @Override - public String getDepartmentName () { - return this.departmentName; - } - - @Override - public void setDepartmentName (final String departmentName) { - this.departmentName = departmentName; - } - @Override public User getDepartmentUserOwner () { return this.departmentUserOwner; @@ -266,7 +266,7 @@ public class CompanyDepartment implements Department { hash = 53 * hash + Objects.hashCode(this.getDepartmentId()); hash = 53 * hash + Objects.hashCode(this.getDepartmentCompany()); - hash = 53 * hash + Objects.hashCode(this.getDepartmentName()); + hash = 53 * hash + Objects.hashCode(this.getDepartmentI18nKey()); return hash; } diff --git a/src/org/mxchange/jcontactsbusiness/model/department/Department.java b/src/org/mxchange/jcontactsbusiness/model/department/Department.java index 860d2e2..9583a73 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/Department.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/Department.java @@ -102,18 +102,18 @@ public interface Department extends Serializable { void setDepartmentLead (final Employee departmentLead); /** - * Getter for department name + * Getter for department i18n key *

- * @return Department name + * @return Department i18n key */ - String getDepartmentName (); + String getDepartmentI18nKey (); /** - * Setter for department name + * Setter for department i18n key *

- * @param departmentName Department name + * @param departmentI18nKey Department i18n key */ - void setDepartmentName (final String departmentName); + void setDepartmentI18nKey (final String departmentI18nKey); /** * Getter for user owner instance diff --git a/src/org/mxchange/jcontactsbusiness/model/department/Departments.java b/src/org/mxchange/jcontactsbusiness/model/department/Departments.java index 033c736..1ca7605 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/Departments.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/Departments.java @@ -54,26 +54,26 @@ public class Departments implements Serializable { } else if (department1.getDepartmentCompany() == null) { // Throw NPE again throw new NullPointerException("department1.departmentCompany is null"); //NOI18N - } else if (department1.getDepartmentName() == null) { + } else if (department1.getDepartmentI18nKey() == null) { // Throw it again throw new NullPointerException("department1.departmentName is null"); //NOI18N - } else if (department1.getDepartmentName().isEmpty()) { + } else if (department1.getDepartmentI18nKey().isEmpty()) { // Throw IAE throw new IllegalArgumentException("department1.departmentName is empty"); //NOI18N } else if (department2.getDepartmentCompany() == null) { // Throw NPE again throw new NullPointerException("department2.departmentCompany is null"); //NOI18N - } else if (department2.getDepartmentName() == null) { + } else if (department2.getDepartmentI18nKey() == null) { // Throw it again throw new NullPointerException("department2.departmentName is null"); //NOI18N - } else if (department2.getDepartmentName().isEmpty()) { + } else if (department2.getDepartmentI18nKey().isEmpty()) { // Throw IAE throw new IllegalArgumentException("department2.departmentName is empty"); //NOI18N } // Same company and same name? boolean isSame = ((Objects.equals(department1.getDepartmentCompany(), department2.getDepartmentCompany())) && - (Objects.equals(department1.getDepartmentName(), department2.getDepartmentName()))); + (Objects.equals(department1.getDepartmentI18nKey(), department2.getDepartmentI18nKey()))); // Return it return isSame; -- 2.39.5