]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 13 Dec 2018 12:01:08 +0000 (13:01 +0100)
committerRoland Häder <roland@mxchange.org>
Thu, 13 Dec 2018 12:01:08 +0000 (13:01 +0100)
- added companyShortName property with equals/hashCode/compareTo
- made companyName now optional
- updated commons-lang3 to 3.8.1

Signed-off-by: Roland Häder <roland@mxchange.org>
lib/nblibraries.properties
src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java
src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java

index 6d2e94d82a512b0fc13f743b82c287ddc75182af..23309c107f81f0ffbb8414f6e72723c71b1dafe1 100644 (file)
@@ -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=\
index 834aad7306c9f805da31f6df2598ec4f5621fb49..aae030bfe3aef064166170a6069801376ece8f44 100644 (file)
@@ -202,6 +202,20 @@ public interface BasicData extends Comparable<BasicData>, Serializable {
         */
        void setCompanyName (final String companyName);
 
+       /**
+        * Getter for company short name
+        * <p>
+        * @return Company short name
+        */
+       String getCompanyShortName ();
+
+       /**
+        * Setter for company short name
+        * <p>
+        * @param companyShortName Company short name
+        */
+       void setCompanyShortName (final String companyShortName);
+
        /**
         * Getter for list of phone number
         * <p>
index f2d83a359f08a30ad95ab15e8d68182d84d4f819..a84620a365c88b6470e009ae9f1f97871ca44d28 100644 (file)
@@ -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
         * <p>
-        * @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;