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 a10fb9c86 Test modernization, clean up utility classes.
a10fb9c86 is described below
commit a10fb9c86da7ab662f1c91752194e73fe39f17b3
Author: James Bognar <[email protected]>
AuthorDate: Mon Aug 25 11:18:17 2025 -0400
Test modernization, clean up utility classes.
---
.../org/apache/juneau/common/internal/Utils.java | 28 +++++++++++++++
.../org/apache/juneau/internal/ObjectUtils.java | 42 ----------------------
.../apache/juneau/objecttools/ObjectSorter.java | 4 +--
.../java/org/apache/juneau/rest/RestOpContext.java | 10 +++---
4 files changed, 35 insertions(+), 49 deletions(-)
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 eb6be6ae5..b86c317f4 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
@@ -540,4 +540,32 @@ public class Utils {
if (value.getClass().isArray()) return Array.getLength(value) >
0;
return StringUtils.isNotEmpty(s(value));
}
+
+ /**
+ * Compares two objects for equality.
+ *
+ * <p>
+ * Nulls are always considered less-than unless both are null.
+ *
+ * @param o1 Object 1.
+ * @param o2 Object 2.
+ * @return
+ * <c>-1</c>, <c>0</c>, or <c>1</c> if <c>o1</c> is less-than,
equal, or greater-than <c>o2</c>.
+ * <br><c>0</c> if objects are not of the same type or do not
implement the {@link Comparable} interface.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static int compare(Object o1, Object o2) {
+ if (o1 == null) {
+ if (o2 == null)
+ return 0;
+ return -1;
+ } else if (o2 == null) {
+ return 1;
+ }
+
+ if (o1.getClass() == o2.getClass() && o1 instanceof Comparable)
+ return ((Comparable)o1).compareTo(o2);
+
+ return 0;
+ }
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ObjectUtils.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ObjectUtils.java
index 68baa6349..f15259c97 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ObjectUtils.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ObjectUtils.java
@@ -30,48 +30,6 @@ import org.apache.juneau.reflect.*;
*/
public class ObjectUtils {
- /**
- * Compares two objects for equality.
- *
- * <p>
- * Nulls are always considered less-than unless both are null.
- *
- * @param o1 Object 1.
- * @param o2 Object 2.
- * @return
- * <c>-1</c>, <c>0</c>, or <c>1</c> if <c>o1</c> is less-than,
equal, or greater-than <c>o2</c>.
- * <br><c>0</c> if objects are not of the same type or do not
implement the {@link Comparable} interface.
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public static int compare(Object o1, Object o2) {
- if (o1 == null) {
- if (o2 == null)
- return 0;
- return -1;
- } else if (o2 == null) {
- return 1;
- }
-
- if (o1.getClass() == o2.getClass() && o1 instanceof Comparable)
- return ((Comparable)o1).compareTo(o2);
-
- return 0;
- }
-
- /**
- * Compare two integers numerically.
- *
- * @param i1 Integer #1
- * @param i2 Integer #2
- * @return
- * The value <c>0</c> if Integer #1 is equal to Integer #2; a
value less than <c>0</c> if
- * Integer #1 numerically less than Integer #2; and a value
greater than <c>0</c> if Integer #1 is
- * numerically greater than Integer #2 (signed comparison).
- */
- public static final int compare(int i1, int i2) {
- return (i1<i2 ? -1 : (i1==i2 ? 0 : 1));
- }
-
/**
* Tests two objects for equality, gracefully handling nulls.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
index 2abf1c740..6adcdea3b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
@@ -173,8 +173,8 @@ public final class ObjectSorter implements
ObjectTool<SortArgs> {
@Override
public int compareTo(Object o) {
if (isDesc)
- return
ObjectUtils.compare(((SortEntry)o).sortVal, this.sortVal);
- return ObjectUtils.compare(this.sortVal,
((SortEntry)o).sortVal);
+ return Utils.compare(((SortEntry)o).sortVal,
this.sortVal);
+ return Utils.compare(this.sortVal,
((SortEntry)o).sortVal);
}
}
}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
index 4d57c9c47..c3effd5fd 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
@@ -2693,19 +2693,19 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
return c;
}
- c = ObjectUtils.compare(o.hierarchyDepth, hierarchyDepth);
+ c = Utils.compare(o.hierarchyDepth, hierarchyDepth);
if (c != 0)
return c;
- c = ObjectUtils.compare(o.requiredMatchers.length,
requiredMatchers.length);
+ c = Utils.compare(o.requiredMatchers.length,
requiredMatchers.length);
if (c != 0)
return c;
- c = ObjectUtils.compare(o.optionalMatchers.length,
optionalMatchers.length);
+ c = Utils.compare(o.optionalMatchers.length,
optionalMatchers.length);
if (c != 0)
return c;
- c = ObjectUtils.compare(o.guards.length, guards.length);
+ c = Utils.compare(o.guards.length, guards.length);
if (c != 0)
return c;
@@ -2714,7 +2714,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
if (c != 0)
return c;
- c = ObjectUtils.compare(method.getParameterCount(),
o.method.getParameterCount());
+ c = Utils.compare(method.getParameterCount(),
o.method.getParameterCount());
if (c != 0)
return c;