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

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 56fb7767e Test modernization, clean up utility classes.
56fb7767e is described below

commit 56fb7767e75aee6e83c678a0aa09f4dde83dad8e
Author: James Bognar <[email protected]>
AuthorDate: Mon Aug 25 15:18:40 2025 -0400

    Test modernization, clean up utility classes.
---
 .../apache/juneau/common/internal/StringUtils.java | 18 +++-------
 .../org/apache/juneau/common/internal/Utils.java   | 38 ++++++++++++++++++++++
 2 files changed, 43 insertions(+), 13 deletions(-)

diff --git 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
index 8798fe7db..988ad9403 100644
--- 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
+++ 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/StringUtils.java
@@ -1307,11 +1307,7 @@ public final class StringUtils {
         * @return <jk>true</jk> if the strings are equal.
         */
        public static boolean eq3(String s1, String s2) {
-               if (s1 == null)
-                       return s2 == null;
-               if (s2 == null)
-                       return false;
-               return s1.equals(s2);
+               return Utils.eq(s1, s2);
        }
 
        /**
@@ -1323,7 +1319,7 @@ public final class StringUtils {
         * @return <jk>true</jk> if the strings are equal.
         */
        public static boolean eq3(boolean caseInsensitive, String s1, String 
s2) {
-               return caseInsensitive ? eqic3(s1, s2) : eq3(s1, s2);
+               return Utils.eq(caseInsensitive, s1, s2);
        }
 
        /**
@@ -1380,11 +1376,7 @@ public final class StringUtils {
         * @return <jk>true</jk> if the strings are equal.
         */
        public static boolean eqic3(String s1, String s2) {
-               if (s1 == null)
-                       return s2 == null;
-               if (s2 == null)
-                       return false;
-               return s1.equalsIgnoreCase(s2);
+               return Utils.eqic(s1, s2);
        }
 
        /**
@@ -1395,7 +1387,7 @@ public final class StringUtils {
         * @return <jk>true</jk> if the strings are not equal.
         */
        public static boolean ne3(String s1, String s2) {
-               return ! eq3(s1, s2);
+               return Utils.ne(s1, s2);
        }
 
        /**
@@ -1406,7 +1398,7 @@ public final class StringUtils {
         * @return <jk>true</jk> if the strings are not equal ignoring case.
         */
        public static boolean neic3(String s1, String s2) {
-               return ! eqic3(s1, s2);
+               return Utils.neic(s1, s2);
        }
 
        /**
diff --git 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/Utils.java
 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/Utils.java
index 5cfd863a1..b6c3a70d4 100644
--- 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/Utils.java
+++ 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/internal/Utils.java
@@ -701,4 +701,42 @@ public class Utils {
        public static <E> ArrayList<E> listOfSize(int size) {
                return new ArrayList<>(size);
        }
+
+       /**
+        * Tests two strings for equality, but gracefully handles nulls.
+        *
+        * @param caseInsensitive Use case-insensitive matching.
+        * @param s1 String 1.
+        * @param s2 String 2.
+        * @return <jk>true</jk> if the strings are equal.
+        */
+       public static boolean eq(boolean caseInsensitive, String s1, String s2) 
{
+               return caseInsensitive ? eqic(s1, s2) : eq(s1, s2);
+       }
+
+       /**
+        * Tests two strings for case-insensitive equality, but gracefully 
handles nulls.
+        *
+        * @param s1 String 1.
+        * @param s2 String 2.
+        * @return <jk>true</jk> if the strings are equal.
+        */
+       public static boolean eqic(String s1, String s2) {
+               if (s1 == null)
+                       return s2 == null;
+               if (s2 == null)
+                       return false;
+               return s1.equalsIgnoreCase(s2);
+       }
+
+       /**
+        * Tests two strings for non-equality ignoring case, but gracefully 
handles nulls.
+        *
+        * @param s1 String 1.
+        * @param s2 String 2.
+        * @return <jk>true</jk> if the strings are not equal ignoring case.
+        */
+       public static boolean neic(String s1, String s2) {
+               return ! eqic(s1, s2);
+       }
 }
\ No newline at end of file

Reply via email to