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

commit 694dbd4b11f5167443385a352cadc044cb4931cc
Author: James Bognar <[email protected]>
AuthorDate: Thu Nov 6 19:42:24 2025 -0500

    Utility class modernization
---
 .../juneau/common/reflect/AnnotationProvider.java  | 176 ---------------------
 .../juneau/common/reflect/ConstructorInfo.java     |   2 +-
 .../src/main/java/org/apache/juneau/Context.java   |  75 ---------
 3 files changed, 1 insertion(+), 252 deletions(-)

diff --git 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/AnnotationProvider.java
 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/AnnotationProvider.java
index e92397555b..9f0ec93e22 100644
--- 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/AnnotationProvider.java
+++ 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/AnnotationProvider.java
@@ -16,17 +16,6 @@
  */
 package org.apache.juneau.common.reflect;
 
-import static org.apache.juneau.common.utils.CollectionUtils.*;
-import static org.apache.juneau.common.utils.PredicateUtils.*;
-import static org.apache.juneau.common.utils.Utils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.function.*;
-
-import org.apache.juneau.common.collections.*;
-
 /**
  * Interface that provides the ability to look up annotations on 
classes/methods/constructors/fields.
  *
@@ -49,169 +38,4 @@ public interface AnnotationProvider {
         * @return The underlying AnnotationProvider2 instance.
         */
        AnnotationProvider2 getAnnotationProvider();
-
-       /**
-        * Finds the first matching annotation on the specified class.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onClass The class to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if not found.
-        */
-       <A extends Annotation> A firstAnnotation(Class<A> type, Class<?> 
onClass, Predicate<A> filter);
-
-       /**
-        * Finds the first matching annotation on the specified constructor.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onConstructor The constructor to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if no annotations 
matched.
-        */
-       <A extends Annotation> A firstAnnotation(Class<A> type, Constructor<?> 
onConstructor, Predicate<A> filter);
-
-       /**
-        * Finds the first matching annotation on the specified field.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onField The field to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if no annotations 
matched.
-        */
-       <A extends Annotation> A firstAnnotation(Class<A> type, Field onField, 
Predicate<A> filter);
-
-       /**
-        * Finds the first matching annotation on the specified method.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onMethod The method to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if no annotations 
matched.
-        */
-       <A extends Annotation> A firstAnnotation(Class<A> type, Method 
onMethod, Predicate<A> filter);
-
-       /**
-        * Finds the first matching declared annotations on the specified class.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onClass The class to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if no annotations 
matched.
-        */
-       <A extends Annotation> A firstDeclaredAnnotation(Class<A> type, 
Class<?> onClass, Predicate<A> filter);
-
-       /**
-        * Performs an action on the matching annotations on the specified 
class.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onClass The class to search on.
-        * @param filter A predicate to apply to the entries to determine if 
action should be performed.  Can be <jk>null</jk>.
-        * @param action An action to perform on the entry.
-        */
-       <A extends Annotation> void forEachAnnotation(Class<A> type, Class<?> 
onClass, Predicate<A> filter, Consumer<A> action);
-
-       /**
-        * Performs an action on the matching annotations on the specified 
constructor.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onConstructor The constructor to search on.
-        * @param filter A predicate to apply to the entries to determine if 
action should be performed.  Can be <jk>null</jk>.
-        * @param action An action to perform on the entry.
-        */
-       <A extends Annotation> void forEachAnnotation(Class<A> type, 
Constructor<?> onConstructor, Predicate<A> filter, Consumer<A> action);
-
-       /**
-        * Performs an action on the matching annotations on the specified 
field.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onField The field to search on.
-        * @param filter A predicate to apply to the entries to determine if 
action should be performed.  Can be <jk>null</jk>.
-        * @param action An action to perform on the entry.
-        */
-       <A extends Annotation> void forEachAnnotation(Class<A> type, Field 
onField, Predicate<A> filter, Consumer<A> action);
-
-       /**
-        * Performs an action on the matching annotations on the specified 
method.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onMethod The method to search on.
-        * @param filter A predicate to apply to the entries to determine if 
action should be performed.  Can be <jk>null</jk>.
-        * @param action An action to perform on the entry.
-        */
-       <A extends Annotation> void forEachAnnotation(Class<A> type, Method 
onMethod, Predicate<A> filter, Consumer<A> action);
-
-       /**
-        * Performs an action on the matching declared annotations on the 
specified class.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onClass The class to search on.
-        * @param filter A predicate to apply to the entries to determine if 
action should be performed.  Can be <jk>null</jk>.
-        * @param action An action to perform on the entry.
-        */
-       <A extends Annotation> void forEachDeclaredAnnotation(Class<A> type, 
Class<?> onClass, Predicate<A> filter, Consumer<A> action);
-
-       /**
-        * Finds the last matching annotation on the specified class.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onClass The class to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if not found.
-        */
-       <A extends Annotation> A lastAnnotation(Class<A> type, Class<?> 
onClass, Predicate<A> filter);
-
-       /**
-        * Finds the last matching annotation on the specified constructor.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onConstructor The constructor to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if no annotations 
matched.
-        */
-       <A extends Annotation> A lastAnnotation(Class<A> type, Constructor<?> 
onConstructor, Predicate<A> filter);
-
-       /**
-        * Finds the last matching annotation on the specified field.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onField The field to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if no annotations 
matched.
-        */
-       <A extends Annotation> A lastAnnotation(Class<A> type, Field onField, 
Predicate<A> filter);
-
-       /**
-        * Finds the last matching annotation on the specified method.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onMethod The method to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if no annotations 
matched.
-        */
-       <A extends Annotation> A lastAnnotation(Class<A> type, Method onMethod, 
Predicate<A> filter);
-
-       /**
-        * Finds the last matching declared annotations on the specified class.
-        *
-        * @param <A> The annotation type to find.
-        * @param type The annotation type to find.
-        * @param onClass The class to search on.
-        * @param filter A predicate to apply to the entries to determine if 
value should be used.  Can be <jk>null</jk>.
-        * @return The matched annotation, or <jk>null</jk> if no annotations 
matched.
-        */
-       <A extends Annotation> A lastDeclaredAnnotation(Class<A> type, Class<?> 
onClass, Predicate<A> filter);
 }
