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

commit 079612c6d51d4fdd9174a5ce8bf02a97a15c9e98
Author: James Bognar <[email protected]>
AuthorDate: Fri Nov 7 13:03:34 2025 -0500

    Utility class modernization
---
 .../apache/juneau/common/reflect/ClassInfo.java    | 11 ------
 .../apache/juneau/common/reflect/MethodInfo.java   | 12 ------
 .../apache/juneau/common/reflect/PackageInfo.java  | 10 ++---
 .../juneau/common/reflect/ParameterInfo.java       | 46 ++++------------------
 .../org/apache/juneau/httppart/HttpPartSchema.java |  2 +-
 .../juneau/common/reflect/ParamInfoTest.java       |  2 +-
 .../org/apache/juneau/reflect/ParamInfoTest.java   |  2 +-
 7 files changed, 16 insertions(+), 69 deletions(-)

diff --git 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
index 447e82bfd5..c903c4382e 100644
--- 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
+++ 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
@@ -1649,17 +1649,6 @@ public class ClassInfo extends ElementInfo implements 
Annotatable {
                return innerType.hashCode();
        }
 
-       /**
-        * Returns <jk>true</jk> if this class doesn't have the specified 
annotation.
-        *
-        * @param <A> The annotation type to look for.
-        * @param type The annotation to look for.
-        * @return The <jk>true</jk> if annotation if not found.
-        */
-       public <A extends Annotation> boolean hasNoAnnotation(Class<A> type) {
-               return ! hasAnnotation(type);
-       }
-
        /**
         * Returns <jk>true</jk> if this class is not in the root package.
         *
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 72193d6bdb..a8fcb9a890 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
@@ -500,18 +500,6 @@ public class MethodInfo extends ExecutableInfo implements 
Comparable<MethodInfo>
                return hasAllParameters(requiredParam);
        }
 
-       /**
-        * Returns <jk>true</jk> if the specified annotation is not present on 
this method.
-        *
-        * @param <A> The annotation type to look for.
-        * @param annotationProvider The annotation provider.
-        * @param type The annotation to look for.
-        * @return <jk>true</jk> if the specified annotation is not present on 
this method.
-        */
-       public <A extends Annotation> boolean 
hasNoAnnotation(AnnotationProvider annotationProvider, Class<A> type) {
-               return ! hasAnnotation(annotationProvider, type);
-       }
-
        /**
         * Returns <jk>true</jk> if this method has this return type.
         *
diff --git 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/PackageInfo.java
 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/PackageInfo.java
index 43eb71a446..cce4f54afe 100644
--- 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/PackageInfo.java
+++ 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/PackageInfo.java
@@ -275,7 +275,7 @@ public class PackageInfo implements Annotatable {
         * @return This package's annotation for the specified annotation type 
wrapped in AnnotationInfo, or <jk>null</jk> if not present.
         */
        public <A extends Annotation> AnnotationInfo<A> getAnnotation(Class<A> 
annotationClass) {
-               return getAnnotations(annotationClass)
+               return getAnnotationInfos(annotationClass)
                        .findFirst()
                        .orElse(null);
        }
