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 31577e23d3 Utility class cleanup
31577e23d3 is described below
commit 31577e23d3bbfa2802c14bfb505319c1732bc5fc
Author: James Bognar <[email protected]>
AuthorDate: Wed Oct 29 14:49:26 2025 -0400
Utility class cleanup
---
TODO-completed.md | 54 ++++++++++++++++++++++
TODO.md | 13 ------
.../org/apache/juneau/common/function/Tuple2.java | 2 +-
.../org/apache/juneau/common/function/Tuple3.java | 2 +-
.../org/apache/juneau/common/function/Tuple4.java | 2 +-
.../org/apache/juneau/common/function/Tuple5.java | 2 +-
.../java/org/apache/juneau/common/utils/Utils.java | 18 --------
.../src/main/java/org/apache/juneau/BeanMeta.java | 2 +-
.../java/org/apache/juneau/BeanPropertyMeta.java | 2 +-
.../src/main/java/org/apache/juneau/ClassMeta.java | 2 +-
.../src/main/java/org/apache/juneau/MediaType.java | 2 +-
.../main/java/org/apache/juneau/StringRange.java | 2 +-
.../java/org/apache/juneau/cp/BasicFileFinder.java | 2 +-
.../main/java/org/apache/juneau/cp/LocalDir.java | 2 +-
.../java/org/apache/juneau/reflect/ClassInfo.java | 2 +-
.../java/org/apache/juneau/rest/RestOpContext.java | 2 +-
.../juneau/rest/beans/ResourceDescription.java | 2 +-
.../juneau/rest/staticfile/BasicStaticFiles.java | 2 +-
18 files changed, 69 insertions(+), 46 deletions(-)
diff --git a/TODO-completed.md b/TODO-completed.md
index afd0a6c907..2c77af8f3e 100644
--- a/TODO-completed.md
+++ b/TODO-completed.md
@@ -167,6 +167,60 @@ This file contains TODO items that have been completed and
moved from TODO.md.
- Line 765: `new IllegalArgumentException(f("Object of type {0} could not
be converted to a list."))` → `illegalArg("Object of type {0} could not be
converted to a list.")`
Added static import for `ThrowableUtils` methods. These utility methods
provide cleaner syntax and consistent exception creation with formatted
messages.
+## Static Import Refactoring
+
+- **TODO-39** ✅ Use static imports for all method calls to AnnotationUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for AnnotationUtils
methods.
+
+- **TODO-40** ✅ Use static imports for all method calls to ArrayUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for ArrayUtils
methods.
+
+- **TODO-41** ✅ Use static imports for all method calls to AssertionUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for AssertionUtils
methods.
+
+- **TODO-42** ✅ Use static imports for all method calls to ClassUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for ClassUtils
methods.
+
+- **TODO-43** ✅ Use static imports for all method calls to CollectionUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for CollectionUtils
methods.
+
+- **TODO-44** ✅ Use static imports for all method calls to DateUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for DateUtils
methods.
+
+- **TODO-45** ✅ Use static imports for all method calls to FileUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for FileUtils
methods.
+
+- **TODO-46** ✅ Use static imports for all method calls to IOUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for IOUtils methods.
+
+- **TODO-47** ✅ Use static imports for all method calls to PredicateUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for PredicateUtils
methods.
+
+- **TODO-48** ✅ Use static imports for all method calls to ResourceBundleUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for
ResourceBundleUtils methods.
+
+- **TODO-50** ✅ Use static imports for all method calls to SystemUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for SystemUtils
methods.
+
+- **TODO-51** ✅ Use static imports for all method calls to ThrowableUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for ThrowableUtils
methods.
+
+- **TODO-53** ✅ Use static imports for all method calls to BctUtils.
+ - **Status**: COMPLETED
+ - **Details**: Refactored codebase to use static imports for BctUtils
methods.
+
## Notes
Items are marked as completed when:
diff --git a/TODO.md b/TODO.md
index 8094a4622b..800420d51c 100644
--- a/TODO.md
+++ b/TODO.md
@@ -15,21 +15,8 @@ This file tracks pending tasks for the Apache Juneau
project. For completed item
- [ ] TODO-15 It appears StringUtils is going to become a commonly-used
external class. Let's see if we can enhance it with commonly used string
utility methods.
- [ ] TODO-27 Determine if there are any other good candidates for
Stringifiers and Listifiers.
- [ ] TODO-29 Finish setting up SonarQube analysis in git workflow.
-- [x] TODO-39 Use static imports for all method calls to AnnotationUtils.
-- [x] TODO-40 Use static imports for all method calls to ArrayUtils.
-- [x] TODO-41 Use static imports for all method calls to AssertionUtils.
-- [x] TODO-42 Use static imports for all method calls to ClassUtils.
-- [x] TODO-43 Use static imports for all method calls to CollectionUtils.
-- [x] TODO-44 Use static imports for all method calls to DateUtils.
-- [x] TODO-45 Use static imports for all method calls to FileUtils.
-- [x] TODO-46 Use static imports for all method calls to IOUtils.
-- [x] TODO-47 Use static imports for all method calls to PredicateUtils.
-- [x] TODO-48 Use static imports for all method calls to ResourceBundleUtils.
- [ ] TODO-49 Use static imports for all method calls to StringUtils.
-- [x] TODO-50 Use static imports for all method calls to SystemUtils.
-- [x] TODO-51 Use static imports for all method calls to ThrowableUtils.
- [ ] TODO-52 Use static imports for all method calls to Utils.
-- [x] TODO-53 Use static imports for all method calls to BctUtils.
- [ ] TODO-54 Search for places in code where Calendar should be replaced with
ZonedDateTime.
- [ ] TODO-66 There are two ArrayUtilsTest classes whose tests should be
merged into CollectionUtils_Test.
- [ ] TODO-67 Add to ThrowableUtils: unsupportedOp, ioException.
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple2.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple2.java
index c53c29b347..5661328420 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple2.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple2.java
@@ -62,7 +62,7 @@ public class Tuple2<A,B> {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return o instanceof Tuple2 && eq(this, (Tuple2<?,?>)o, (x, y)
-> eq(x.a, y.a) && eq(x.b, y.b));
+ return o instanceof Tuple2<?,?> o2 && eq(this, o2, (x, y) ->
eq(x.a, y.a) && eq(x.b, y.b));
}
/**
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple3.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple3.java
index 447a500631..3990c3531a 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple3.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple3.java
@@ -68,7 +68,7 @@ public class Tuple3<A,B,C> {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return o instanceof Tuple3 && eq(this, (Tuple3<?,?,?>)o, (x, y)
-> eq(x.a, y.a) && eq(x.b, y.b) && eq(x.c, y.c));
+ return o instanceof Tuple3<?,?,?> o2 && eq(this, o2, (x, y) ->
eq(x.a, y.a) && eq(x.b, y.b) && eq(x.c, y.c));
}
/**
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple4.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple4.java
index 7543face61..b372ee06b5 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple4.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple4.java
@@ -74,7 +74,7 @@ public class Tuple4<A,B,C,D> {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return o instanceof Tuple4 && eq(this, (Tuple4<?,?,?,?>)o, (x,
y) -> eq(x.a, y.a) && eq(x.b, y.b) && eq(x.c, y.c) && eq(x.d, y.d));
+ return o instanceof Tuple4<?,?,?,?> o2 && eq(this, o2, (x, y)
-> eq(x.a, y.a) && eq(x.b, y.b) && eq(x.c, y.c) && eq(x.d, y.d));
}
/**
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple5.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple5.java
index e99657e7d1..3be21a81cf 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple5.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/function/Tuple5.java
@@ -80,7 +80,7 @@ public class Tuple5<A,B,C,D,E> {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return o instanceof Tuple5 && eq(this, (Tuple5<?,?,?,?,?>)o,
(x, y) -> eq(x.a, y.a) && eq(x.b, y.b) && eq(x.c, y.c) && eq(x.d, y.d) &&
eq(x.e, y.e));
+ return o instanceof Tuple5<?,?,?,?,?> o2 && eq(this, o2, (x, y)
-> eq(x.a, y.a) && eq(x.b, y.b) && eq(x.c, y.c) && eq(x.d, y.d) && eq(x.e,
y.e));
}
/**
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/Utils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/Utils.java
index 40589e3801..33d09cd00f 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/Utils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/Utils.java
@@ -206,24 +206,6 @@ public class Utils {
return Objects.equals(o1, o2);
}
- // TODO: Update instanceof patterns throughout the code to use pattern
matching (Java 16+).
- // This simplifies equals() methods by eliminating explicit casts.
- //
- // Examples to find and update:
- // Old pattern: return super.equals(o) && o instanceof Type &&
eq(this, (Type)o, (x, y) -> ...);
- // New pattern: return super.equals(o) && o instanceof Type o2 &&
eq(this, o2, (x, y) -> ...);
- //
- // Old pattern: return (o instanceof Type) && eq(this, (Type)o, (x,
y) -> ...);
- // New pattern: return (o instanceof Type o2) && eq(this, o2, (x, y)
-> ...);
- //
- // Search pattern: "instanceof.*&&.*eq\(this,.*\("
- // Found ~15 instances in:
- // - BasicStaticFiles.java, ClassInfo.java, RestOpContext.java,
ClassMeta.java, BeanMeta.java,
- // BasicFileFinder.java, BeanPropertyMeta.java, StringRange.java,
MediaType.java, LocalDir.java,
- // Tuple2.java, Tuple3.java, Tuple4.java, Tuple5.java,
ResourceDescription.java
- // Already updated:
- // - LinkString.java, NestedTokenizer.java (Token inner class)
-
/**
* Tests two objects for equality, gracefully handling nulls.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
index 9a686aa3ab..3812f5145b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
@@ -922,7 +922,7 @@ public class BeanMeta<T> {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return (o instanceof BeanMeta) && eq(this, (BeanMeta<?>)o, (x,
y) -> eq(x.classMeta, y.classMeta));
+ return (o instanceof BeanMeta<?> o2) && eq(this, o2, (x, y) ->
eq(x.classMeta, y.classMeta));
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index a99bc32cc5..b83c900972 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -618,7 +618,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return (o instanceof BeanPropertyMeta) && eq(this,
(BeanPropertyMeta)o, (x, y) -> eq(x.name, y.name) && eq(x.beanMeta,
y.beanMeta));
+ return (o instanceof BeanPropertyMeta o2) && eq(this, o2, (x,
y) -> eq(x.name, y.name) && eq(x.beanMeta, y.beanMeta));
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
index 1350636b39..89e9c855fd 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
@@ -850,7 +850,7 @@ public class ClassMeta<T> implements Type {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return (o instanceof ClassMeta) && eq(this, (ClassMeta<?>)o,
(x, y) -> eq(x.innerClass, y.innerClass));
+ return (o instanceof ClassMeta<?> o2) && eq(this, o2, (x, y) ->
eq(x.innerClass, y.innerClass));
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/MediaType.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/MediaType.java
index 38ebeec223..41db9a0dec 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/MediaType.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/MediaType.java
@@ -216,7 +216,7 @@ public class MediaType implements Comparable<MediaType> {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return (o instanceof MediaType) && eq(this, (MediaType)o, (x,
y) -> eq(x.string, y.string));
+ return (o instanceof MediaType o2) && eq(this, o2, (x, y) ->
eq(x.string, y.string));
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/StringRange.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/StringRange.java
index 53e7f89bd9..b41518237f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/StringRange.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/StringRange.java
@@ -116,7 +116,7 @@ public class StringRange {
*/
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return (o instanceof StringRange) && eq(this, (StringRange)o,
(x, y) -> eq(x.string, y.string));
+ return (o instanceof StringRange o2) && eq(this, o2, (x, y) ->
eq(x.string, y.string));
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BasicFileFinder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BasicFileFinder.java
index a6890ef252..5967898d38 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BasicFileFinder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BasicFileFinder.java
@@ -97,7 +97,7 @@ public class BasicFileFinder implements FileFinder {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return o instanceof BasicFileFinder && eq(this,
(BasicFileFinder)o, (x, y) -> eq(x.hashCode, y.hashCode) && eq(x.getClass(),
y.getClass()) && eq(x.roots, y.roots)
+ return o instanceof BasicFileFinder o2 && eq(this, o2, (x, y)
-> eq(x.hashCode, y.hashCode) && eq(x.getClass(), y.getClass()) && eq(x.roots,
y.roots)
&& eq(x.cachingLimit, y.cachingLimit) &&
eq(x.includePatterns, y.includePatterns) && eq(x.excludePatterns,
y.excludePatterns));
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/LocalDir.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/LocalDir.java
index 26b8469cc4..9aa4b6428a 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/LocalDir.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/LocalDir.java
@@ -73,7 +73,7 @@ public class LocalDir {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return o instanceof LocalDir && eq(this, (LocalDir)o, (x, y) ->
eq(x.clazz, y.clazz) && eq(x.clazzPath, y.clazzPath) && eq(x.path, y.path));
+ return o instanceof LocalDir o2 && eq(this, o2, (x, y) ->
eq(x.clazz, y.clazz) && eq(x.clazzPath, y.clazzPath) && eq(x.path, y.path));
}
@Override /* Overridden from Object */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
index 625e8e4353..71e67118ff 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
@@ -370,7 +370,7 @@ public class ClassInfo {
@Override
public boolean equals(Object o) {
- return (o instanceof ClassInfo) && eq(this, (ClassInfo)o, (x,
y) -> eq(x.t, y.t));
+ return (o instanceof ClassInfo o2) && eq(this, o2, (x, y) ->
eq(x.t, y.t));
}
/**
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 29f1a26036..ae67e8031c 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
@@ -2286,7 +2286,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return (o instanceof RestOpContext) && eq(this,
(RestOpContext)o, (x, y) -> x.method.equals(y.method));
+ return (o instanceof RestOpContext o2) && eq(this, o2, (x, y)
-> x.method.equals(y.method));
}
/**
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/ResourceDescription.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/ResourceDescription.java
index 5391754be8..61212bc4f0 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/ResourceDescription.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/ResourceDescription.java
@@ -90,7 +90,7 @@ public class ResourceDescription implements
Comparable<ResourceDescription> {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return (o instanceof ResourceDescription) && eq(this,
(ResourceDescription)o, (x, y) -> eq(x.getName(), y.getName()));
+ return (o instanceof ResourceDescription o2) && eq(this, o2,
(x, y) -> eq(x.getName(), y.getName()));
}
/**
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/staticfile/BasicStaticFiles.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/staticfile/BasicStaticFiles.java
index 850fcf85d2..2d57c9584c 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/staticfile/BasicStaticFiles.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/staticfile/BasicStaticFiles.java
@@ -111,7 +111,7 @@ public class BasicStaticFiles implements StaticFiles {
@Override /* Overridden from Object */
public boolean equals(Object o) {
- return super.equals(o) && o instanceof BasicStaticFiles &&
eq(this, (BasicStaticFiles)o, (x, y) -> eq(x.headers, y.headers));
+ return super.equals(o) && o instanceof BasicStaticFiles o2 &&
eq(this, o2, (x, y) -> eq(x.headers, y.headers));
}
@Override /* Overridden from FileFinder */