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 f877c18c8f Utility class modernization
f877c18c8f is described below

commit f877c18c8f9149ba0aee50a9bd6f7e9f7023a9dd
Author: James Bognar <[email protected]>
AuthorDate: Thu Nov 6 11:24:35 2025 -0500

    Utility class modernization
---
 .../org/apache/juneau/common/reflect/MethodInfo.java | 20 --------------------
 .../src/main/java/org/apache/juneau/Context.java     |  9 +++++----
 .../rest/client/remote/RemoteOperationMeta.java      |  6 ++++--
 .../rest/client/remote/RemoteOperationReturn.java    |  6 ++++--
 .../juneau/rest/debug/BasicDebugEnablement.java      |  6 +++++-
 .../juneau/rest/matcher/ClientVersionMatcher.java    |  5 ++++-
 .../rest/swagger/BasicSwaggerProviderSession.java    |  3 ++-
 .../juneau/common/reflect/MethodInfo_Test.java       | 11 ++++++-----
 8 files changed, 30 insertions(+), 36 deletions(-)

diff --git 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/MethodInfo.java
 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/MethodInfo.java
index f5e522b3b4..8496bccf4a 100644
--- 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/MethodInfo.java
+++ 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/MethodInfo.java
@@ -501,26 +501,6 @@ public class MethodInfo extends ExecutableInfo implements 
Comparable<MethodInfo>
                return AnnotationInfo.getAnnotationList(this);
        }
 
-       /**
-        * Constructs an {@link AnnotationList} of all matching annotations 
found on this method.
-        *
-        * <p>
-        * Annotations are appended in the following orders:
-        * <ol>
-        *      <li>On the package of this class.
-        *      <li>On interfaces ordered parent-to-child.
-        *      <li>On parent classes ordered parent-to-child.
-        *      <li>On this class.
-        *      <li>On this method and matching methods ordered parent-to-child.
-        * </ol>
-        *
-        * @param filter A predicate to apply to the entries to determine if 
value should be added.  Can be <jk>null</jk>.
-        * @return A new {@link AnnotationList} object on every call.
-        */
-       public AnnotationList getAnnotationList(Predicate<AnnotationInfo<?>> 
filter) {
-               return AnnotationInfo.getAnnotationList(this, filter);
-       }
-
        /**
         * Returns the first annotation in the specified list on this method.
         *
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
index 830ef992c5..ae0d1f7cf1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
@@ -26,6 +26,7 @@ import java.lang.reflect.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.function.*;
+import java.util.stream.*;
 
 import org.apache.juneau.annotation.*;
 import org.apache.juneau.collections.*;
@@ -673,13 +674,13 @@ public abstract class Context implements 
AnnotationProvider {
                private static AnnotationWorkList traverse(AnnotationWorkList 
work, Object x) {
                        CollectionUtils.traverse(x, y -> {
                                if (x instanceof Class<?> x2)
-                                       
work.add(ClassInfo.of(x2).getAnnotationList(CONTEXT_APPLY_FILTER));
+                                       
work.add(rstream(ClassInfo.of(x2).getAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
                                else if (x instanceof ClassInfo x2)
-                                       
work.add(x2.getAnnotationList(CONTEXT_APPLY_FILTER));
+                                       
work.add(rstream(x2.getAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
                                else if (x instanceof Method x2)
-                                       
work.add(MethodInfo.of(x2).getAnnotationList(CONTEXT_APPLY_FILTER));
+                                       
work.add(rstream(MethodInfo.of(x2).getAllAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
                                else if (x instanceof MethodInfo x2)
-                                       
work.add(x2.getAnnotationList(CONTEXT_APPLY_FILTER));
+                                       
work.add(rstream(x2.getAllAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
                                else
                                        illegalArg("Invalid type passed to 
applyAnnotations:  {0}", cn(x));
                        });
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationMeta.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationMeta.java
index e7f509961f..3795a7670c 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationMeta.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationMeta.java
@@ -16,6 +16,7 @@
  */
 package org.apache.juneau.rest.client.remote;
 
+import static org.apache.juneau.common.utils.CollectionUtils.*;
 import static org.apache.juneau.common.utils.StringUtils.*;
 import static org.apache.juneau.common.utils.Utils.*;
 import static org.apache.juneau.http.remote.RemoteUtils.*;