@@ -300,13 +300,13 @@ public class PackageInfo implements Annotatable {
         * Filters the cached annotations list by type.
         *
         * @param <A> The annotation type.
-        * @param annotationClass The Class object corresponding to the 
annotation type.
-        * @return All this package's annotations of the specified type wrapped 
in AnnotationInfo, or an empty list if there are none.
+        * @param type The annotation type.
+        * @return A stream of annotation infos of the specified type, never 
<jk>null</jk>.
         */
        @SuppressWarnings("unchecked")
-       public <A extends Annotation> Stream<AnnotationInfo<A>> 
getAnnotations(Class<A> annotationClass) {
+       public <A extends Annotation> Stream<AnnotationInfo<A>> 
getAnnotationInfos(Class<A> type) {
                return getAnnotations().stream()
-                       .filter(ai -> annotationClass.isInstance(ai.inner()))
+                       .filter(ai -> type.isInstance(ai.inner()))
                        .map(ai -> (AnnotationInfo<A>)ai);
        }
 
diff --git 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ParameterInfo.java
 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ParameterInfo.java
index c695eb2f13..f9ec08ca5a 100644
--- 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ParameterInfo.java
+++ 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ParameterInfo.java
@@ -187,8 +187,15 @@ public class ParameterInfo extends ElementInfo implements 
Annotatable {
                return this;
        }
 
+       /**
+        * Returns a stream of annotation infos of the specified type declared 
on this parameter.
+        *
+        * @param <A> The annotation type.
+        * @param type The annotation type.
+        * @return A stream of annotation infos, never <jk>null</jk>.
+        */
        @SuppressWarnings("unchecked")
-       public <A extends Annotation> Stream<AnnotationInfo<A>> 
getAnnotations(Class<A> type) {
+       public <A extends Annotation> Stream<AnnotationInfo<A>> 
getAnnotationInfos(Class<A> type) {
                return getAnnotationInfos().stream().filter(x -> 
x.isType(type)).map(x -> (AnnotationInfo<A>)x);
        }
 
@@ -460,18 +467,6 @@ public class ParameterInfo extends ElementInfo implements 
Annotatable {
                return getResolvedName() != null;
        }
 
-       /**
-        * Returns <jk>true</jk> if this parameter doesn't have the specified 
annotation.
-        *
-        * @param <A> The annotation type to look for.
-        * @param type The annotation type to look for.
-        * @return
-        *      The <jk>true</jk> if annotation if not found.
-        */
-       public <A extends Annotation> boolean hasNoAnnotation(Class<A> type) {
-               return ! hasAnnotation(type);
-       }
-
        /**
         * Returns <jk>true</jk> if the parameter type is an exact match for 
the specified class.
         *
@@ -723,31 +718,6 @@ public class ParameterInfo extends ElementInfo implements 
Annotatable {
                return inner.getDeclaredAnnotations();
        }
 
-       /**
-        * Returns this element's annotations of the specified type (including 
repeated annotations).
-        *
-        * <p>
-        * Same as calling {@link Parameter#getAnnotationsByType(Class)}.
-        *
-        * <p>
-        * This method handles repeatable annotations by "looking through" 
container annotations.
-        *
-        * <h5 class='section'>Example:</h5>
-        * <p class='bjava'>
-        *      <jc>// Get all @Author annotations (including repeated): 
@Authors({@Author(...), @Author(...)})</jc>
-        *      ParameterInfo <jv>pi</jv> = ...;
-        *      Author[] <jv>authors</jv> = 
<jv>pi</jv>.getAnnotationsByType(Author.<jk>class</jk>);
-        * </p>
-        *
-        * @param <A> The annotation type.
-        * @param annotationClass The Class object corresponding to the 
annotation type.
-        * @return All this element's annotations of the specified type, or an 
empty array if there are none.
-        * @see Parameter#getAnnotationsByType(Class)
-        */
-       public <A extends Annotation> A[] getAnnotationsByType(Class<A> 
annotationClass) {
-               return inner.getAnnotationsByType(annotationClass);
-       }
-
        /**
         * Returns this element's declared annotations of the specified type 
(including repeated annotations).
         *
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index d1e47c9c31..f6205c8d9e 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -2564,7 +2564,7 @@ public class HttpPartSchema {
 
                Builder apply(Class<? extends Annotation> c, ParameterInfo mpi) 
{
                        apply(c, mpi.getParameterType().innerType());
-                       mpi.getAnnotations(c).forEach(x -> apply(x.inner()));
+                       mpi.getAnnotationInfos(c).forEach(x -> 
apply(x.inner()));
                        return this;
                }
 
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ParamInfoTest.java
 
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ParamInfoTest.java
index f6614bac82..c0fd4e45a1 100644
--- 
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ParamInfoTest.java
+++ 
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ParamInfoTest.java
@@ -210,7 +210,7 @@ class ParamInfoTest extends TestBase {
        }
 
        private static <T extends Annotation> List<T> 
declaredAnnotations(ParameterInfo pi, Class<T> type) {
-               return pi.getAnnotations(type).map(x -> x.inner()).toList();
+               return pi.getAnnotationInfos(type).map(x -> x.inner()).toList();
        }
 
        @Test void getDeclaredAnnotation() {
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java 
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
index 1e462ff745..9f88db14e8 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
@@ -187,7 +187,7 @@ class ParamInfoTest extends TestBase {
        }
 
        private static <T extends Annotation> List<T> 
declaredAnnotations(ParameterInfo pi, Class<T> type) {
-               return pi.getAnnotations(type).map(x -> x.inner()).toList();
+               return pi.getAnnotationInfos(type).map(x -> x.inner()).toList();
        }
 
        @Test void getDeclaredAnnotation() {

Reply via email to