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 1aca972649 org.apache.juneau.common.reflect API improvements
1aca972649 is described below
commit 1aca972649b4e87cc05f3aa354cdb05714006c92
Author: James Bognar <[email protected]>
AuthorDate: Wed Nov 19 10:15:33 2025 -0500
org.apache.juneau.common.reflect API improvements
---
.../juneau/common/reflect/AnnotationProvider.java | 137 +++++++++------------
.../apache/juneau/common/reflect/ClassInfo.java | 2 +-
.../src/main/java/org/apache/juneau/BeanMeta.java | 34 ++---
.../java/org/apache/juneau/BeanPropertyMeta.java | 44 +++----
.../main/java/org/apache/juneau/BeanRegistry.java | 2 +-
.../src/main/java/org/apache/juneau/ClassMeta.java | 34 ++---
.../src/main/java/org/apache/juneau/Context.java | 9 +-
.../apache/juneau/html/HtmlBeanPropertyMeta.java | 6 +-
.../java/org/apache/juneau/swap/AutoListSwap.java | 8 +-
.../java/org/apache/juneau/swap/AutoMapSwap.java | 8 +-
.../org/apache/juneau/swap/AutoNumberSwap.java | 8 +-
.../org/apache/juneau/swap/AutoObjectSwap.java | 8 +-
.../java/org/apache/juneau/swap/BuilderSwap.java | 2 +-
.../java/org/apache/juneau/swap/SurrogateSwap.java | 2 +-
.../java/org/apache/juneau/xml/XmlBeanMeta.java | 2 +-
.../rest/swagger/BasicSwaggerProviderSession.java | 16 +--
.../juneau/common/reflect/ClassInfo_Test.java | 8 +-
17 files changed, 157 insertions(+), 173 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 234398ddf8..d78640cf6c 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
@@ -48,7 +48,7 @@ import org.apache.juneau.common.collections.*;
*
* <h5 class='section'>Annotation Order of Precedence:</h5>
*
- * <h6 class='topic'>For Classes ({@link #find(Class)}):</h6>
+ * <h6 class='topic'>For Classes ({@link #xfind(Class)}):</h6>
* <p>
* Annotations are returned in <b>child-to-parent</b> order with the following
precedence:
* <ol>
@@ -73,7 +73,7 @@ import org.apache.juneau.common.collections.*;
* <jc>// 7. @Annotation on package-info.java</jc>
* </p>
*
- * <h6 class='topic'>For Methods ({@link #find(Method)}):</h6>
+ * <h6 class='topic'>For Methods ({@link #xfind(Method)}):</h6>
* <p>
* Annotations are returned in <b>child-to-parent</b> order with the following
precedence:
* <ol>
@@ -83,7 +83,7 @@ import org.apache.juneau.common.collections.*;
* <li><b>Declared annotations</b> on overridden parent methods
(child-to-parent order)
* </ol>
*
- * <h6 class='topic'>For Fields ({@link #find(Field)}):</h6>
+ * <h6 class='topic'>For Fields ({@link #xfind(Field)}):</h6>
* <p>
* Annotations are returned with the following precedence:
* <ol>
@@ -91,7 +91,7 @@ import org.apache.juneau.common.collections.*;
* <li><b>Declared annotations</b> on the field
* </ol>
*
- * <h6 class='topic'>For Constructors ({@link #find(Constructor)}):</h6>
+ * <h6 class='topic'>For Constructors ({@link #xfind(Constructor)}):</h6>
* <p>
* Annotations are returned with the following precedence:
* <ol>
@@ -475,7 +475,7 @@ public class AnnotationProvider {
* @return A list of {@link AnnotationInfo} objects representing all
annotations on the specified class,
* its parents, interfaces, and package. Never <jk>null</jk>.
*/
- public List<AnnotationInfo<Annotation>> find(Class<?> onClass) {
+ public List<AnnotationInfo<Annotation>> xfind(Class<?> onClass) {
assertArgNotNull("onClass", onClass);
return classAnnotations.get(onClass);
}
@@ -489,7 +489,7 @@ public class AnnotationProvider {
* taking precedence at each level.
*
* <p>
- * This is a filtered version of {@link #find(Class)} that only returns
annotations matching the specified type.
+ * This is a filtered version of {@link #xfind(Class)} that only
returns annotations matching the specified type.
*
* <p>
* <b>Comparison with {@link ClassInfo#getAnnotations(Class)}:</b>
@@ -506,10 +506,10 @@ public class AnnotationProvider {
* specified class, its parents, interfaces, and package. Never
<jk>null</jk>.
*/
@SuppressWarnings("unchecked")
- public <A extends Annotation> Stream<AnnotationInfo<A>> find(Class<A>
type, Class<?> onClass) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>> xfind(Class<A>
type, Class<?> onClass) {
assertArgNotNull("type", type);
assertArgNotNull("onClass", onClass);
- return find(onClass).stream()
+ return xfind(onClass).stream()
.filter(a -> a.isType(type))
.map(a -> (AnnotationInfo<A>)a);
}
@@ -518,7 +518,7 @@ public class AnnotationProvider {
* Finds annotations declared directly on the specified class,
including runtime annotations.
*
* <p>
- * Unlike {@link #find(Class)}, this method only returns annotations
declared directly on the specified class,
+ * Unlike {@link #xfind(Class)}, this method only returns annotations
declared directly on the specified class,
* not on its parents, interfaces, or package.
*
* <p>
@@ -539,7 +539,7 @@ public class AnnotationProvider {
* @return A list of {@link AnnotationInfo} objects representing
annotations declared directly on the class.
* Never <jk>null</jk>.
*/
- public List<AnnotationInfo<Annotation>> findDeclared(Class<?> onClass) {
+ public List<AnnotationInfo<Annotation>> xfindDeclared(Class<?> onClass)
{
assertArgNotNull("onClass", onClass);
return classDeclaredAnnotations.get(onClass);
}
@@ -548,7 +548,7 @@ public class AnnotationProvider {
* Finds annotations of the specified type declared directly on the
specified class, including runtime annotations.
*
* <p>
- * This is a filtered version of {@link #findDeclared(Class)} that only
returns annotations matching the specified type.
+ * This is a filtered version of {@link #xfindDeclared(Class)} that
only returns annotations matching the specified type.
*
* @param <A> The annotation type to find.
* @param type The annotation type to find.
@@ -557,10 +557,10 @@ public class AnnotationProvider {
* directly on the class. Never <jk>null</jk>.
*/
@SuppressWarnings("unchecked")
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findDeclared(Class<A> type, Class<?> onClass) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>>
xfindDeclared(Class<A> type, Class<?> onClass) {
assertArgNotNull("type", type);
assertArgNotNull("onClass", onClass);
- return findDeclared(onClass).stream()
+ return xfindDeclared(onClass).stream()
.filter(a -> a.isType(type))
.map(a -> (AnnotationInfo<A>)a);
}
@@ -569,7 +569,7 @@ public class AnnotationProvider {
* Finds all declared annotations on the specified class in
parent-to-child order (reversed).
*
* <p>
- * This method returns annotations in the opposite order from {@link
#findDeclared(Class)}.
+ * This method returns annotations in the opposite order from {@link
#xfindDeclared(Class)}.
* Returns annotations in <b>parent-to-child</b> order with declared
annotations coming before
* runtime annotations at each level.
*
@@ -587,7 +587,7 @@ public class AnnotationProvider {
* @param onClass The class to search on.
* @return A stream of {@link AnnotationInfo} objects in
parent-to-child order.
*/
- public Stream<AnnotationInfo<Annotation>>
findDeclaredParentFirst(Class<?> onClass) {
+ public Stream<AnnotationInfo<Annotation>>
xfindDeclaredParentFirst(Class<?> onClass) {
assertArgNotNull("onClass", onClass);
var list = classDeclaredAnnotations.get(onClass);
// Iterate backwards to get parent-to-child order
@@ -598,7 +598,7 @@ public class AnnotationProvider {
* Finds all declared annotations of the specified type on the
specified class in parent-to-child order (reversed).
*
* <p>
- * This method returns annotations in the opposite order from {@link
#findDeclared(Class, Class)}.
+ * This method returns annotations in the opposite order from {@link
#xfindDeclared(Class, Class)}.
*
* @param <A> The annotation type to find.
* @param type The annotation type to find.
@@ -606,10 +606,10 @@ public class AnnotationProvider {
* @return A stream of {@link AnnotationInfo} objects in
parent-to-child order.
*/
@SuppressWarnings("unchecked")
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findDeclaredParentFirst(Class<A> type, Class<?> onClass) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>>
xfindDeclaredParentFirst(Class<A> type, Class<?> onClass) {
assertArgNotNull("type", type);
assertArgNotNull("onClass", onClass);
- return findDeclaredParentFirst(onClass)
+ return xfindDeclaredParentFirst(onClass)
.filter(a -> a.isType(type))
.map(a -> (AnnotationInfo<A>)a);
}
@@ -642,7 +642,7 @@ public class AnnotationProvider {
* @return A list of {@link AnnotationInfo} objects representing all
annotations on the method and
* overridden parent methods. Never <jk>null</jk>.
*/
- public List<AnnotationInfo<Annotation>> find(Method onMethod) {
+ public List<AnnotationInfo<Annotation>> xfind(Method onMethod) {
assertArgNotNull("onMethod", onMethod);
return methodAnnotations.get(onMethod);
}
@@ -651,7 +651,7 @@ public class AnnotationProvider {
* Finds all annotations of the specified type on the specified method,
including runtime annotations.
*
* <p>
- * This is a filtered version of {@link #find(Method)} that only
returns annotations matching the specified type.
+ * This is a filtered version of {@link #xfind(Method)} that only
returns annotations matching the specified type.
*
* @param <A> The annotation type to find.
* @param type The annotation type to find.
@@ -660,10 +660,10 @@ public class AnnotationProvider {
* method and overridden parent methods. Never <jk>null</jk>.
*/
@SuppressWarnings("unchecked")
- public <A extends Annotation> Stream<AnnotationInfo<A>> find(Class<A>
type, Method onMethod) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>> xfind(Class<A>
type, Method onMethod) {
assertArgNotNull("type", type);
assertArgNotNull("onMethod", onMethod);
- return find(onMethod).stream()
+ return xfind(onMethod).stream()
.filter(a -> a.isType(type))
.map(a -> (AnnotationInfo<A>)a);
}
@@ -689,7 +689,7 @@ public class AnnotationProvider {
* @return A list of {@link AnnotationInfo} objects representing all
annotations on the field.
* Never <jk>null</jk>.
*/
- public List<AnnotationInfo<Annotation>> find(Field onField) {
+ public List<AnnotationInfo<Annotation>> xfind(Field onField) {
assertArgNotNull("onField", onField);
return fieldAnnotations.get(onField);
}
@@ -698,7 +698,7 @@ public class AnnotationProvider {
* Finds all annotations of the specified type on the specified field,
including runtime annotations.
*
* <p>
- * This is a filtered version of {@link #find(Field)} that only returns
annotations matching the specified type.
+ * This is a filtered version of {@link #xfind(Field)} that only
returns annotations matching the specified type.
*
* @param <A> The annotation type to find.
* @param type The annotation type to find.
@@ -707,10 +707,10 @@ public class AnnotationProvider {
* Never <jk>null</jk>.
*/
@SuppressWarnings("unchecked")
- public <A extends Annotation> Stream<AnnotationInfo<A>> find(Class<A>
type, Field onField) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>> xfind(Class<A>
type, Field onField) {
assertArgNotNull("type", type);
assertArgNotNull("onField", onField);
- return find(onField).stream()
+ return xfind(onField).stream()
.filter(a -> a.isType(type))
.map(a -> (AnnotationInfo<A>)a);
}
@@ -736,7 +736,7 @@ public class AnnotationProvider {
* @return A list of {@link AnnotationInfo} objects representing all
annotations on the constructor.
* Never <jk>null</jk>.
*/
- public List<AnnotationInfo<Annotation>> find(Constructor<?>
onConstructor) {
+ public List<AnnotationInfo<Annotation>> xfind(Constructor<?>
onConstructor) {
assertArgNotNull("onConstructor", onConstructor);
return constructorAnnotations.get(onConstructor);
}
@@ -745,7 +745,7 @@ public class AnnotationProvider {
* Finds all annotations of the specified type on the specified
constructor, including runtime annotations.
*
* <p>
- * This is a filtered version of {@link #find(Constructor)} that only
returns annotations matching the specified type.
+ * This is a filtered version of {@link #xfind(Constructor)} that only
returns annotations matching the specified type.
*
* @param <A> The annotation type to find.
* @param type The annotation type to find.
@@ -754,10 +754,10 @@ public class AnnotationProvider {
* Never <jk>null</jk>.
*/
@SuppressWarnings("unchecked")
- public <A extends Annotation> Stream<AnnotationInfo<A>> find(Class<A>
type, Constructor<?> onConstructor) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>> xfind(Class<A>
type, Constructor<?> onConstructor) {
assertArgNotNull("type", type);
assertArgNotNull("onConstructor", onConstructor);
- return find(onConstructor).stream()
+ return xfind(onConstructor).stream()
.filter(a -> a.isType(type))
.map(a -> (AnnotationInfo<A>)a);
}
@@ -871,15 +871,15 @@ public class AnnotationProvider {
* @param filter Optional filter to apply to annotations. Can be
<jk>null</jk>.
* @param action The action to perform on each matching annotation.
*/
- public <A extends Annotation> void forEachMethodAnnotation(Class<A>
type, MethodInfo mi, Predicate<A> filter, Consumer<A> action) {
- forEachClassAnnotation(type, mi.getDeclaringClass(), filter,
action);
+ public <A extends Annotation> void xforEachMethodAnnotation(Class<A>
type, MethodInfo mi, Predicate<A> filter, Consumer<A> action) {
+ xforEachClassAnnotation(type, mi.getDeclaringClass(), filter,
action);
rstream(mi.getMatchingMethods())
.flatMap(m -> m.getDeclaredAnnotations().stream())
.map(AnnotationInfo::inner)
.filter(type::isInstance)
.map(type::cast)
.forEach(a -> consumeIf(filter, action, a));
- forEachClassAnnotation(type,
mi.getReturnType().unwrap(Value.class, Optional.class), filter, action);
+ xforEachClassAnnotation(type,
mi.getReturnType().unwrap(Value.class, Optional.class), filter, action);
}
/**
@@ -899,16 +899,16 @@ public class AnnotationProvider {
* @param filter Optional filter to apply to annotations. Can be
<jk>null</jk>.
* @param action The action to perform on each matching annotation.
*/
- public <A extends Annotation> void forEachClassAnnotation(Class<A>
type, ClassInfo ci, Predicate<A> filter, Consumer<A> action) {
+ public <A extends Annotation> void xforEachClassAnnotation(Class<A>
type, ClassInfo ci, Predicate<A> filter, Consumer<A> action) {
A t2 = ci.getPackageAnnotation(type);
if (nn(t2))
consumeIf(filter, action, t2);
var interfaces2 = ci.getInterfaces();
for (int i = interfaces2.size() - 1; i >= 0; i--)
- findDeclaredParentFirst(type,
interfaces2.get(i).inner()).map(x -> x.inner()).filter(x -> filter == null ||
filter.test(x)).forEach(x -> action.accept(x));
+ xfindDeclaredParentFirst(type,
interfaces2.get(i).inner()).map(x -> x.inner()).filter(x -> filter == null ||
filter.test(x)).forEach(x -> action.accept(x));
var parents2 = ci.getParents();
for (int i = parents2.size() - 1; i >= 0; i--)
- findDeclaredParentFirst(type,
parents2.get(i).inner()).map(x -> x.inner()).filter(x -> filter == null ||
filter.test(x)).forEach(x -> action.accept(x));
+ xfindDeclaredParentFirst(type,
parents2.get(i).inner()).map(x -> x.inner()).filter(x -> filter == null ||
filter.test(x)).forEach(x -> action.accept(x));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -943,7 +943,7 @@ public class AnnotationProvider {
* @param traversals The traversal options (what to search and order).
* @return A stream of {@link AnnotationInfo} objects. Never
<jk>null</jk>.
*/
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotations(Class<A> type, ClassInfo clazz, AnnotationTraversal...
traversals) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>> find(Class<A>
type, ClassInfo clazz, AnnotationTraversal... traversals) {
assertArgNotNull("type", type);
assertArgNotNull("clazz", clazz);
@@ -951,9 +951,9 @@ public class AnnotationProvider {
.sorted(Comparator.comparingInt(AnnotationTraversal::getOrder))
.flatMap(traversal -> {
if (traversal == SELF) {
- return findDeclared(type,
clazz.inner());
+ return xfindDeclared(type,
clazz.inner());
} else if (traversal == PARENTS) {
- return
clazz.getParentsAndInterfaces().stream().flatMap(x -> findDeclared(type,
x.inner()));
+ return
clazz.getParentsAndInterfaces().stream().flatMap(x -> xfindDeclared(type,
x.inner()));
} else if (traversal == PACKAGE) {
A packageAnn =
clazz.getPackageAnnotation(type);
return nn(packageAnn) ?
Stream.of(AnnotationInfo.of(clazz, packageAnn)) : Stream.empty();
@@ -966,7 +966,7 @@ public class AnnotationProvider {
* Streams annotations from a class using configurable traversal
options in parent-first order.
*
* <p>
- * This is equivalent to calling {@link #findAnnotations(Class,
ClassInfo, AnnotationTraversal...)}
+ * This is equivalent to calling {@link #find(Class, ClassInfo,
AnnotationTraversal...)}
* and reversing the result.
*
* @param <A> The annotation type.
@@ -975,8 +975,8 @@ public class AnnotationProvider {
* @param traversals The traversal options (what to search and order).
* @return A stream of {@link AnnotationInfo} objects in parent-first
order. Never <jk>null</jk>.
*/
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotationsParentFirst(Class<A> type, ClassInfo clazz,
AnnotationTraversal... traversals) {
- return rstream(findAnnotations(type, clazz,
traversals).toList());
+ public <A extends Annotation> Stream<AnnotationInfo<A>>
findTopDown(Class<A> type, ClassInfo clazz, AnnotationTraversal... traversals) {
+ return rstream(find(type, clazz, traversals).toList());
}
/**
@@ -1002,7 +1002,7 @@ public class AnnotationProvider {
* @param traversals The traversal options.
* @return A stream of {@link AnnotationInfo} objects. Never
<jk>null</jk>.
*/
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotations(Class<A> type, MethodInfo method, AnnotationTraversal...
traversals) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>> find(Class<A>
type, MethodInfo method, AnnotationTraversal... traversals) {
assertArgNotNull("type", type);
assertArgNotNull("method", method);
if (traversals.length == 0)
@@ -1012,11 +1012,11 @@ public class AnnotationProvider {
.sorted(Comparator.comparingInt(AnnotationTraversal::getOrder))
.flatMap(traversal -> {
if (traversal == SELF) {
- return find(type, method.inner());
+ return xfind(type, method.inner());
} else if (traversal == MATCHING_METHODS) {
- return
method.getMatchingMethods().stream().skip(1).flatMap(x -> find(type,
x.inner()));
+ return
method.getMatchingMethods().stream().skip(1).flatMap(x -> xfind(type,
x.inner()));
} else if (traversal == RETURN_TYPE) {
- return findAnnotations(type,
method.getReturnType().unwrap(Value.class, Optional.class), PARENTS);
+ return find(type,
method.getReturnType().unwrap(Value.class, Optional.class), PARENTS);
} else if (traversal == PACKAGE) {
var c = method.getDeclaringClass();
A packageAnn =
c.getPackageAnnotation(type);
@@ -1030,7 +1030,7 @@ public class AnnotationProvider {
* Streams annotations from a method using configurable traversal
options in parent-first order.
*
* <p>
- * This is equivalent to calling {@link #findAnnotations(Class,
MethodInfo, AnnotationTraversal...)}
+ * This is equivalent to calling {@link #find(Class, MethodInfo,
AnnotationTraversal...)}
* and reversing the result.
*
* @param <A> The annotation type.
@@ -1039,8 +1039,8 @@ public class AnnotationProvider {
* @param traversals The traversal options.
* @return A stream of {@link AnnotationInfo} objects in parent-first
order. Never <jk>null</jk>.
*/
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotationsParentFirst(Class<A> type, MethodInfo method,
AnnotationTraversal... traversals) {
- return rstream(findAnnotations(type, method,
traversals).toList());
+ public <A extends Annotation> Stream<AnnotationInfo<A>>
findTopDown(Class<A> type, MethodInfo method, AnnotationTraversal...
traversals) {
+ return rstream(find(type, method, traversals).toList());
}
/**
@@ -1096,7 +1096,7 @@ public class AnnotationProvider {
} else if (traversal == MATCHING_PARAMETERS) {
return
parameter.getMatchingParameters().stream().skip(1).flatMap(x ->
x.getAnnotations(type));
} else if (traversal == PARAMETER_TYPE) {
- return findAnnotations(type,
parameter.getParameterType().unwrap(Value.class, Optional.class), PARENTS,
PACKAGE);
+ return find(type,
parameter.getParameterType().unwrap(Value.class, Optional.class), PARENTS,
PACKAGE);
}
throw illegalArg("Invalid traversal type for
parameter annotations: {0}", traversal);
});
@@ -1181,23 +1181,6 @@ public class AnnotationProvider {
return find(type, parameter,
traversals).findFirst().isPresent();
}
- /**
- * Streams annotations from a parameter using configurable traversal
options in parent-first order.
- *
- * <p>
- * This is equivalent to calling {@link #find(Class, ParameterInfo,
AnnotationTraversal...)}
- * and reversing the result.
- *
- * @param <A> The annotation type.
- * @param type The annotation type to search for.
- * @param parameter The parameter to search.
- * @param traversals The traversal options.
- * @return A stream of {@link AnnotationInfo} objects in parent-first
order. Never <jk>null</jk>.
- */
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotationsParentFirst(Class<A> type, ParameterInfo parameter,
AnnotationTraversal... traversals) {
- return rstream(find(type, parameter, traversals).toList());
- }
-
/**
* Streams annotations from a field using configurable traversal
options.
*
@@ -1217,7 +1200,7 @@ public class AnnotationProvider {
* @param traversals The traversal options.
* @return A stream of {@link AnnotationInfo} objects. Never
<jk>null</jk>.
*/
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotations(Class<A> type, FieldInfo field, AnnotationTraversal...
traversals) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>> find(Class<A>
type, FieldInfo field, AnnotationTraversal... traversals) {
assertArgNotNull("type", type);
assertArgNotNull("field", field);
@@ -1225,7 +1208,7 @@ public class AnnotationProvider {
.sorted(Comparator.comparingInt(AnnotationTraversal::getOrder))
.flatMap(traversal -> {
if (traversal == SELF) {
- return find(type, field.inner());
+ return xfind(type, field.inner());
}
throw illegalArg("Invalid traversal type for
field annotations: {0}", traversal);
});
@@ -1235,7 +1218,7 @@ public class AnnotationProvider {
* Streams annotations from a field using configurable traversal
options in parent-first order.
*
* <p>
- * This is equivalent to calling {@link #findAnnotations(Class,
FieldInfo, AnnotationTraversal...)}
+ * This is equivalent to calling {@link #find(Class, FieldInfo,
AnnotationTraversal...)}
* and reversing the result.
*
* @param <A> The annotation type.
@@ -1244,8 +1227,8 @@ public class AnnotationProvider {
* @param traversals The traversal options.
* @return A stream of {@link AnnotationInfo} objects in parent-first
order. Never <jk>null</jk>.
*/
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotationsParentFirst(Class<A> type, FieldInfo field,
AnnotationTraversal... traversals) {
- return rstream(findAnnotations(type, field,
traversals).toList());
+ public <A extends Annotation> Stream<AnnotationInfo<A>>
findTopDown(Class<A> type, FieldInfo field, AnnotationTraversal... traversals) {
+ return rstream(find(type, field, traversals).toList());
}
/**
@@ -1267,7 +1250,7 @@ public class AnnotationProvider {
* @param traversals The traversal options.
* @return A stream of {@link AnnotationInfo} objects. Never
<jk>null</jk>.
*/
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotations(Class<A> type, ConstructorInfo constructor,
AnnotationTraversal... traversals) {
+ public <A extends Annotation> Stream<AnnotationInfo<A>> find(Class<A>
type, ConstructorInfo constructor, AnnotationTraversal... traversals) {
assertArgNotNull("type", type);
assertArgNotNull("constructor", constructor);
@@ -1275,7 +1258,7 @@ public class AnnotationProvider {
.sorted(Comparator.comparingInt(AnnotationTraversal::getOrder))
.flatMap(traversal -> {
if (traversal == SELF) {
- return find(type, constructor.inner());
+ return xfind(type, constructor.inner());
}
throw illegalArg("Invalid traversal type for
constructor annotations: {0}", traversal);
});
@@ -1285,7 +1268,7 @@ public class AnnotationProvider {
* Streams annotations from a constructor using configurable traversal
options in parent-first order.
*
* <p>
- * This is equivalent to calling {@link #findAnnotations(Class,
ConstructorInfo, AnnotationTraversal...)}
+ * This is equivalent to calling {@link #find(Class, ConstructorInfo,
AnnotationTraversal...)}
* and reversing the result.
*
* @param <A> The annotation type.
@@ -1294,7 +1277,7 @@ public class AnnotationProvider {
* @param traversals The traversal options.
* @return A stream of {@link AnnotationInfo} objects in parent-first
order. Never <jk>null</jk>.
*/
- public <A extends Annotation> Stream<AnnotationInfo<A>>
findAnnotationsParentFirst(Class<A> type, ConstructorInfo constructor,
AnnotationTraversal... traversals) {
- return rstream(findAnnotations(type, constructor,
traversals).toList());
+ public <A extends Annotation> Stream<AnnotationInfo<A>>
findTopDown(Class<A> type, ConstructorInfo constructor, AnnotationTraversal...
traversals) {
+ return rstream(find(type, constructor, traversals).toList());
}
}
\ No newline at end of file
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 afc5057d64..f8e8471591 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
@@ -2457,7 +2457,7 @@ public class ClassInfo extends ElementInfo implements
Annotatable {
* Finds all annotations on this class and parent classes/interfaces in
child-to-parent order.
*
* <p>
- * This is similar to {@link
org.apache.juneau.common.reflect.AnnotationProvider#find(Class)} but without
runtime annotations.
+ * This is similar to {@link
org.apache.juneau.common.reflect.AnnotationProvider#xfind(Class)} but without
runtime annotations.
*
* <p>
* Order of traversal:
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 c56d38babc..4503970ac7 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
@@ -183,8 +183,8 @@ public class BeanMeta<T> {
List<Beanp> lp = list();
List<Name> ln = list();
// Inline Context.forEachAnnotation() calls
- ctx.getAnnotationProvider().find(Beanp.class, f).map(x
-> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
- ctx.getAnnotationProvider().find(Name.class, f).map(x
-> x.inner()).filter(x -> true).forEach(x -> ln.add(x));
+ ctx.getAnnotationProvider().xfind(Beanp.class, f).map(x
-> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
+ ctx.getAnnotationProvider().xfind(Name.class, f).map(x
-> x.inner()).filter(x -> true).forEach(x -> ln.add(x));
String name = bpName(lp, ln);
if (isNotEmpty(name))
return name;
@@ -230,8 +230,8 @@ public class BeanMeta<T> {
Map<String,BeanPropertyMeta.Builder>
normalProps = map();
- boolean hasBean =
ctx.getAnnotationProvider().find(Bean.class,
ci.inner()).findFirst().isPresent();
- boolean hasBeanIgnore =
ctx.getAnnotationProvider().find(BeanIgnore.class,
ci.inner()).findFirst().isPresent();
+ boolean hasBean =
ctx.getAnnotationProvider().xfind(Bean.class,
ci.inner()).findFirst().isPresent();
+ boolean hasBeanIgnore =
ctx.getAnnotationProvider().xfind(BeanIgnore.class,
ci.inner()).findFirst().isPresent();
/// See if this class matches one the patterns
in the exclude-class list.
if (ctx.isNotABean(c))
@@ -248,12 +248,12 @@ public class BeanMeta<T> {
return "Class is not serializable";
// Look for @Beanc constructor on public
constructors.
- ci.getPublicConstructors().stream().filter(x ->
ctx.getAnnotationProvider().find(Beanc.class,
x.inner()).findAny().isPresent()).forEach(x -> {
+ ci.getPublicConstructors().stream().filter(x ->
ctx.getAnnotationProvider().xfind(Beanc.class,
x.inner()).findAny().isPresent()).forEach(x -> {
if (nn(constructor))
throw new
BeanRuntimeException(c, "Multiple instances of '@Beanc' found.");
constructor = x;
constructorArgs = new String[0];
-
ctx.getAnnotationProvider().find(Beanc.class, x.inner()).map(x2 ->
x2.inner()).filter(y -> ! y.properties().isEmpty()).forEach(z ->
constructorArgs = splita(z.properties()));
+
ctx.getAnnotationProvider().xfind(Beanc.class, x.inner()).map(x2 ->
x2.inner()).filter(y -> ! y.properties().isEmpty()).forEach(z ->
constructorArgs = splita(z.properties()));
if (!
x.hasNumParameters(constructorArgs.length)) {
if (constructorArgs.length != 0)
throw new
BeanRuntimeException(c, "Number of properties defined in '@Beanc' annotation
does not match number of parameters in constructor.");
@@ -271,12 +271,12 @@ public class BeanMeta<T> {
// Look for @Beanc on all other constructors.
if (constructor == null) {
-
ci.getDeclaredConstructors().stream().filter(x ->
ctx.getAnnotationProvider().find(Beanc.class,
x.inner()).findAny().isPresent()).forEach(x -> {
+
ci.getDeclaredConstructors().stream().filter(x ->
ctx.getAnnotationProvider().xfind(Beanc.class,
x.inner()).findAny().isPresent()).forEach(x -> {
if (nn(constructor))
throw new
BeanRuntimeException(c, "Multiple instances of '@Beanc' found.");
constructor = x;
constructorArgs = new String[0];
-
ctx.getAnnotationProvider().find(Beanc.class, x.inner()).map(x2 ->
x2.inner()).filter(y -> ! y.properties().isEmpty()).forEach(z ->
constructorArgs = splita(z.properties()));
+
ctx.getAnnotationProvider().xfind(Beanc.class, x.inner()).map(x2 ->
x2.inner()).filter(y -> ! y.properties().isEmpty()).forEach(z ->
constructorArgs = splita(z.properties()));
if (!
x.hasNumParameters(constructorArgs.length)) {
if
(constructorArgs.length != 0)
throw new
BeanRuntimeException(c, "Number of properties defined in '@Beanc' annotation
does not match number of parameters in constructor.");
@@ -570,8 +570,8 @@ public class BeanMeta<T> {
.filter(x -> x.isNotStatic()
&& (x.isNotTransient() || noIgnoreTransients)
&& (! x.hasAnnotation(Transient.class) ||
noIgnoreTransients)
- &&
ctx.getAnnotationProvider().find(BeanIgnore.class,
x.inner()).findAny().isEmpty()
- && (v.isVisible(x.inner()) ||
ctx.getAnnotationProvider().find(Beanp.class, x.inner()).findAny().isPresent()))
+ &&
ctx.getAnnotationProvider().xfind(BeanIgnore.class,
x.inner()).findAny().isEmpty()
+ && (v.isVisible(x.inner()) ||
ctx.getAnnotationProvider().xfind(Beanp.class,
x.inner()).findAny().isPresent()))
.forEach(x -> l.add(x.inner())
);
// @formatter:on
@@ -593,10 +593,10 @@ public class BeanMeta<T> {
forEachClass(ClassInfo.of(c), stopClass, c2 -> {
for (var m : c2.getDeclaredMethods()) {
- if (m.isStatic() || m.isBridge() ||
m.getParameterCount() > 2 || m.getMatchingMethods().stream().anyMatch(m2 ->
ctx.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent()))
+ if (m.isStatic() || m.isBridge() ||
m.getParameterCount() > 2 || m.getMatchingMethods().stream().anyMatch(m2 ->
ctx.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent()))
continue;
Transient t = m.getMatchingMethods().stream()
- .map(m2 ->
ctx.getAnnotationProvider().find(Transient.class, m2.inner()).map(x ->
x.inner()).filter(x -> true).findFirst().orElse(null))
+ .map(m2 ->
ctx.getAnnotationProvider().xfind(Transient.class, m2.inner()).map(x ->
x.inner()).filter(x -> true).findFirst().orElse(null))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
@@ -605,8 +605,8 @@ public class BeanMeta<T> {
List<Beanp> lp = list();
List<Name> ln = list();
- ctx.getAnnotationProvider().find(Beanp.class,
m.inner()).map(x -> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
- ctx.getAnnotationProvider().find(Name.class,
m.inner()).map(x -> x.inner()).filter(x -> true).forEach(x -> ln.add(x));
+ ctx.getAnnotationProvider().xfind(Beanp.class,
m.inner()).map(x -> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
+ ctx.getAnnotationProvider().xfind(Name.class,
m.inner()).map(x -> x.inner()).filter(x -> true).forEach(x -> ln.add(x));
// If this method doesn't have @Beanp or @Name,
check if it overrides a parent method that does
// This ensures property names are inherited
correctly, preventing duplicate property definitions
@@ -710,7 +710,7 @@ public class BeanMeta<T> {
x -> x.isNotStatic()
&& (x.isNotTransient() || noIgnoreTransients)
&& (! x.hasAnnotation(Transient.class) ||
noIgnoreTransients)
- &&
ctx.getAnnotationProvider().find(BeanIgnore.class,
x.inner()).findAny().isEmpty()
+ &&
ctx.getAnnotationProvider().xfind(BeanIgnore.class,
x.inner()).findAny().isEmpty()
&& x.hasName(name))
.ifPresent(f -> value.set(f.inner()));
// @formatter:on
@@ -819,8 +819,8 @@ public class BeanMeta<T> {
if (paramsMatch) {
// Found a matching parent
method - check for @Beanp and @Name annotations
-
ctx.getAnnotationProvider().find(Beanp.class, parentMethod.inner()).map(x ->
x.inner()).filter(x -> true).forEach(x -> lp.add(x));
-
ctx.getAnnotationProvider().find(Name.class, parentMethod.inner()).map(x ->
x.inner()).filter(x -> true).forEach(x -> ln.add(x));
+
ctx.getAnnotationProvider().xfind(Beanp.class, parentMethod.inner()).map(x ->
x.inner()).filter(x -> true).forEach(x -> lp.add(x));
+
ctx.getAnnotationProvider().xfind(Name.class, parentMethod.inner()).map(x ->
x.inner()).filter(x -> true).forEach(x -> ln.add(x));
// If we found annotations,
we're done
if (! lp.isEmpty() || !
ln.isEmpty())
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 cc55bacc40..46c16be05b 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
@@ -221,7 +221,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (nn(innerField)) {
List<Beanp> lp = list();
// Inline Context.forEachAnnotation() call
- bc.getAnnotationProvider().find(Beanp.class,
innerField).map(x -> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
+ bc.getAnnotationProvider().xfind(Beanp.class,
innerField).map(x -> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
if (nn(field) || isNotEmpty(lp)) {
// Only use field type if it's a bean
property or has @Beanp annotation.
// Otherwise, we want to infer the type
from the getter or setter.
@@ -240,13 +240,13 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
writeOnly =
Boolean.valueOf(x.wo());
});
// Inline Context.forEachAnnotation() call
- bc.getAnnotationProvider().find(Swap.class,
innerField).map(x -> x.inner()).filter(x -> true).forEach(x -> swap =
getPropertySwap(x));
- isUri |=
nn(bc.getAnnotationProvider().find(Uri.class, innerField).map(x ->
x.inner()).filter(x -> true).findFirst().orElse(null));
+ bc.getAnnotationProvider().xfind(Swap.class,
innerField).map(x -> x.inner()).filter(x -> true).forEach(x -> swap =
getPropertySwap(x));
+ isUri |=
nn(bc.getAnnotationProvider().xfind(Uri.class, innerField).map(x ->
x.inner()).filter(x -> true).findFirst().orElse(null));
}
if (nn(getter)) {
List<Beanp> lp = list();
- bc.getAnnotationProvider().find(Beanp.class,
getter).map(x -> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
+ bc.getAnnotationProvider().xfind(Beanp.class,
getter).map(x -> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
if (rawTypeMeta == null)
rawTypeMeta =
bc.resolveClassMeta(last(lp), getter.getGenericReturnType(), typeVarImpls);
isUri |= (rawTypeMeta.isUri() ||
bc.hasAnnotation(Uri.class, getter));
@@ -261,12 +261,12 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (! x.wo().isEmpty())
writeOnly =
Boolean.valueOf(x.wo());
});
- bc.getAnnotationProvider().find(Swap.class,
getter).map(x -> x.inner()).filter(x -> true).forEach(x -> swap =
getPropertySwap(x));
+ bc.getAnnotationProvider().xfind(Swap.class,
getter).map(x -> x.inner()).filter(x -> true).forEach(x -> swap =
getPropertySwap(x));
}
if (nn(setter)) {
List<Beanp> lp = list();
- bc.getAnnotationProvider().find(Beanp.class,
setter).map(x -> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
+ bc.getAnnotationProvider().xfind(Beanp.class,
setter).map(x -> x.inner()).filter(x -> true).forEach(x -> lp.add(x));
if (rawTypeMeta == null)
rawTypeMeta =
bc.resolveClassMeta(last(lp), setter.getGenericParameterTypes()[0],
typeVarImpls);
isUri |= (rawTypeMeta.isUri() ||
bc.hasAnnotation(Uri.class, setter));
@@ -281,7 +281,7 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
if (! x.wo().isEmpty())
writeOnly =
Boolean.valueOf(x.wo());
});
- bc.getAnnotationProvider().find(Swap.class,
setter).map(x -> x.inner()).filter(x -> true).forEach(x -> swap =
getPropertySwap(x));
+ bc.getAnnotationProvider().xfind(Swap.class,
setter).map(x -> x.inner()).filter(x -> true).forEach(x -> swap =
getPropertySwap(x));
}
if (rawTypeMeta == null)
@@ -637,9 +637,9 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
public <A extends Annotation> BeanPropertyMeta
forEachAnnotation(Class<A> a, Predicate<A> filter, Consumer<A> action) {
BeanContext bc = beanContext;
if (nn(a)) {
- if (nn(field)) bc.getAnnotationProvider().find(a,
field).map(x -> x.inner()).filter(filter).forEach(action);
- if (nn(getter)) bc.getAnnotationProvider().find(a,
getter).map(x -> x.inner()).filter(filter).forEach(action);
- if (nn(setter)) bc.getAnnotationProvider().find(a,
setter).map(x -> x.inner()).filter(filter).forEach(action);
+ if (nn(field)) bc.getAnnotationProvider().xfind(a,
field).map(x -> x.inner()).filter(filter).forEach(action);
+ if (nn(getter)) bc.getAnnotationProvider().xfind(a,
getter).map(x -> x.inner()).filter(filter).forEach(action);
+ if (nn(setter)) bc.getAnnotationProvider().xfind(a,
setter).map(x -> x.inner()).filter(filter).forEach(action);
}
return this;
}
@@ -679,34 +679,34 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
BeanContext bc = beanContext;
if (a == null)
return l;
- bc.getAnnotationProvider().forEachClassAnnotation(a,
getBeanMeta().getClassMeta().getInfo(), x -> true, x -> l.add(x));
+ bc.getAnnotationProvider().xforEachClassAnnotation(a,
getBeanMeta().getClassMeta().getInfo(), x -> true, x -> l.add(x));
if (nn(field)) {
- bc.getAnnotationProvider().find(a, field).map(x ->
x.inner()).filter(x -> true).forEach(x -> l.add(x));
- bc.getAnnotationProvider().forEachClassAnnotation(a,
ClassInfo.of(field.getType()), x -> true, x -> l.add(x));
+ bc.getAnnotationProvider().xfind(a, field).map(x ->
x.inner()).filter(x -> true).forEach(x -> l.add(x));
+ bc.getAnnotationProvider().xforEachClassAnnotation(a,
ClassInfo.of(field.getType()), x -> true, x -> l.add(x));
}
if (nn(getter)) {
// Walk up the inheritance hierarchy for the getter
method
forEachParentMethod(getter, parentGetter -> {
- bc.getAnnotationProvider().find(a,
parentGetter).map(x -> x.inner()).filter(x -> true).forEach(x -> l.add(x));
+ bc.getAnnotationProvider().xfind(a,
parentGetter).map(x -> x.inner()).filter(x -> true).forEach(x -> l.add(x));
});
- bc.getAnnotationProvider().find(a, getter).map(x ->
x.inner()).filter(x -> true).forEach(x -> l.add(x));
- bc.getAnnotationProvider().forEachClassAnnotation(a,
ClassInfo.of(getter.getReturnType()), x -> true, x -> l.add(x));
+ bc.getAnnotationProvider().xfind(a, getter).map(x ->
x.inner()).filter(x -> true).forEach(x -> l.add(x));
+ bc.getAnnotationProvider().xforEachClassAnnotation(a,
ClassInfo.of(getter.getReturnType()), x -> true, x -> l.add(x));
}
if (nn(setter)) {
// Walk up the inheritance hierarchy for the setter
method
forEachParentMethod(setter, parentSetter -> {
- bc.getAnnotationProvider().find(a,
parentSetter).map(x -> x.inner()).filter(x -> true).forEach(x -> l.add(x));
+ bc.getAnnotationProvider().xfind(a,
parentSetter).map(x -> x.inner()).filter(x -> true).forEach(x -> l.add(x));
});
- bc.getAnnotationProvider().find(a, setter).map(x ->
x.inner()).filter(x -> true).forEach(x -> l.add(x));
- bc.getAnnotationProvider().forEachClassAnnotation(a,
ClassInfo.of(setter.getReturnType()), x -> true, x -> l.add(x));
+ bc.getAnnotationProvider().xfind(a, setter).map(x ->
x.inner()).filter(x -> true).forEach(x -> l.add(x));
+ bc.getAnnotationProvider().xforEachClassAnnotation(a,
ClassInfo.of(setter.getReturnType()), x -> true, x -> l.add(x));
}
if (nn(extraKeys)) {
// Walk up the inheritance hierarchy for the extraKeys
method
forEachParentMethod(extraKeys, parentExtraKeys -> {
- bc.getAnnotationProvider().find(a,
parentExtraKeys).map(x -> x.inner()).filter(x -> true).forEach(x -> l.add(x));
+ bc.getAnnotationProvider().xfind(a,
parentExtraKeys).map(x -> x.inner()).filter(x -> true).forEach(x -> l.add(x));
});
- bc.getAnnotationProvider().find(a, extraKeys).map(x ->
x.inner()).filter(x -> true).forEach(x -> l.add(x));
- bc.getAnnotationProvider().forEachClassAnnotation(a,
ClassInfo.of(extraKeys.getReturnType()), x -> true, x -> l.add(x));
+ bc.getAnnotationProvider().xfind(a, extraKeys).map(x ->
x.inner()).filter(x -> true).forEach(x -> l.add(x));
+ bc.getAnnotationProvider().xforEachClassAnnotation(a,
ClassInfo.of(extraKeys.getReturnType()), x -> true, x -> l.add(x));
}
return l;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanRegistry.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanRegistry.java
index 1486c78d40..8296be7fb7 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanRegistry.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanRegistry.java
@@ -150,7 +150,7 @@ public class BeanRegistry {
});
} else {
Value<String> typeName = Value.empty();
-
beanContext.getAnnotationProvider().forEachClassAnnotation(Bean.class, ci, x ->
isNotEmpty(x.typeName()), x -> typeName.set(x.typeName()));
+
beanContext.getAnnotationProvider().xforEachClassAnnotation(Bean.class, ci, x
-> isNotEmpty(x.typeName()), x -> typeName.set(x.typeName()));
addToMap(typeName.orElseThrow(() -> new
BeanRuntimeException("Class ''{0}'' was passed to BeanRegistry but it doesn't
have a @Bean(typeName) annotation defined.", cn(c))),
beanContext.getClassMeta(c));
}
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 2b177719f6..9e515231ba 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
@@ -163,7 +163,7 @@ public class ClassMeta<T> implements Type {
cc = DATE;
else if (c.isArray())
cc = ARRAY;
- else if (ci.isChildOfAny(URL.class, URI.class)
|| bc.getAnnotationProvider().find(Uri.class,
ci.inner()).findFirst().isPresent())
+ else if (ci.isChildOfAny(URL.class, URI.class)
|| bc.getAnnotationProvider().xfind(Uri.class,
ci.inner()).findFirst().isPresent())
cc = URI;
else if (ci.isChildOf(Reader.class))
cc = READER;
@@ -204,19 +204,19 @@ public class ClassMeta<T> implements Type {
.orElse(null);
// @formatter:on
- ci.getAllFields().stream().filter(x ->
bc.getAnnotationProvider().find(ParentProperty.class,
x.inner()).findAny().isPresent()).forEach(x -> {
+ ci.getAllFields().stream().filter(x ->
bc.getAnnotationProvider().xfind(ParentProperty.class,
x.inner()).findAny().isPresent()).forEach(x -> {
if (x.isStatic())
throw new ClassMetaRuntimeException(c,
"@ParentProperty used on invalid field ''{0}''. Must be static.", x);
parentPropertyMethod = new
Setter.FieldSetter(x.accessible().inner());
});
- ci.getAllFields().stream().filter(x ->
bc.getAnnotationProvider().find(NameProperty.class,
x.inner()).findAny().isPresent()).forEach(x -> {
+ ci.getAllFields().stream().filter(x ->
bc.getAnnotationProvider().xfind(NameProperty.class,
x.inner()).findAny().isPresent()).forEach(x -> {
if (x.isStatic())
throw new ClassMetaRuntimeException(c,
"@NameProperty used on invalid field ''{0}''. Must be static.", x);
namePropertyMethod = new
Setter.FieldSetter(x.accessible().inner());
});
- ci.getDeclaredFields().stream().filter(x ->
bc.getAnnotationProvider().find(Example.class,
x.inner()).findAny().isPresent()).forEach(x -> {
+ ci.getDeclaredFields().stream().filter(x ->
bc.getAnnotationProvider().xfind(Example.class,
x.inner()).findAny().isPresent()).forEach(x -> {
if (! (x.isStatic() &&
ci.isParentOf(x.getFieldType().inner())))
throw new ClassMetaRuntimeException(c,
"@Example used on invalid field ''{0}''. Must be static and an instance of the
type.", x);
exampleField = x.accessible().inner();
@@ -226,13 +226,13 @@ public class ClassMeta<T> implements Type {
List<MethodInfo> methods = ci.getAllMethods();
for (int i = methods.size() - 1; i >= 0; i--) {
MethodInfo m = methods.get(i);
- if (m.getMatchingMethods().stream().anyMatch(m2
-> bc.getAnnotationProvider().find(ParentProperty.class,
m2.inner()).findFirst().isPresent())) {
+ if (m.getMatchingMethods().stream().anyMatch(m2
-> bc.getAnnotationProvider().xfind(ParentProperty.class,
m2.inner()).findFirst().isPresent())) {
if (m.isStatic() || !
m.hasNumParameters(1))
throw new
ClassMetaRuntimeException(c, "@ParentProperty used on invalid method ''{0}''.
Must not be static and have one argument.", m);
m.setAccessible();
parentPropertyMethod = new
Setter.MethodSetter(m.inner());
}
- if (m.getMatchingMethods().stream().anyMatch(m2
-> bc.getAnnotationProvider().find(NameProperty.class,
m2.inner()).findFirst().isPresent())) {
+ if (m.getMatchingMethods().stream().anyMatch(m2
-> bc.getAnnotationProvider().xfind(NameProperty.class,
m2.inner()).findFirst().isPresent())) {
if (m.isStatic() || !
m.hasNumParameters(1))
throw new
ClassMetaRuntimeException(c, "@NameProperty used on invalid method ''{0}''.
Must not be static and have one argument.", m);
m.setAccessible();
@@ -240,7 +240,7 @@ public class ClassMeta<T> implements Type {
}
}
- ci.getDeclaredMethods().stream().filter(m ->
m.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(Example.class,
m2.inner()).findFirst().isPresent())).forEach(m -> {
+ ci.getDeclaredMethods().stream().filter(m ->
m.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(Example.class,
m2.inner()).findFirst().isPresent())).forEach(m -> {
if (! (m.isStatic() &&
m.hasParameterTypesLenient(BeanSession.class) &&
ci.isParentOf(m.getReturnType().inner())))
throw new ClassMetaRuntimeException(c,
"@Example used on invalid method ''{0}''. Must be static and return an
instance of the declaring class.", m.toString());
m.setAccessible();
@@ -361,7 +361,7 @@ public class ClassMeta<T> implements Type {
if (nn(bc)) {
// Inline Context.forEachAnnotation() call
- bc.getAnnotationProvider().find(Bean.class,
c).map(x -> x.inner()).filter(x -> true).forEach(x -> {
+ bc.getAnnotationProvider().xfind(Bean.class,
c).map(x -> x.inner()).filter(x -> true).forEach(x -> {
if (x.dictionary().length != 0)
beanRegistry = new
BeanRegistry(bc, null, x.dictionary());
// This could be a non-bean POJO with a
type name.
@@ -372,7 +372,7 @@ public class ClassMeta<T> implements Type {
if (example == null && nn(bc)) {
// Inline Context.forEachAnnotation() call
- bc.getAnnotationProvider().find(Example.class,
c).map(x -> x.inner()).filter(x -> ! x.value().isEmpty()).forEach(x -> example
= x.value());
+ bc.getAnnotationProvider().xfind(Example.class,
c).map(x -> x.inner()).filter(x -> ! x.value().isEmpty()).forEach(x -> example
= x.value());
}
if (example == null) {
@@ -465,7 +465,7 @@ public class ClassMeta<T> implements Type {
private BeanFilter findBeanFilter(BeanContext bc) {
try {
List<Bean> ba = list();
-
bc.getAnnotationProvider().forEachClassAnnotation(Bean.class, info, x -> true,
x -> ba.add(x));
+
bc.getAnnotationProvider().xforEachClassAnnotation(Bean.class, info, x -> true,
x -> ba.add(x));
if (! ba.isEmpty())
return
BeanFilter.create(innerClass).applyAnnotations(ba).build();
} catch (Exception e) {
@@ -481,7 +481,7 @@ public class ClassMeta<T> implements Type {
private MarshalledFilter findMarshalledFilter(BeanContext bc) {
try {
List<Marshalled> ba = list();
-
bc.getAnnotationProvider().forEachClassAnnotation(Marshalled.class, info, x ->
true, x -> ba.add(x));
+
bc.getAnnotationProvider().xforEachClassAnnotation(Marshalled.class, info, x ->
true, x -> ba.add(x));
if (! ba.isEmpty())
return
MarshalledFilter.create(innerClass).applyAnnotations(ba).build();
} catch (Exception e) {
@@ -498,7 +498,7 @@ public class ClassMeta<T> implements Type {
if (nn(bc))
// Inline Context.forEachAnnotation() call
- bc.getAnnotationProvider().find(Swap.class,
innerClass).map(x -> x.inner()).filter(x -> true).forEach(x ->
l.add(createSwap(x)));
+ bc.getAnnotationProvider().xfind(Swap.class,
innerClass).map(x -> x.inner()).filter(x -> true).forEach(x ->
l.add(createSwap(x)));
ObjectSwap defaultSwap = DefaultSwaps.find(ci);
if (defaultSwap == null)
@@ -863,7 +863,7 @@ public class ClassMeta<T> implements Type {
*/
public <A extends Annotation> ClassMeta<T> forEachAnnotation(Class<A>
type, Predicate<A> filter, Consumer<A> action) {
if (beanContext != null) {
- beanContext.getAnnotationProvider().find(type,
info.inner()).map(x -> x.inner()).filter(x -> x != null).filter(x -> filter ==
null || filter.test(x)).forEach(x -> action.accept(x));
+ beanContext.getAnnotationProvider().xfind(type,
info.inner()).map(x -> x.inner()).filter(x -> x != null).filter(x -> filter ==
null || filter.test(x)).forEach(x -> action.accept(x));
}
return this;
}
@@ -1114,8 +1114,8 @@ public class ClassMeta<T> implements Type {
Optional<A> o = (Optional<A>)annotationLastMap.get(a);
if (o == null) {
if (beanContext == null)
- return
BeanContext.DEFAULT.getAnnotationProvider().find(a,
info.inner()).findFirst().map(x -> x.inner()).orElse(null);
- o = opt(beanContext.getAnnotationProvider().find(a,
info.inner()).findFirst().map(x -> x.inner()).orElse(null));
+ return
BeanContext.DEFAULT.getAnnotationProvider().xfind(a,
info.inner()).findFirst().map(x -> x.inner()).orElse(null);
+ o = opt(beanContext.getAnnotationProvider().xfind(a,
info.inner()).findFirst().map(x -> x.inner()).orElse(null));
annotationLastMap.put(a, o);
}
return o.orElse(null);
@@ -1760,7 +1760,7 @@ public class ClassMeta<T> implements Type {
A[] array = annotationArray(type);
if (array == null) {
if (beanContext == null)
- return AnnotationProvider.INSTANCE.find(type,
info.inner())
+ return AnnotationProvider.INSTANCE.xfind(type,
info.inner())
.map(AnnotationInfo::inner)
.filter(a -> test(filter, a))
.findFirst(); // AnnotationProvider
returns child-to-parent, so first is "last"
@@ -1937,7 +1937,7 @@ public class ClassMeta<T> implements Type {
A[] array = (A[])annotationArrayMap.get(type);
if (array == null && nn(beanContext)) {
List<A> l = list();
- beanContext.getAnnotationProvider().find(type,
info.inner()).map(x -> x.inner()).filter(x -> true).forEach(x -> l.add(x));
+ beanContext.getAnnotationProvider().xfind(type,
info.inner()).map(x -> x.inner()).filter(x -> true).forEach(x -> l.add(x));
array = (A[])Array.newInstance(type, l.size());
for (int i = 0; i < l.size(); i++)
Array.set(array, i, l.get(i));
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 9c59ef51ba..7a6f317019 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
@@ -81,6 +81,7 @@ public abstract class Context {
public abstract static class Builder {
private static final Map<Class<?>,ConstructorInfo>
CONTEXT_CONSTRUCTORS = new ConcurrentHashMap<>();
+ private static final AnnotationProvider AP =
AnnotationProvider.INSTANCE;
boolean debug;
Class<? extends Context> type;
@@ -827,7 +828,7 @@ public abstract class Context {
* @return <jk>true</jk> if the annotation exists on the specified
class.
*/
public <A extends Annotation> boolean hasAnnotation(Class<A> type,
Class<?> onClass) {
- return getAnnotationProvider().find(type, onClass).map(x ->
x.inner()).findFirst().isPresent();
+ return getAnnotationProvider().xfind(type, onClass).map(x ->
x.inner()).findFirst().isPresent();
}
/**
@@ -839,7 +840,7 @@ public abstract class Context {
* @return <jk>true</jk> if the annotation exists on the specified
field.
*/
public <A extends Annotation> boolean hasAnnotation(Class<A> type,
Constructor<?> onConstructor) {
- return getAnnotationProvider().find(type, onConstructor).map(x
-> x.inner()).findFirst().isPresent();
+ return getAnnotationProvider().xfind(type, onConstructor).map(x
-> x.inner()).findFirst().isPresent();
}
/**
@@ -851,7 +852,7 @@ public abstract class Context {
* @return <jk>true</jk> if the annotation exists on the specified
field.
*/
public <A extends Annotation> boolean hasAnnotation(Class<A> type,
Field onField) {
- return getAnnotationProvider().find(type, onField).map(x ->
x.inner()).findFirst().isPresent();
+ return getAnnotationProvider().xfind(type, onField).map(x ->
x.inner()).findFirst().isPresent();
}
/**
@@ -863,7 +864,7 @@ public abstract class Context {
* @return <jk>true</jk> if the annotation exists on the specified
method.
*/
public <A extends Annotation> boolean hasAnnotation(Class<A> type,
Method onMethod) {
- return getAnnotationProvider().find(type, onMethod).map(x ->
x.inner()).findFirst().isPresent();
+ return getAnnotationProvider().xfind(type, onMethod).map(x ->
x.inner()).findFirst().isPresent();
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java
index 389f4a993d..51b22fa3e5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java
@@ -81,11 +81,11 @@ public class HtmlBeanPropertyMeta extends
ExtendedBeanPropertyMeta {
Builder b = new Builder();
if (nn(bpm.getInnerField()))
- annotationProvider.find(Html.class,
bpm.getInnerField()).map(x -> x.inner()).filter(x -> true).forEach(x ->
b.findHtmlInfo(x));
+ annotationProvider.xfind(Html.class,
bpm.getInnerField()).map(x -> x.inner()).filter(x -> true).forEach(x ->
b.findHtmlInfo(x));
if (nn(bpm.getGetter()))
- annotationProvider.find(Html.class,
bpm.getGetter()).map(x -> x.inner()).filter(x -> true).forEach(x ->
b.findHtmlInfo(x));
+ annotationProvider.xfind(Html.class,
bpm.getGetter()).map(x -> x.inner()).filter(x -> true).forEach(x ->
b.findHtmlInfo(x));
if (nn(bpm.getSetter()))
- annotationProvider.find(Html.class,
bpm.getSetter()).map(x -> x.inner()).filter(x -> true).forEach(x ->
b.findHtmlInfo(x));
+ annotationProvider.xfind(Html.class,
bpm.getSetter()).map(x -> x.inner()).filter(x -> true).forEach(x ->
b.findHtmlInfo(x));
this.format = b.format;
this.noTables = b.noTables;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoListSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoListSwap.java
index 5f05e97359..8703d42ea9 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoListSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoListSwap.java
@@ -133,7 +133,7 @@ public class AutoListSwap<T> extends ObjectSwap<T,List<?>> {
&& mi.hasAnyName(SWAP_METHOD_NAMES)
&& mi.hasReturnTypeParent(List.class)
&& mi.hasParameterTypesLenient(BeanSession.class)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
+ && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
// @formatter:on
}
@@ -143,7 +143,7 @@ public class AutoListSwap<T> extends ObjectSwap<T,List<?>> {
cs.isNotDeprecated()
&&
cs.isVisible(bc.getBeanConstructorVisibility())
&& cs.hasParameterTypeParents(rt)
- &&
bc.getAnnotationProvider().find(BeanIgnore.class,
cs.inner()).findAny().isEmpty();
+ &&
bc.getAnnotationProvider().xfind(BeanIgnore.class,
cs.inner()).findAny().isEmpty();
// @formatter:on
}
@@ -156,12 +156,12 @@ public class AutoListSwap<T> extends
ObjectSwap<T,List<?>> {
&& mi.hasAnyName(UNSWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class,
rt.inner())
&& mi.hasReturnTypeParent(ci)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
+ && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
// @formatter:on
}
private static boolean shouldIgnore(BeanContext bc, ClassInfo ci) {
- return bc.getAnnotationProvider().find(BeanIgnore.class,
ci.inner()).findFirst().isPresent() || ci.isNonStaticMemberClass();
+ return bc.getAnnotationProvider().xfind(BeanIgnore.class,
ci.inner()).findFirst().isPresent() || ci.isNonStaticMemberClass();
}
//------------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoMapSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoMapSwap.java
index 6c500dfd5b..75a1c59ede 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoMapSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoMapSwap.java
@@ -133,7 +133,7 @@ public class AutoMapSwap<T> extends ObjectSwap<T,Map<?,?>> {
&& mi.hasAnyName(SWAP_METHOD_NAMES)
&& mi.hasReturnTypeParent(Map.class)
&& mi.hasParameterTypesLenient(BeanSession.class)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
+ && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
// @formatter:on
}
@@ -143,7 +143,7 @@ public class AutoMapSwap<T> extends ObjectSwap<T,Map<?,?>> {
cs.isNotDeprecated()
&&
cs.isVisible(bc.getBeanConstructorVisibility())
&& cs.hasParameterTypeParents(rt)
- &&
bc.getAnnotationProvider().find(BeanIgnore.class,
cs.inner()).findAny().isEmpty();
+ &&
bc.getAnnotationProvider().xfind(BeanIgnore.class,
cs.inner()).findAny().isEmpty();
// @formatter:on
}
@@ -156,12 +156,12 @@ public class AutoMapSwap<T> extends
ObjectSwap<T,Map<?,?>> {
&& mi.hasAnyName(UNSWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class,
rt.inner())
&& mi.hasReturnTypeParent(ci)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
+ && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
// @formatter:on
}
private static boolean shouldIgnore(BeanContext bc, ClassInfo ci) {
- return bc.getAnnotationProvider().find(BeanIgnore.class,
ci.inner()).findFirst().isPresent() || ci.isNonStaticMemberClass();
+ return bc.getAnnotationProvider().xfind(BeanIgnore.class,
ci.inner()).findFirst().isPresent() || ci.isNonStaticMemberClass();
}
//------------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoNumberSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoNumberSwap.java
index 991b298787..f56ef730c8 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoNumberSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoNumberSwap.java
@@ -158,7 +158,7 @@ public class AutoNumberSwap<T> extends ObjectSwap<T,Number>
{
&& (rt.isChildOf(Number.class) || (rt.isPrimitive() &&
rt.isAny(int.class, short.class, long.class, float.class, double.class,
byte.class)))
&& mi.hasAnyName(SWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
+ && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
// @formatter:on
}
@@ -168,7 +168,7 @@ public class AutoNumberSwap<T> extends ObjectSwap<T,Number>
{
cs.isNotDeprecated()
&& cs.isVisible(bc.getBeanConstructorVisibility())
&& cs.hasParameterTypeParents(rt)
- && bc.getAnnotationProvider().find(BeanIgnore.class,
cs.inner()).findAny().isEmpty();
+ && bc.getAnnotationProvider().xfind(BeanIgnore.class,
cs.inner()).findAny().isEmpty();
// @formatter:on
}
@@ -181,14 +181,14 @@ public class AutoNumberSwap<T> extends
ObjectSwap<T,Number> {
&& mi.hasAnyName(UNSWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class,
rt.inner())
&& mi.hasReturnTypeParent(ci)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
+ && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
// @formatter:on
}
private static boolean shouldIgnore(BeanContext bc, ClassInfo ci) {
// @formatter:off
return
- bc.getAnnotationProvider().find(BeanIgnore.class,
ci.inner()).findFirst().isPresent()
+ bc.getAnnotationProvider().xfind(BeanIgnore.class,
ci.inner()).findFirst().isPresent()
|| ci.isNonStaticMemberClass()
|| ci.isPrimitive()
|| ci.isChildOf(Number.class);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoObjectSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoObjectSwap.java
index 96d8216b53..c579228436 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoObjectSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/AutoObjectSwap.java
@@ -134,7 +134,7 @@ public class AutoObjectSwap<T> extends ObjectSwap<T,Object>
{
&& mi.isVisible(bc.getBeanMethodVisibility())
&& mi.hasAnyName(SWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
+ && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
// @formatter:on
}
@@ -144,7 +144,7 @@ public class AutoObjectSwap<T> extends ObjectSwap<T,Object>
{
cs.isNotDeprecated()
&&
cs.isVisible(bc.getBeanConstructorVisibility())
&& cs.hasParameterTypeParents(rt)
- &&
bc.getAnnotationProvider().find(BeanIgnore.class,
cs.inner()).findAny().isEmpty();
+ &&
bc.getAnnotationProvider().xfind(BeanIgnore.class,
cs.inner()).findAny().isEmpty();
// @formatter:on
}
@@ -157,12 +157,12 @@ public class AutoObjectSwap<T> extends
ObjectSwap<T,Object> {
&& mi.hasAnyName(UNSWAP_METHOD_NAMES)
&& mi.hasParameterTypesLenient(BeanSession.class,
rt.inner())
&& mi.hasReturnTypeParent(ci)
- && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().find(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
+ && ! mi.getMatchingMethods().stream().anyMatch(m2 ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
m2.inner()).findFirst().isPresent());
// @formatter:on
}
private static boolean shouldIgnore(BeanContext bc, ClassInfo ci) {
- return bc.getAnnotationProvider().find(BeanIgnore.class,
ci.inner()).findFirst().isPresent() || ci.isNonStaticMemberClass();
+ return bc.getAnnotationProvider().xfind(BeanIgnore.class,
ci.inner()).findFirst().isPresent() || ci.isNonStaticMemberClass();
}
//------------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/BuilderSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/BuilderSwap.java
index 93b4e1f45d..125866d891 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/BuilderSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/BuilderSwap.java
@@ -97,7 +97,7 @@ public class BuilderSwap<T,B> {
ConstructorInfo objectConstructor = null;
ConstructorInfo builderConstructor;
-
bc.getAnnotationProvider().find(org.apache.juneau.annotation.Builder.class,
objectClass).map(x -> x.inner()).filter(x -> isNotVoid(x.value())).forEach(x ->
builderClass.set(x.value()));
+
bc.getAnnotationProvider().xfind(org.apache.juneau.annotation.Builder.class,
objectClass).map(x -> x.inner()).filter(x -> isNotVoid(x.value())).forEach(x ->
builderClass.set(x.value()));
var pci = ClassInfo.of(objectClass);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/SurrogateSwap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/SurrogateSwap.java
index e7b0cc4a0c..7b5a55397c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/SurrogateSwap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/swap/SurrogateSwap.java
@@ -54,7 +54,7 @@ public class SurrogateSwap<T,F> extends ObjectSwap<T,F> {
public static List<SurrogateSwap<?,?>> findObjectSwaps(Class<?> c,
BeanContext bc) {
List<SurrogateSwap<?,?>> l = new LinkedList<>();
var ci = ClassInfo.of(c);
- ci.getPublicConstructors().stream().filter(x ->
bc.getAnnotationProvider().find(BeanIgnore.class,
x.inner()).findAny().isEmpty() && x.hasNumParameters(1) &&
x.isPublic()).forEach(x -> {
+ ci.getPublicConstructors().stream().filter(x ->
bc.getAnnotationProvider().xfind(BeanIgnore.class,
x.inner()).findAny().isEmpty() && x.hasNumParameters(1) &&
x.isPublic()).forEach(x -> {
var pt = x.getParameter(0).getParameterType().inner();
if (! pt.equals(c.getDeclaringClass())) {
// Find the unswap method if there is one.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
index e06253ab9d..281955c828 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
@@ -46,7 +46,7 @@ public class XmlBeanMeta extends ExtendedBeanMeta {
Class<?> c = beanMeta.getClassMeta().getInnerClass();
Value<XmlFormat> defaultFormat = Value.empty();
-
beanMeta.getClassMeta().getBeanContext().getAnnotationProvider().find(Xml.class,
c).map(x -> x.inner()).filter(x -> true).forEach(x -> {
+
beanMeta.getClassMeta().getBeanContext().getAnnotationProvider().xfind(Xml.class,
c).map(x -> x.inner()).filter(x -> true).forEach(x -> {
XmlFormat xf = x.format();
if (xf == ATTRS)
defaultFormat.set(XmlFormat.ATTR);
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 c49862aa88..46b75c7099 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
@@ -159,7 +159,7 @@ public class BasicSwaggerProviderSession {
// Combine it with @Rest(swagger)
List<Rest> restAnnotations = list();
-
context.getAnnotationProvider().forEachClassAnnotation(Rest.class, rci, x ->
true, x -> restAnnotations.add(x));
+
context.getAnnotationProvider().xforEachClassAnnotation(Rest.class, rci, x ->
true, x -> restAnnotations.add(x));
for (var rr : restAnnotations) {
JsonMap sInfo = omSwagger.getMap("info", true);
@@ -437,9 +437,9 @@ public class BasicSwaggerProviderSession {
for (var eci : mi.getExceptionTypes()) {
if (eci.hasAnnotation(Response.class)) {
List<Response> la = list();
-
context.getAnnotationProvider().forEachClassAnnotation(Response.class, eci, x
-> true, x -> la.add(x));
+
context.getAnnotationProvider().xforEachClassAnnotation(Response.class, eci, x
-> true, x -> la.add(x));
List<StatusCode> la2 = list();
-
context.getAnnotationProvider().forEachClassAnnotation(StatusCode.class, eci, x
-> true, x -> la2.add(x));
+
context.getAnnotationProvider().xforEachClassAnnotation(StatusCode.class, eci,
x -> true, x -> la2.add(x));
Set<Integer> codes = getCodes(la2, 500);
for (var a : la) {
for (var code : codes) {
@@ -461,7 +461,7 @@ public class BasicSwaggerProviderSession {
String ha = a.name();
for (var code : codes) {
JsonMap header
= responses.getMap(String.valueOf(code), true).getMap("headers",
true).getMap(ha, true);
-
context.getAnnotationProvider().forEachMethodAnnotation(Schema.class, ecmi, x
-> true, x -> merge(header, x));
+
context.getAnnotationProvider().xforEachMethodAnnotation(Schema.class, ecmi, x
-> true, x -> merge(header, x));
rstream(ecmi.getReturnType().unwrap(Value.class,
Optional.class).getAnnotations()).map(x ->
x.cast(Schema.class)).filter(Objects::nonNull).map(AnnotationInfo::inner).forEach(x
-> merge(header, x));
pushupSchemaFields(RESPONSE_HEADER, header, getSchema(header.getMap("schema"),
ecmi.getReturnType().unwrap(Value.class, Optional.class).innerType(), bs));
}
@@ -472,16 +472,16 @@ public class BasicSwaggerProviderSession {
if (mi.hasAnnotation(Response.class) ||
mi.getReturnType().unwrap(Value.class,
Optional.class).hasAnnotation(Response.class)) {
List<Response> la = list();
-
context.getAnnotationProvider().forEachMethodAnnotation(Response.class, mi, x
-> true, x -> la.add(x));
+
context.getAnnotationProvider().xforEachMethodAnnotation(Response.class, mi, x
-> true, x -> la.add(x));
List<StatusCode> la2 = list();
-
context.getAnnotationProvider().forEachMethodAnnotation(StatusCode.class, mi, x
-> true, x -> la2.add(x));
+
context.getAnnotationProvider().xforEachMethodAnnotation(StatusCode.class, mi,
x -> true, x -> la2.add(x));
Set<Integer> codes = getCodes(la2, 200);
for (var a : la) {
for (var code : codes) {
JsonMap om =
responses.getMap(String.valueOf(code), true);
merge(om, a);
JsonMap schema =
getSchema(om.getMap("schema"), m.getGenericReturnType(), bs);
-
context.getAnnotationProvider().forEachMethodAnnotation(Schema.class, mi, x ->
true, x -> merge(schema, x));
+
context.getAnnotationProvider().xforEachMethodAnnotation(Schema.class, mi, x ->
true, x -> merge(schema, x));
pushupSchemaFields(RESPONSE,
om, schema);
om.appendIf(nem, "schema",
schema);
addBodyExamples(sm, om, true,
m.getGenericReturnType(), locale);
@@ -497,7 +497,7 @@ public class BasicSwaggerProviderSession {
if (! isMulti(a)) {
for (var code :
codes) {
JsonMap
header = responses.getMap(String.valueOf(code), true).getMap("headers",
true).getMap(ha, true);
-
context.getAnnotationProvider().forEachMethodAnnotation(Schema.class, ecmi, x
-> true, x -> merge(header, x));
+
context.getAnnotationProvider().xforEachMethodAnnotation(Schema.class, ecmi, x
-> true, x -> merge(header, x));
rstream(ecmi.getReturnType().unwrap(Value.class,
Optional.class).getAnnotations()).map(x ->
x.cast(Schema.class)).filter(Objects::nonNull).map(AnnotationInfo::inner).forEach(x
-> merge(header, x));
merge(header, a.schema());
pushupSchemaFields(RESPONSE_HEADER, header, getSchema(header,
ecmi.getReturnType().innerType(), bs));
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ClassInfo_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ClassInfo_Test.java
index 700c732a15..f104ab6754 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ClassInfo_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ClassInfo_Test.java
@@ -595,10 +595,10 @@ public class ClassInfo_Test extends TestBase {
@Test void lastAnnotation() {
// Use AnnotationProvider to get last annotation (first in
child-to-parent order stream)
var ap =
org.apache.juneau.common.reflect.AnnotationProvider.INSTANCE;
- assertEquals(7, ap.find(A.class, g3.inner()).map(x ->
x.inner()).findFirst().get().value());
- assertEquals(7, ap.find(A.class, g4.inner()).map(x ->
x.inner()).findFirst().get().value());
- assertEquals(3, ap.find(A.class, g5.inner()).map(x ->
x.inner()).findFirst().get().value());
- assertEquals(5, ap.find(A.class, g3.inner()).map(x ->
x.inner()).filter(x -> x.value() == 5).findFirst().get().value());
+ assertEquals(7, ap.xfind(A.class, g3.inner()).map(x ->
x.inner()).findFirst().get().value());
+ assertEquals(7, ap.xfind(A.class, g4.inner()).map(x ->
x.inner()).findFirst().get().value());
+ assertEquals(3, ap.xfind(A.class, g5.inner()).map(x ->
x.inner()).findFirst().get().value());
+ assertEquals(5, ap.xfind(A.class, g3.inner()).map(x ->
x.inner()).filter(x -> x.value() == 5).findFirst().get().value());
}
@Test void getPackageAnnotation() {