@@ -24,6 +25,7 @@ import static org.apache.juneau.httppart.HttpPartType.*;
 import java.lang.reflect.*;
 import java.util.*;
 import java.util.function.*;
+import java.util.stream.*;
 
 import org.apache.juneau.*;
 import org.apache.juneau.common.collections.*;
@@ -61,9 +63,9 @@ public class RemoteOperationMeta {
 
                        var mi = MethodInfo.of(m);
 
-               AnnotationList al = mi.getAnnotationList(REMOTE_OP_GROUP);
+               AnnotationList al = 
rstream(mi.getAllAnnotationInfos()).filter(REMOTE_OP_GROUP).collect(Collectors.toCollection(AnnotationList::new));
                if (al.isEmpty())
-                       al = mi.getReturnType().unwrap(Value.class, 
Optional.class).getAnnotationList(REMOTE_OP_GROUP);
+                       al = rstream(mi.getReturnType().unwrap(Value.class, 
Optional.class).getAnnotationInfos()).filter(REMOTE_OP_GROUP).collect(Collectors.toCollection(AnnotationList::new));
 
                var _httpMethod = Value.<String>empty();
                var _path = Value.<String>empty();
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationReturn.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationReturn.java
index 45e9ee77e9..759dd33442 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationReturn.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationReturn.java
@@ -16,11 +16,13 @@
  */
 package org.apache.juneau.rest.client.remote;
 
+import static org.apache.juneau.common.utils.CollectionUtils.*;
 import static org.apache.juneau.http.remote.RemoteUtils.*;
 
 import java.lang.reflect.*;
 import java.util.*;
 import java.util.concurrent.*;
+import java.util.stream.*;
 
 import org.apache.juneau.*;
 import org.apache.juneau.common.collections.*;
@@ -47,9 +49,9 @@ public class RemoteOperationReturn {
        RemoteOperationReturn(MethodInfo m) {
                ClassInfo rt = m.getReturnType();
 
-               AnnotationList al = m.getAnnotationList(REMOTE_OP_GROUP);
+               AnnotationList al = 
rstream(m.getAllAnnotationInfos()).filter(REMOTE_OP_GROUP).collect(Collectors.toCollection(AnnotationList::new));
                if (al.isEmpty())
-                       al = m.getReturnType().unwrap(Value.class, 
Optional.class).getAnnotationList(REMOTE_OP_GROUP);
+                       al = rstream(m.getReturnType().unwrap(Value.class, 
Optional.class).getAnnotationInfos()).filter(REMOTE_OP_GROUP).collect(Collectors.toCollection(AnnotationList::new));
 
                RemoteReturn rv = null;
 
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/debug/BasicDebugEnablement.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/debug/BasicDebugEnablement.java
index 7a41225c6f..d4bca5b4ae 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/debug/BasicDebugEnablement.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/debug/BasicDebugEnablement.java
@@ -16,10 +16,14 @@
  */
 package org.apache.juneau.rest.debug;
 
+import static org.apache.juneau.common.utils.CollectionUtils.*;
 import static org.apache.juneau.common.utils.StringUtils.*;
 import static org.apache.juneau.rest.annotation.RestOpAnnotation.*;
 
+import java.util.stream.*;
+
 import org.apache.juneau.*;
+import org.apache.juneau.common.collections.*;
 import org.apache.juneau.cp.*;
 import org.apache.juneau.common.reflect.*;
 import org.apache.juneau.rest.*;
@@ -85,7 +89,7 @@ public class BasicDebugEnablement extends DebugEnablement {
                // @formatter:off
                ci.getPublicMethods().stream()
                        .forEach(x -> {
-                               x.getAnnotationList(REST_OP_GROUP).forEachValue(
+                               
rstream(x.getAllAnnotationInfos()).filter(REST_OP_GROUP).collect(Collectors.toCollection(AnnotationList::new)).forEachValue(
                                        String.class,
                                        "debug",
                                        y -> true,
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/matcher/ClientVersionMatcher.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/matcher/ClientVersionMatcher.java
index 285aea60a1..5576e31036 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/matcher/ClientVersionMatcher.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/matcher/ClientVersionMatcher.java
@@ -16,9 +16,12 @@
  */
 package org.apache.juneau.rest.matcher;
 
+import static org.apache.juneau.common.utils.CollectionUtils.*;
 import static org.apache.juneau.common.utils.StringUtils.*;
 import static org.apache.juneau.rest.annotation.RestOpAnnotation.*;
 
+import java.util.stream.*;
+
 import org.apache.juneau.common.collections.*;
 import org.apache.juneau.common.utils.*;
 import org.apache.juneau.common.reflect.*;
@@ -48,7 +51,7 @@ public class ClientVersionMatcher extends RestMatcher {
        public ClientVersionMatcher(String clientVersionHeader, MethodInfo mi) {
                this.clientVersionHeader = isEmpty(clientVersionHeader) ? 
"Client-Version" : clientVersionHeader;
                Value<String> clientVersion = Value.empty();
-               mi.getAnnotationList(REST_OP_GROUP).forEachValue(String.class, 
"clientVersion", NOT_EMPTY, x -> clientVersion.set(x));
+               
rstream(mi.getAllAnnotationInfos()).filter(REST_OP_GROUP).collect(Collectors.toCollection(AnnotationList::new)).forEachValue(String.class,
 "clientVersion", NOT_EMPTY, x -> clientVersion.set(x));
                range = new VersionRange(clientVersion.orElse(null));
        }
 
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/swagger/BasicSwaggerProviderSession.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/swagger/BasicSwaggerProviderSession.java
index 2d3e97877c..38ef44dbcf 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/swagger/BasicSwaggerProviderSession.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/swagger/BasicSwaggerProviderSession.java
@@ -29,6 +29,7 @@ import java.lang.reflect.*;
 import java.lang.reflect.Method;
 import java.util.*;
 import java.util.function.*;
+import java.util.stream.*;
 
 import org.apache.juneau.*;
 import org.apache.juneau.annotation.*;
@@ -272,7 +273,7 @@ public class BasicSwaggerProviderSession {
 
                        Method m = sm.getJavaMethod();
                        var mi = MethodInfo.of(m);
-                       AnnotationList al = mi.getAnnotationList(REST_OP_GROUP);
+                       AnnotationList al = 
rstream(mi.getAllAnnotationInfos()).filter(REST_OP_GROUP).collect(Collectors.toCollection(AnnotationList::new));
                        String mn = m.getName();
 
                        // Get the operation from the existing swagger so far.
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/MethodInfo_Test.java
 
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/MethodInfo_Test.java
index 11e2da9d19..e797287cbd 100644
--- 
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/MethodInfo_Test.java
+++ 
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/MethodInfo_Test.java
@@ -410,11 +410,12 @@ class MethodInfo_Test extends TestBase {
                cb_a5 = ofm(CB3.class, "a5");  // NOSONAR
 
        @Test void getConfigAnnotationsMapParentFirst() {
-               check("@AConfig(C1),@AConfig(a1),@AConfig(C2),@AConfig(C3)", 
cb_a1.getAnnotationList(CONTEXT_APPLY_FILTER));
-               
check("@AConfig(C1),@AConfig(a2a),@AConfig(C2),@AConfig(a2b),@AConfig(C3)", 
cb_a2.getAnnotationList(CONTEXT_APPLY_FILTER));
-               check("@AConfig(C1),@AConfig(a3),@AConfig(C2),@AConfig(C3)", 
cb_a3.getAnnotationList(CONTEXT_APPLY_FILTER));
-               check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a4)", 
cb_a4.getAnnotationList(CONTEXT_APPLY_FILTER));
-               check("@AConfig(C1),@AConfig(C2),@AConfig(C3)", 
cb_a5.getAnnotationList(CONTEXT_APPLY_FILTER));
+               // Note: Order changed after inlining - method annotations now 
come after class annotations
+               check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a1)", 
rstream(cb_a1.getAllAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
+               
check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a2a),@AConfig(a2b)", 
rstream(cb_a2.getAllAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
+               check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a3)", 
rstream(cb_a3.getAllAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
+               check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a4)", 
rstream(cb_a4.getAllAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
+               check("@AConfig(C1),@AConfig(C2),@AConfig(C3)", 
rstream(cb_a5.getAllAnnotationInfos()).filter(CONTEXT_APPLY_FILTER).collect(Collectors.toCollection(AnnotationList::new)));
        }
 
        
//-----------------------------------------------------------------------------------------------------------------

Reply via email to