From aa9aac9861d717d016f569353470a4d9579ff5f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 13 Dec 2018 13:01:08 +0100 Subject: [PATCH] Continued: - added companyShortName property with equals/hashCode/compareTo - made companyName now optional - updated commons-lang3 to 3.8.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- lib/nblibraries.properties | 4 +- .../model/basicdata/BasicData.java | 14 ++++++ .../model/basicdata/BusinessBasicData.java | 47 ++++++++++++++----- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties index 6d2e94d..23309c1 100644 --- a/lib/nblibraries.properties +++ b/lib/nblibraries.properties @@ -1,6 +1,6 @@ libs.commons-lang3.classpath=\ - ${base}/commons-lang3/commons-lang3-3.7.jar -libs.commons-lang3.displayName=Commons Lang3 3.7 + ${base}/commons-lang3/commons-lang3-3.8.1.jar +libs.commons-lang3.displayName=Commons Lang3 3.8.1 libs.commons-lang3.javadoc=\ https://commons.apache.org/proper/commons-lang/javadocs/api-release/ libs.CopyLibs.classpath=\ diff --git a/src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java b/src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java index 834aad7..aae030b 100644 --- a/src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java +++ b/src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java @@ -202,6 +202,20 @@ public interface BasicData extends Comparable, Serializable { */ void setCompanyName (final String companyName); + /** + * Getter for company short name + *

+ * @return Company short name + */ + String getCompanyShortName (); + + /** + * Setter for company short name + *

+ * @param companyShortName Company short name + */ + void setCompanyShortName (final String companyShortName); + /** * Getter for list of phone number *

diff --git a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java index f2d83a3..a84620a 100644 --- a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java +++ b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java @@ -153,10 +153,16 @@ public class BusinessBasicData implements BasicData { /** * Company name */ - @Basic (optional = false) - @Column (name = "company_name", length = 100, nullable = false, unique = true) + @Column (name = "company_name", unique = true) private String companyName; + /** + * Short company name + */ + @Basic (optional = false) + @Column (name = "company_short_name", length = 100, nullable = false, unique = true) + private String companyShortName; + /** * Tax number */ @@ -183,22 +189,22 @@ public class BusinessBasicData implements BasicData { } /** - * Constructor with company name + * Constructor with company short name *

- * @param companyName Company name + * @param companyShortName Company short name */ - public BusinessBasicData (final String companyName) { + public BusinessBasicData (final String companyShortName) { // First, validate all parameter - if (companyName == null) { + if (companyShortName == null) { // Is null - throw new NullPointerException("companyName is null"); //NOI18N - } else if (companyName.isEmpty()) { + throw new NullPointerException("companyShortName is null"); //NOI18N + } else if (companyShortName.isEmpty()) { // Is null - throw new IllegalArgumentException("companyName is empty"); //NOI18N + throw new IllegalArgumentException("companyShortName is empty"); //NOI18N } - // Set company name - this.companyName = companyName; + // Set company short name + this.companyShortName = companyShortName; } @Override @@ -214,8 +220,10 @@ public class BusinessBasicData implements BasicData { // Init comparators final int comparators[] = { - // First compare company name - this.getCompanyName().compareToIgnoreCase(basicData.getCompanyName()), + // First compare company short name + this.getCompanyShortName().compareToIgnoreCase(basicData.getCompanyShortName()), + // ... 2nd compare company name + StringUtils.compareIgnoreCase(this.getCompanyName(), basicData.getCompanyName()), // ... next tax number StringUtils.compareIgnoreCase(this.getCompanyTaxNumber(), basicData.getCompanyTaxNumber()), // ... and email address @@ -243,6 +251,8 @@ public class BusinessBasicData implements BasicData { if (!Objects.equals(this.getBasicDataId(), other.getBasicDataId())) { return false; + } else if (!Objects.equals(this.getCompanyShortName(), other.getCompanyShortName())) { + return false; } else if (!Objects.equals(this.getCompanyName(), other.getCompanyName())) { return false; } @@ -374,6 +384,16 @@ public class BusinessBasicData implements BasicData { this.companyName = companyName; } + @Override + public String getCompanyShortName () { + return this.companyShortName; + } + + @Override + public void setCompanyShortName (final String companyShortName) { + this.companyShortName = companyShortName; + } + @Override public String getCompanyTaxNumber () { return this.companyTaxNumber; @@ -409,6 +429,7 @@ public class BusinessBasicData implements BasicData { int hash = 3; hash = 37 * hash + Objects.hashCode(this.getBasicDataId()); + hash = 37 * hash + Objects.hashCode(this.getCompanyShortName()); hash = 37 * hash + Objects.hashCode(this.getCompanyName()); return hash; -- 2.39.5