This is an automated email from the ASF dual-hosted git repository.

doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/master by this push:
     new 981c4e8  EMPIREDB-282 new compareEqual methods for convenience
981c4e8 is described below

commit 981c4e834abecd7509b6127b73368ab38019f64f
Author: Rainer Döbele <[email protected]>
AuthorDate: Fri Dec 6 18:04:59 2019 +0100

    EMPIREDB-282
    new compareEqual methods for convenience
---
 .../org/apache/empire/commons/StringUtils.java     | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java 
b/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
index b13345b..6b4b088 100644
--- a/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/commons/StringUtils.java
@@ -225,11 +225,54 @@ public class StringUtils
     {
         if (s1==null || s2==null)
             return (s1==s2);
+        // Empty
+        if (isEmpty(s1) && isEmpty(s2))
+            return true;
         // Compare 
         return (ignoreCase) ? s1.equalsIgnoreCase(s2) : s1.equals(s2);
     }
     
     /**
+     * Compares two Strings with each other - either with or without character 
case. Both arguments may be null.
+     * @param s1 the first String
+     * @param s2 the second String
+     * @return true if the two strings supplied are equal 
+     */
+    public static boolean compareEqual(String s1, String s2)
+    {
+        if (s1==null || s2==null)
+            return (s1==s2);
+        // Empty
+        if (isEmpty(s1) && isEmpty(s2))
+            return true;
+        // Compare 
+        return s1.equals(s2);
+    }
+    
+    /**
+     * Compares two Strings with each other - either with or without character 
case. Both arguments may be null.
+     * @param s1 the first String
+     * @param s2 the second String
+     * @param ignoreCase whether to ignore the character casing or not
+     * @return true if the two strings supplied are not equal 
+     */
+    public static boolean compareNotEqual(String s1, String s2, boolean 
ignoreCase)
+    {
+        return !compareEqual(s1, s2, ignoreCase);
+    }
+    
+    /**
+     * Compares two Strings with each other - either with or without character 
case. Both arguments may be null.
+     * @param s1 the first String
+     * @param s2 the second String
+     * @return true if the two strings supplied are not equal 
+     */
+    public static boolean compareNotEqual(String s1, String s2)
+    {
+        return !compareEqual(s1, s2);
+    }
+    
+    /**
      * Validates a given string. If the string is empty then null is returned. 
      * Otherwise the trimmed string is returned.
      * 

Reply via email to