\ No newline at end of file
diff --git 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ConstructorInfo.java
 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ConstructorInfo.java
index a9a04fb6ce..1fed8f9282 100644
--- 
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ConstructorInfo.java
+++ 
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ConstructorInfo.java
@@ -136,7 +136,7 @@ public class ConstructorInfo extends ExecutableInfo 
implements Comparable<Constr
         */
        public <A extends Annotation> A getAnnotation(AnnotationProvider 
annotationProvider, Class<A> type) {
                Value<A> t = Value.empty();
-               annotationProvider.forEachAnnotation(type, c, x -> true, x -> 
t.set(x));
+               annotationProvider.getAnnotationProvider().find(type, c).map(x 
-> x.inner()).filter(x -> true).forEach(x -> t.set(x));
                return t.orElse(null);
        }
 
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 b77b74182d..159eedafa9 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
@@ -812,56 +812,6 @@ public abstract class Context implements 
AnnotationProvider {
                throw unsupportedOp();
        }
 
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A firstAnnotation(Class<A> type, Class<?> 
onClass, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A firstAnnotation(Class<A> type, 
Constructor<?> onConstructor, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A firstAnnotation(Class<A> type, Field 
onField, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A firstAnnotation(Class<A> type, Method 
onMethod, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A firstDeclaredAnnotation(Class<A> type, 
Class<?> onClass, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> void forEachAnnotation(Class<A> type, 
Class<?> onClass, Predicate<A> filter, Consumer<A> action) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> void forEachAnnotation(Class<A> type, 
Constructor<?> onConstructor, Predicate<A> filter, Consumer<A> action) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> void forEachAnnotation(Class<A> type, 
Field onField, Predicate<A> filter, Consumer<A> action) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> void forEachAnnotation(Class<A> type, 
Method onMethod, Predicate<A> filter, Consumer<A> action) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> void forEachDeclaredAnnotation(Class<A> 
type, Class<?> onClass, Predicate<A> filter, Consumer<A> action) {
-               throw unsupportedOp();
-       }
-
        /**
         * Returns a session to use for this context.
         *
@@ -929,31 +879,6 @@ public abstract class Context implements 
AnnotationProvider {
         */
        public boolean isDebug() { return debug; }
 
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A lastAnnotation(Class<A> type, Class<?> 
onClass, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A lastAnnotation(Class<A> type, 
Constructor<?> onConstructor, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A lastAnnotation(Class<A> type, Field 
onField, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A lastAnnotation(Class<A> type, Method 
onMethod, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
-       @Override /* Overridden from MetaProvider */
-       public <A extends Annotation> A lastDeclaredAnnotation(Class<A> type, 
Class<?> onClass, Predicate<A> filter) {
-               throw unsupportedOp();
-       }
-
        @Override /* Overridden from Object */
        public String toString() {
                return Utils2.toPropertyMap(this).asReadableString();

Reply via email to