]> git.mxchange.org Git - jcustomer-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 19 Mar 2018 01:05:59 +0000 (02:05 +0100)
committerRoland Häder <roland@mxchange.org>
Mon, 19 Mar 2018 01:29:27 +0000 (02:29 +0100)
- added method Customers.compare() which allows a null-safe comparison of
  the entity
- updated commons-lang3 to 3.7
- updated commons-codec to 1.11

Signed-off-by: Roland Häder <roland@mxchange.org>
lib/nblibraries.properties
src/org/mxchange/jcustomercore/utils/Customers.java

index 2f0bd14c64f0db72aecce732360a03bdd8281dc5..b1c3713a31037aefeacbf35fad142467618fabe4 100644 (file)
@@ -1,11 +1,11 @@
 libs.commons-codec.classpath=\
-    ${base}/commons-codec/commons-codec-1.10.jar
-libs.commons-codec.displayName=Commons Codec 1.10
+    ${base}/commons-codec/commons-codec-1.11.jar
+libs.commons-codec.displayName=Commons Codec 1.11
 libs.commons-codec.javadoc=\
-    https://commons.apache.org/proper/commons-codec/archives/1.10/apidocs/
+    https://commons.apache.org/proper/commons-codec/archives/1.11/apidocs/
 libs.commons-lang3.classpath=\
-    ${base}/commons-lang3/commons-lang3-3.5.jar
-libs.commons-lang3.displayName=Commons Lang3 3.5
+    ${base}/commons-lang3/commons-lang3-3.7.jar
+libs.commons-lang3.displayName=Commons Lang3 3.7
 libs.commons-lang3.javadoc=\
     https://commons.apache.org/proper/commons-lang/javadocs/api-release/
 libs.CopyLibs.classpath=\
index 20ed6fd0d5204e2dc75f22e900de131a7804935a..866d871934c9e10ce5c0957481da395d2a137041 100644 (file)
@@ -18,6 +18,7 @@ package org.mxchange.jcustomercore.utils;
 
 import java.security.SecureRandom;
 import java.text.MessageFormat;
+import java.util.Objects;
 import java.util.Random;
 import org.apache.commons.lang3.StringUtils;
 import org.mxchange.jcustomercore.model.customer.Customer;
@@ -42,6 +43,32 @@ public class Customers {
                RANDOM_NUMBER_GENERATOR = new SecureRandom();
        }
 
+       /**
+        * Compares both customer instances. This method returns -1 if second
+        * instance is null.
+        * <p>
+        * @param customer1 Customer instance 1
+        * @param customer2 Customer instance 2
+        * <p>
+        * @return Comparison value
+        */
+       public static int compare (final Customer customer1, final Customer customer2) {
+               // Check euqality, then at least first must be given
+               if (Objects.equals(customer1, customer2)) {
+                       // Both are same
+                       return 0;
+               } else if (null == customer1) {
+                       // First is null
+                       return -1;
+               } else if (null == customer2) {
+                       // Second is null
+                       return 1;
+               }
+
+               // Invoke compareTo() method
+               return customer1.compareTo(customer2);
+       }
+
        /**
         * Copies all fields from source customer to target customer instance.
         * <p>