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 a606e5e JUNEAU-197
a606e5e is described below
commit a606e5ef33a89064de9677b50da84148f48f63f6
Author: JamesBognar <[email protected]>
AuthorDate: Sun Mar 8 11:36:10 2020 -0400
JUNEAU-197
@BeanConfig(bpi) does not override @Bean(bpi)
---
.../apache/juneau/reflection/ParamInfoTest.java | 28 +++----
.../src/main/java/org/apache/juneau/BeanMeta.java | 2 +-
.../juneau/httppart/bean/RequestBeanMeta.java | 2 +-
.../java/org/apache/juneau/reflect/ClassInfo.java | 93 +---------------------
.../java/org/apache/juneau/reflect/MethodInfo.java | 20 ++---
.../java/org/apache/juneau/reflect/ParamInfo.java | 8 +-
.../org/apache/juneau/rest/RestParamDefaults.java | 2 +-
7 files changed, 33 insertions(+), 122 deletions(-)
diff --git
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
index adf8754..54e7590 100644
---
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
+++
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
@@ -247,37 +247,37 @@ public class ParamInfoTest {
@Test
public void getAnnotation() throws Exception {
- check("@CA(5)", cb_a1.getAnnotation(CA.class));
- check("@CA(5)", cb_a2.getAnnotation(CA.class));
- check("@CA(5)", cc_a1.getAnnotation(CA.class));
- check("@CA(6)", cc_a2.getAnnotation(CA.class));
+ check("@CA(5)", cb_a1.getLastAnnotation(CA.class));
+ check("@CA(5)", cb_a2.getLastAnnotation(CA.class));
+ check("@CA(5)", cc_a1.getLastAnnotation(CA.class));
+ check("@CA(6)", cc_a2.getLastAnnotation(CA.class));
}
@Test
public void getAnnotation_notFound() throws Exception {
- check(null, cb_a1.getAnnotation(DA.class));
+ check(null, cb_a1.getLastAnnotation(DA.class));
}
@Test
public void getAnnotation_constructor() throws Exception {
- check("@CA(9)", cc_cc.getAnnotation(CA.class));
+ check("@CA(9)", cc_cc.getLastAnnotation(CA.class));
}
@Test
public void getAnnotation_notFound_constructor() throws Exception {
- check(null, cc_cc.getAnnotation(DA.class));
+ check(null, cc_cc.getLastAnnotation(DA.class));
}
@Test
public void getAnnotation_twice() throws Exception {
- check("@CA(5)", cb_a1.getAnnotation(CA.class));
- check("@CA(5)", cb_a1.getAnnotation(CA.class));
+ check("@CA(5)", cb_a1.getLastAnnotation(CA.class));
+ check("@CA(5)", cb_a1.getLastAnnotation(CA.class));
}
@Test
public void getAnnotation_twice_constructor() throws Exception {
- check("@CA(9)", cc_cc.getAnnotation(CA.class));
- check("@CA(9)", cc_cc.getAnnotation(CA.class));
+ check("@CA(9)", cc_cc.getLastAnnotation(CA.class));
+ check("@CA(9)", cc_cc.getLastAnnotation(CA.class));
}
@Test
@@ -334,13 +334,13 @@ public class ParamInfoTest {
@Test
public void getAnnotation_inherited() throws Exception {
- check("@DA(0)", db_a1.getAnnotation(DA.class));
- check("@DA(5)", dc_a1.getAnnotation(DA.class));
+ check("@DA(0)", db_a1.getLastAnnotation(DA.class));
+ check("@DA(5)", dc_a1.getLastAnnotation(DA.class));
}
@Test
public void getAnnotation_inherited_notFound() throws Exception {
- check(null, db_a1.getAnnotation(CA.class));
+ check(null, db_a1.getLastAnnotation(CA.class));
}
//-----------------------------------------------------------------------------------------------------------------
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 ea1666f..37e137f 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
@@ -199,7 +199,7 @@ public class BeanMeta<T> {
Map<String,BeanPropertyMeta.Builder>
normalProps = new LinkedHashMap<>();
- Annotation ba = ci.findFirstAnnotation(ctx,
Bean.class, BeanIgnore.class);
+ Annotation ba = ci.getAnyLastAnnotation(ctx,
Bean.class, BeanIgnore.class);
boolean hasBean = ba != null &&
ba.annotationType() == Bean.class;
boolean hasBeanIgnore = ba != null &&
ba.annotationType() == BeanIgnore.class;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
index 8e9daad..dfc6c5c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
@@ -91,7 +91,7 @@ public class RequestBeanMeta {
}
Builder apply(ParamInfo mpi) {
- return
apply(mpi.getParameterType().inner()).apply(mpi.getAnnotation(Request.class));
+ return
apply(mpi.getParameterType().inner()).apply(mpi.getLastAnnotation(Request.class));
}
Builder apply(Class<?> c) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
index 3d1b95f..94d62cf 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
@@ -1104,55 +1104,6 @@ public final class ClassInfo {
* <p>
* Annotations are appended in the following orders:
* <ol>
- * <li>On this class.
- * <li>On parent classes ordered child-to-parent.
- * <li>On interfaces ordered child-to-parent.
- * <li>On the package of this class.
- * </ol>
- *
- * @param l The list of annotations.
- * @param a The annotation to search for.
- * @return The same list.
- */
- public <T extends Annotation> List<T> appendAnnotations(List<T> l,
Class<T> a) {
- return appendAnnotations(l, a, MetaProvider.DEFAULT);
- }
-
- /**
- * Finds and appends the specified annotation on the specified class
and superclasses/interfaces to the specified
- * list.
- *
- * <p>
- * Annotations are appended in the following orders:
- * <ol>
- * <li>On this class.
- * <li>On parent classes ordered child-to-parent.
- * <li>On interfaces ordered child-to-parent.
- * <li>On the package of this class.
- * </ol>
- *
- * @param <T> The annotation to search for.
- * @param l The list of annotations.
- * @param a The annotation to search for.
- * @param mp The meta provider for looking up annotations on reflection
objects (classes, methods, fields, constructors).
- * @return The same list.
- */
- public <T extends Annotation> List<T> appendAnnotations(List<T> l,
Class<T> a, MetaProvider mp) {
- for (ClassInfo ci : getParents())
- addIfNotNull(l, mp.getDeclaredAnnotation(a,
ci.inner()));
- for (ClassInfo ci : getInterfaces())
- addIfNotNull(l, mp.getDeclaredAnnotation(a,
ci.inner()));
- addIfNotNull(l, getPackageAnnotation(a));
- return l;
- }
-
- /**
- * Finds and appends the specified annotation on the specified class
and superclasses/interfaces to the specified
- * list.
- *
- * <p>
- * Annotations are appended in the following orders:
- * <ol>
* <li>On the package of this class.
* <li>On interfaces ordered child-to-parent.
* <li>On parent classes ordered child-to-parent.
@@ -1201,32 +1152,6 @@ public final class ClassInfo {
* <p>
* Annotations are appended in the following orders:
* <ol>
- * <li>On this class.
- * <li>On parent classes ordered child-to-parent.
- * <li>On interfaces ordered child-to-parent.
- * <li>On the package of this class.
- * </ol>
- *
- * @param l The list of annotations.
- * @param a The annotation to search for.
- * @return The same list.
- */
- public <T extends Annotation> List<AnnotationInfo<T>>
appendAnnotationInfos(List<AnnotationInfo<T>> l, Class<T> a) {
- for (ClassInfo ci : getParents())
- addIfNotNull(l, ci.getDeclaredAnnotationInfo(a));
- for (ClassInfo ci : getInterfaces())
- addIfNotNull(l, ci.getDeclaredAnnotationInfo(a));
- addIfNotNull(l, getPackageAnnotationInfo(a));
- return l;
- }
-
- /**
- * Finds and appends the specified annotation on the specified class
and superclasses/interfaces to the specified
- * list.
- *
- * <p>
- * Annotations are appended in the following orders:
- * <ol>
* <li>On the package of this class.
* <li>On interfaces ordered child-to-parent.
* <li>On parent classes ordered child-to-parent.
@@ -1254,7 +1179,7 @@ public final class ClassInfo {
* @return The first annotation found, or <jk>null</jk> if not found.
*/
@SafeVarargs
- public final Annotation findFirstAnnotation(MetaProvider mp, Class<?
extends Annotation>...annotations) {
+ public final Annotation getAnyLastAnnotation(MetaProvider mp, Class<?
extends Annotation>...annotations) {
for (Class<? extends Annotation> ca : annotations) {
Annotation x = getLastAnnotation(ca, mp);
if (x != null)
@@ -1268,24 +1193,10 @@ public final class ClassInfo {
}
}
ClassInfo ci = getParent();
- return ci == null ? null : ci.findFirstAnnotation(mp,
annotations);
+ return ci == null ? null : ci.getAnyLastAnnotation(mp,
annotations);
}
- AnnotationList appendAnnotationList(AnnotationList m) {
- for (ClassInfo ci : getParents())
- for (Annotation a : ci.c.getDeclaredAnnotations())
- m.add(AnnotationInfo.of(ci, a));
- for (ClassInfo ci : getInterfaces())
- for (Annotation a : ci.c.getDeclaredAnnotations())
- m.add(AnnotationInfo.of(ci, a));
- Package p = c.getPackage();
- if (p != null)
- for (Annotation a : p.getDeclaredAnnotations())
- m.add(AnnotationInfo.of(p, a));
- return m;
- }
-
AnnotationList appendAnnotationListParentFirst(AnnotationList m) {
Package p = c.getPackage();
if (p != null)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java
index aa7853d..bfefe7f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java
@@ -322,14 +322,14 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
AnnotationList appendAnnotationListParentFirst(AnnotationList al) {
ClassInfo c = this.declaringClass;
- appendAnnotations(al, c.getPackage());
+ appendDeclaredAnnotations(al, c.getPackage());
for (ClassInfo ci : c.getInterfacesParentFirst()) {
- appendAnnotations(al, ci);
- appendMethodAnnotations(al, ci);
+ appendDeclaredAnnotations(al, ci);
+ appendDeclaredMethodAnnotations(al, ci);
}
for (ClassInfo ci : c.getParentsParentFirst()) {
- appendAnnotations(al, ci);
- appendMethodAnnotations(al, ci);
+ appendDeclaredAnnotations(al, ci);
+ appendDeclaredMethodAnnotations(al, ci);
}
return al;
}
@@ -337,25 +337,25 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
AnnotationList appendAnnotationListMethodOnlyParentFirst(AnnotationList
al) {
ClassInfo c = this.declaringClass;
for (ClassInfo ci : c.getInterfacesParentFirst())
- appendMethodAnnotations(al, ci);
+ appendDeclaredMethodAnnotations(al, ci);
for (ClassInfo ci : c.getParentsParentFirst())
- appendMethodAnnotations(al, ci);
+ appendDeclaredMethodAnnotations(al, ci);
return al;
}
- void appendAnnotations(AnnotationList al, Package p) {
+ void appendDeclaredAnnotations(AnnotationList al, Package p) {
if (p != null)
for (Annotation a : p.getDeclaredAnnotations())
al.add(AnnotationInfo.of(p, a));
}
- void appendAnnotations(AnnotationList al, ClassInfo ci) {
+ void appendDeclaredAnnotations(AnnotationList al, ClassInfo ci) {
if (ci != null)
for (Annotation a : ci.c.getDeclaredAnnotations())
al.add(AnnotationInfo.of(ci, a));
}
- void appendMethodAnnotations(AnnotationList al, ClassInfo ci) {
+ void appendDeclaredMethodAnnotations(AnnotationList al, ClassInfo ci) {
Method m = findMatchingOnClass(ci);
if (m != null)
for (Annotation a : m.getDeclaredAnnotations())
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java
index e970364..9eff74d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java
@@ -131,7 +131,7 @@ public final class ParamInfo {
* The annotation if found, or <jk>null</jk> if not.
*/
@SuppressWarnings("unchecked")
- public <T extends Annotation> T getAnnotation(Class<T> a) {
+ public <T extends Annotation> T getLastAnnotation(Class<T> a) {
Optional<Annotation> o = annotationMap().get(a);
if (o == null) {
o = Optional.ofNullable(findAnnotation(a));
@@ -149,7 +149,7 @@ public final class ParamInfo {
* The <jk>true</jk> if annotation if found.
*/
public boolean hasAnnotation(Class<? extends Annotation> a) {
- return getAnnotation(a) != null;
+ return getLastAnnotation(a) != null;
}
@SuppressWarnings("unchecked")
@@ -200,7 +200,7 @@ public final class ParamInfo {
for (Annotation a2 : annotations)
if (a.isInstance(a2))
l.add((T)a2);
- ci.appendAnnotations(l, a);
+ ci.appendAnnotationsParentFirst(l, a);
}
} else {
MethodInfo mi = (MethodInfo)eInfo;
@@ -216,7 +216,7 @@ public final class ParamInfo {
for (Annotation a2 :
m2.getParameterAnnotations()[index])
if (a.isInstance(a2))
l.add((T)a2);
- ci.appendAnnotations(l, a);
+ ci.appendAnnotationsParentFirst(l, a);
}
}
return l;
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
index 385ba0a..c6354cb 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
@@ -217,7 +217,7 @@ class RestParamDefaults {
MethodInfo mi = mpi.getMethod();
for (int j = 0; j < i; j++)
- if
(mi.getParam(i).getAnnotation(Path.class) != null)
+ if
(mi.getParam(i).getLastAnnotation(Path.class) != null)
idx++;
String[] vars = pathPattern.getVars();