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 a1c4318 ClassInfo refactoring.
a1c4318 is described below
commit a1c4318af83eeaf58bf404d3fc723d4cf77a75a1
Author: JamesBognar <[email protected]>
AuthorDate: Sun Jan 30 15:46:38 2022 -0500
ClassInfo refactoring.
---
.../main/ConfigurablePropertyCodeGenerator.java | 2 +-
.../src/main/java/org/apache/juneau/BeanMeta.java | 2 +-
.../src/main/java/org/apache/juneau/ClassMeta.java | 4 +-
.../src/main/java/org/apache/juneau/Context.java | 9 +-
.../annotation/InvalidAnnotationException.java | 2 +-
.../http/annotation/HasFormDataAnnotation.java | 22 ----
.../juneau/http/annotation/HasQueryAnnotation.java | 22 ----
.../org/apache/juneau/httppart/HttpPartSchema.java | 4 +-
.../juneau/httppart/bean/RequestBeanMeta.java | 2 +-
.../httppart/bean/RequestBeanPropertyMeta.java | 6 +-
.../juneau/httppart/bean/ResponseBeanMeta.java | 10 +-
.../org/apache/juneau/reflect/AnnotationInfo.java | 44 +++----
.../java/org/apache/juneau/reflect/ClassInfo.java | 110 ++++++++--------
.../org/apache/juneau/reflect/ConstructorInfo.java | 30 ++---
.../apache/juneau/reflect/ContextApplyFilter.java | 38 ------
.../org/apache/juneau/reflect/ExecutableInfo.java | 25 ++--
.../java/org/apache/juneau/reflect/FieldInfo.java | 44 +++----
.../java/org/apache/juneau/reflect/MethodInfo.java | 143 +++++++-------------
.../java/org/apache/juneau/reflect/ParamInfo.java | 145 ++++++++++-----------
.../apache/juneau/reflect/ReflectionFilters.java | 98 --------------
.../java/org/apache/juneau/rest/RestContext.java | 12 +-
.../java/org/apache/juneau/rest/RestOpContext.java | 9 +-
.../org/apache/juneau/rest/arg/HasFormDataArg.java | 15 ++-
.../org/apache/juneau/rest/arg/HasQueryArg.java | 14 +-
.../java/org/apache/juneau/rest/arg/PathArg.java | 2 +-
.../rest/swagger/BasicSwaggerProviderSession.java | 28 ++--
.../juneau/{reflection => reflect}/AClass.java | 2 +-
.../juneau/{reflection => reflect}/AInterface.java | 2 +-
.../AnnotationInfoTest.java | 3 +-
.../{reflection => reflect}/ClassInfoTest.java | 68 +++++-----
.../ConstructorInfoTest.java | 3 +-
.../ExecutableInfoTest.java | 21 ++-
.../{reflection => reflect}/FieldInfoTest.java | 5 +-
.../{reflection => reflect}/MethodInfoTest.java | 60 +++++----
.../apache/juneau/{reflection => reflect}/PA.java | 2 +-
.../{reflection => reflect}/ParamInfoTest.java | 78 ++++++-----
.../{reflection => reflect}/package-info.java | 2 +-
.../client/RestClient_Config_Context_Test.java | 4 +-
38 files changed, 443 insertions(+), 649 deletions(-)
diff --git a/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java
b/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java
index ad66eb8..38e6228 100644
--- a/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java
+++ b/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java
@@ -102,7 +102,7 @@ public class ConfigurablePropertyCodeGenerator {
ClassInfo ci = ClassInfo.of(c);
String cName = ci.getSimpleName();
Set<String> ignore = ASet.of();
- FluentSetters fs =
ci.getLastAnnotation(FluentSetters.class);
+ FluentSetters fs =
ci.getAnnotation(FluentSetters.class);
if (! fs.returns().isEmpty())
cName = fs.returns();
for (String i : fs.ignore())
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 a86c540..17ece9f 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
@@ -663,7 +663,7 @@ public class BeanMeta<T> {
if (m.hasAnnotation(ctx, BeanIgnore.class))
continue;
- Transient t = m.getLastAnnotation(ctx,
Transient.class);
+ Transient t = m.getAnnotation(ctx,
Transient.class);
if (t != null && t.value())
continue;
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 278b499..36e7934 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
@@ -2083,8 +2083,8 @@ public final class ClassMeta<T> implements Type {
Optional<A> o = (Optional<A>)annotationLastMap.get(a);
if (o == null) {
if (beanContext == null)
- return
info.getLastAnnotation(BeanContext.DEFAULT, a);
- o =
Optional.ofNullable(info.getLastAnnotation(beanContext, a));
+ return info.getAnnotation(BeanContext.DEFAULT,
a);
+ o = Optional.ofNullable(info.getAnnotation(beanContext,
a));
annotationLastMap.put(a, o);
}
return o.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 65dfbed..124e8e1 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
@@ -80,6 +80,11 @@ public abstract class Context implements AnnotationProvider {
private static final Map<Class<?>,MethodInfo> BUILDER_CREATE_METHODS =
new ConcurrentHashMap<>();
/**
+ * Predicate for annotations that themselves are annotated with {@link
ContextApply}.
+ */
+ public static final Predicate<AnnotationInfo<?>> CONTEXT_APPLY_FILTER =
x -> x.hasAnnotation(ContextApply.class);
+
+ /**
* Instantiates a builder of the specified context class.
*
* <p>
@@ -447,7 +452,7 @@ public abstract class Context implements AnnotationProvider
{
public Builder applyAnnotations(Class<?>...fromClasses) {
AnnotationWorkList work = AnnotationWorkList.create();
for (Class<?> c : fromClasses)
-
work.add(ClassInfo.of(c).getAnnotationList(ContextApplyFilter.INSTANCE));
+
work.add(ClassInfo.of(c).getAnnotationList(CONTEXT_APPLY_FILTER));
return apply(work);
}
@@ -511,7 +516,7 @@ public abstract class Context implements AnnotationProvider
{
public Builder applyAnnotations(Method...fromMethods) {
AnnotationWorkList work = AnnotationWorkList.create();
for (Method m : fromMethods)
-
work.add(MethodInfo.of(m).getAnnotationList(ContextApplyFilter.INSTANCE));
+
work.add(MethodInfo.of(m).getAnnotationList(CONTEXT_APPLY_FILTER));
return apply(work);
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/InvalidAnnotationException.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/InvalidAnnotationException.java
index 608ba67..0e58b5b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/InvalidAnnotationException.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/InvalidAnnotationException.java
@@ -49,7 +49,7 @@ public class InvalidAnnotationException extends
BasicRuntimeException {
*/
@SafeVarargs
public static void assertNoInvalidAnnotations(MethodInfo m, Class<?
extends Annotation>...a) throws InvalidAnnotationException {
- Annotation aa = m.getAnyLastAnnotation(a);
+ Annotation aa = m.getAnyAnnotation(a);
if (aa != null)
throw new InvalidAnnotationException("@{0} annotation
cannot be used in a @{1} bean. Method=''{2}''", aa.getClass().getSimpleName(),
m.getDeclaringClass().getSimpleName(), m);
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
index 5e79315..d492267 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
@@ -12,11 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.http.annotation;
-import static org.apache.juneau.internal.StringUtils.*;
-
import java.lang.annotation.*;
-import java.util.*;
-
import org.apache.juneau.annotation.*;
/**
@@ -44,24 +40,6 @@ public class HasFormDataAnnotation {
return new Builder();
}
- /**
- * Finds the name from the specified lists of annotations.
- *
- * <p>
- * The last matching name found is returned.
- *
- * @param lists The lists to search.
- * @return The last matching name, or {@link Optional#empty()} if not
found.
- */
- @SafeVarargs
- public static Optional<String> findName(List<HasFormData>...lists) {
- String n = null;
- for (List<HasFormData> l : lists)
- for (HasFormData h : l)
- n = firstNonEmpty(h.name(), h.value(), n);
- return Optional.ofNullable(n);
- }
-
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
index 2f5a8f7..4924741 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
@@ -12,11 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.http.annotation;
-import static org.apache.juneau.internal.StringUtils.*;
-
import java.lang.annotation.*;
-import java.util.*;
-
import org.apache.juneau.annotation.*;
/**
@@ -44,24 +40,6 @@ public class HasQueryAnnotation {
return new Builder();
}
- /**
- * Finds the name from the specified lists of annotations.
- *
- * <p>
- * The last matching name found is returned.
- *
- * @param lists The lists to search.
- * @return The last matching name, or {@link Optional#empty()} if not
found.
- */
- @SafeVarargs
- public static Optional<String> findName(List<HasQuery>...lists) {
- String n = null;
- for (List<HasQuery> l : lists)
- for (HasQuery h : l)
- n = firstNonEmpty(h.name(), h.value(), n);
- return Optional.ofNullable(n);
- }
-
//-----------------------------------------------------------------------------------------------------------------
// Builder
//-----------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index 7ebf180..a310fbb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -662,9 +662,7 @@ public class HttpPartSchema {
Builder apply(Class<? extends Annotation> c, ParamInfo mpi) {
apply(c, mpi.getParameterType().innerType());
- for (Annotation a : mpi.getDeclaredAnnotations())
- if (c.isInstance(a))
- apply(a);
+ mpi.getDeclaredAnnotations(c, x -> true, x -> apply(x));
return this;
}
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 c7fa6f6..f54cc38 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.getLastAnnotation(Request.class));
+ return
apply(mpi.getParameterType().inner()).apply(mpi.getAnnotation(Request.class));
}
Builder apply(Class<?> c) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanPropertyMeta.java
index 434f203..1d4d57d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanPropertyMeta.java
@@ -35,10 +35,8 @@ public class RequestBeanPropertyMeta {
static RequestBeanPropertyMeta.Builder create(HttpPartType partType,
Class<? extends Annotation> c, MethodInfo m) {
HttpPartSchema.Builder sb =
HttpPartSchema.create().name(m.getPropertyName());
- for (Annotation a : m.getAnnotations(Schema.class))
- sb.apply(a);
- for (Annotation a : m.getAnnotations(c))
- sb.apply(a);
+ m.getAnnotations(Schema.class, x -> true, x -> sb.apply(x));
+ m.getAnnotations(c, x -> true, x -> sb.apply(x));
return new
Builder().partType(partType).schema(sb.build()).getter(m.inner());
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
index d1bc9fe..a8f6d2a 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
@@ -72,8 +72,8 @@ public class ResponseBeanMeta {
return null;
Builder b = new Builder(annotations);
b.apply(m.getReturnType().unwrap(Value.class,
Optional.class).innerType());
- m.getAnnotations(Response.class).forEach(x -> b.apply(x));
- m.getAnnotations(StatusCode.class).forEach(x -> b.apply(x));
+ m.getAnnotations(Response.class, x -> true, x -> b.apply(x));
+ m.getAnnotations(StatusCode.class, x -> true, x -> b.apply(x));
return b.build();
}
@@ -89,8 +89,8 @@ public class ResponseBeanMeta {
return null;
Builder b = new Builder(annotations);
b.apply(mpi.getParameterType().unwrap(Value.class,
Optional.class).innerType());
- mpi.getAnnotations(Response.class).forEach(x -> b.apply(x));
- mpi.getAnnotations(StatusCode.class).forEach(x -> b.apply(x));
+ mpi.getAnnotations(Response.class, x-> true, x -> b.apply(x));
+ mpi.getAnnotations(StatusCode.class, x -> true, x ->
b.apply(x));
return b.build();
}
@@ -160,7 +160,7 @@ public class ResponseBeanMeta {
if (m.hasAnnotation(Header.class)) {
assertNoArgs(m, Header.class);
assertReturnNotVoid(m, Header.class);
- HttpPartSchema s =
HttpPartSchema.create(m.getLastAnnotation(Header.class), m.getPropertyName());
+ HttpPartSchema s =
HttpPartSchema.create(m.getAnnotation(Header.class), m.getPropertyName());
headerMethods.put(s.getName(),
ResponseBeanPropertyMeta.create(RESPONSE_HEADER, s, m));
} else if (m.hasAnnotation(StatusCode.class)) {
assertNoArgs(m, Header.class);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
index 2c7636b..abd331e 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
@@ -49,7 +49,7 @@ public class AnnotationInfo<T extends Annotation> {
* @param p The package where the annotation was found.
* @param a The annotation found.
*/
- protected AnnotationInfo(ClassInfo c, MethodInfo m, Package p, T a) {
+ AnnotationInfo(ClassInfo c, MethodInfo m, Package p, T a) {
this.c = c;
this.m = m;
this.p = p;
@@ -73,34 +73,34 @@ public class AnnotationInfo<T extends Annotation> {
/**
* Convenience constructor when annotation is found on a class.
*
- * @param c The class where the annotation was found.
- * @param a The annotation found.
+ * @param onClass The class where the annotation was found.
+ * @param value The annotation found.
* @return A new {@link AnnotationInfo} object.
*/
- public static <T extends Annotation> AnnotationInfo<T> of(ClassInfo c,
T a) {
- return new AnnotationInfo<>(c, null, null, a);
+ public static <A extends Annotation> AnnotationInfo<A> of(ClassInfo
onClass, A value) {
+ return new AnnotationInfo<>(onClass, null, null, value);
}
/**
* Convenience constructor when annotation is found on a method.
*
- * @param m The method where the annotation was found.
- * @param a The annotation found.
+ * @param onMethod The method where the annotation was found.
+ * @param value The annotation found.
* @return A new {@link AnnotationInfo} object.
*/
- public static <T extends Annotation> AnnotationInfo<T> of(MethodInfo m,
T a) {
- return new AnnotationInfo<>(null, m, null, a);
+ public static <A extends Annotation> AnnotationInfo<A> of(MethodInfo
onMethod, A value) {
+ return new AnnotationInfo<>(null, onMethod, null, value);
}
/**
* Convenience constructor when annotation is found on a package.
*
- * @param p The package where the annotation was found.
- * @param a The annotation found.
+ * @param onPackage The package where the annotation was found.
+ * @param value The annotation found.
* @return A new {@link AnnotationInfo} object.
*/
- public static <T extends Annotation> AnnotationInfo<T> of(Package p, T
a) {
- return new AnnotationInfo<>(null, null, p, a);
+ public static <A extends Annotation> AnnotationInfo<A> of(Package
onPackage, A value) {
+ return new AnnotationInfo<>(null, null, onPackage, value);
}
/**
@@ -181,7 +181,7 @@ public class AnnotationInfo<T extends Annotation> {
* @throws ExecutableException Exception occurred on invoked
constructor/method/field.
*/
@SuppressWarnings("unchecked")
- public AnnotationInfo<?> getApplies(VarResolverSession vrs,
Consumer<AnnotationApplier<Annotation,Object>> consumer) throws
ExecutableException {
+ public AnnotationInfo<T> getApplies(VarResolverSession vrs,
Consumer<AnnotationApplier<Annotation,Object>> consumer) throws
ExecutableException {
try {
if (applyConstructors == null) {
ContextApply cpa =
a.annotationType().getAnnotation(ContextApply.class);
@@ -217,22 +217,22 @@ public class AnnotationInfo<T extends Annotation> {
/**
* Returns <jk>true</jk> if this annotation is the specified type.
*
- * @param a The type to test against.
+ * @param type The type to test against.
* @return <jk>true</jk> if this annotation is the specified type.
*/
- public boolean isType(Class<? extends Annotation> a) {
+ public <A extends Annotation> boolean isType(Class<A> type) {
Class<? extends Annotation> at = this.a.annotationType();
- return at == a;
+ return at == type;
}
/**
* Returns <jk>true</jk> if this annotation has the specified
annotation defined on it.
*
- * @param a The annotation to test for.
+ * @param type The annotation to test for.
* @return <jk>true</jk> if this annotation has the specified
annotation defined on it.
*/
- public boolean hasAnnotation(Class<? extends Annotation> a) {
- return this.a.annotationType().getAnnotation(a) != null;
+ public <A extends Annotation> boolean hasAnnotation(Class<A> type) {
+ return this.a.annotationType().getAnnotation(type) != null;
}
/**
@@ -241,7 +241,7 @@ public class AnnotationInfo<T extends Annotation> {
* @param group The group annotation.
* @return <jk>true</jk> if this annotation is in the specified {@link
AnnotationGroup group}.
*/
- public boolean isInGroup(Class<? extends Annotation> group) {
+ public <A extends Annotation> boolean isInGroup(Class<A> group) {
AnnotationGroup x =
a.annotationType().getAnnotation(AnnotationGroup.class);
return (x != null && x.value().equals(group));
}
@@ -269,7 +269,7 @@ public class AnnotationInfo<T extends Annotation> {
return this;
}
- @Override
+ @Override /* Object */
public String toString() {
return SimpleJson.DEFAULT_READABLE.toString(toOMap());
}
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 c56ee0e..687e035 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
@@ -350,7 +350,7 @@ public final class ClassInfo {
* <p>
* Results are classes-before-interfaces, then child-to-parent order.
*
- * @param predicate The predicate to test for.
+ * @param predicate The predicate.
* @return The parent class or interface that matches the specified
predicate.
*/
public ClassInfo getAnyParent(Predicate<ClassInfo> predicate) {
@@ -689,7 +689,7 @@ public final class ClassInfo {
/**
* Returns the declared constructor that matches the specified
predicate.
*
- * @param predicate The predicate to match.
+ * @param predicate The predicate.
* @return The declared constructor that matches the specified
predicate.
*/
public ConstructorInfo
getDeclaredConstructor(Predicate<ConstructorInfo> predicate) {
@@ -919,13 +919,11 @@ public final class ClassInfo {
/**
* Returns all annotations of the specified type defined on the
specified class or parent classes/interfaces in parent-to-child order.
*
- * @param a
- * The annotation to search for.
- * @return
- * A list of all matching annotations found or an empty list if
none found.
+ * @param type The annotation type to look for.
+ * @return The matching annotations.
*/
- public <T extends Annotation> List<T> getAnnotations(Class<T> a) {
- return getAnnotations(AnnotationProvider.DEFAULT, a);
+ public <A extends Annotation> List<A> getAnnotations(Class<A> type) {
+ return getAnnotations(AnnotationProvider.DEFAULT, type);
}
/**
@@ -933,29 +931,27 @@ public final class ClassInfo {
*
* <p>
* Returns the list in reverse (parent-to-child) order.
- * @param ap The meta provider for looking up annotations on reflection
objects (classes, methods, fields, constructors).
- * @param a
- * The annotation to search for.
*
- * @return
- * A list of all matching annotations found or an empty list if
none found.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation type to look for.
+ * @return The matching annotations.
*/
- public <T extends Annotation> List<T> getAnnotations(AnnotationProvider
ap, Class<T> a) {
- List<T> l = new ArrayList<>();
- getAnnotations(ap, a, x-> true, x -> l.add(x));
+ public <A extends Annotation> List<A> getAnnotations(AnnotationProvider
annotationProvider, Class<A> type) {
+ List<A> l = new ArrayList<>();
+ getAnnotations(annotationProvider, type, x-> true, x ->
l.add(x));
return l;
}
/**
* Consumes all matching annotations of the specified type defined on
this or parent classes/interfaces.
*
- * @param a The annotation to look for.
+ * @param type The annotation to look for.
* @param predicate The predicate.
* @param consumer The consumer.
* @return This object.
*/
- public <T extends Annotation> ClassInfo getAnnotations(Class<T> a,
Predicate<T> predicate, Consumer<T> consumer) {
- return getAnnotations(AnnotationProvider.DEFAULT, a, predicate,
consumer);
+ public <A extends Annotation> ClassInfo getAnnotations(Class<A> type,
Predicate<A> predicate, Consumer<A> consumer) {
+ return getAnnotations(AnnotationProvider.DEFAULT, type,
predicate, consumer);
}
/**
@@ -970,24 +966,24 @@ public final class ClassInfo {
* <li>On this class.
* </ol>
*
- * @param ap The meta provider for looking up annotations on reflection
objects (classes, methods, fields, constructors).
- * @param a The annotation to search for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @param predicate The predicate.
* @param consumer The consumer.
* @return This object.
*/
- public <T extends Annotation> ClassInfo
getAnnotations(AnnotationProvider ap, Class<T> a, Predicate<T> predicate,
Consumer<T> consumer) {
+ public <A extends Annotation> ClassInfo
getAnnotations(AnnotationProvider annotationProvider, Class<A> type,
Predicate<A> predicate, Consumer<A> consumer) {
if (predicate == null) predicate = x->true;
- if (ap == null) ap = AnnotationProvider.DEFAULT;
- T t2 = getPackageAnnotation(a);
+ if (annotationProvider == null) annotationProvider =
AnnotationProvider.DEFAULT;
+ A t2 = getPackageAnnotation(type);
if (t2 != null && predicate.test(t2))
consumer.accept(t2);
ClassInfo[] interfaces = _getInterfaces();
for (int i = interfaces.length-1; i >= 0; i--)
- ap.getDeclaredAnnotations(a, interfaces[i].inner(),
predicate, consumer);
+ annotationProvider.getDeclaredAnnotations(type,
interfaces[i].inner(), predicate, consumer);
ClassInfo[] parents = _getParents();
for (int i = parents.length-1; i >= 0; i--)
- ap.getDeclaredAnnotations(a, parents[i].inner(),
predicate, consumer);
+ annotationProvider.getDeclaredAnnotations(type,
parents[i].inner(), predicate, consumer);
return this;
}
@@ -999,11 +995,11 @@ public final class ClassInfo {
* signature on the parent classes or interfaces.
* <br>The search is performed in child-to-parent order.
*
- * @param a The annotation to search for.
+ * @param type The annotation to look for.
* @return The annotation if found, or <jk>null</jk> if not.
*/
- public <T extends Annotation> T getLastAnnotation(Class<T> a) {
- return getLastAnnotation(AnnotationProvider.DEFAULT, a);
+ public <A extends Annotation> A getAnnotation(Class<A> type) {
+ return getAnnotation(AnnotationProvider.DEFAULT, type);
}
/**
@@ -1012,57 +1008,57 @@ public final class ClassInfo {
* <p>
* If the annotation cannot be found on the immediate class, searches
methods with the same signature on the parent classes or interfaces. <br>
* The search is performed in child-to-parent order.
- * @param ap The meta provider for looking up annotations on reflection
objects (classes, methods, fields, constructors).
- * @param a The annotation to search for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
*
* @return The annotation if found, or <jk>null</jk> if not.
*/
- public <T extends Annotation> T getLastAnnotation(AnnotationProvider
ap, Class<T> a) {
- return findAnnotation(ap, a);
+ public <A extends Annotation> A getAnnotation(AnnotationProvider
annotationProvider, Class<A> type) {
+ return findAnnotation(annotationProvider, type);
}
/**
* Returns <jk>true</jk> if this class has the specified annotation.
*
- * @param a The annotation to search for.
+ * @param type The annotation to look for.
* @return The <jk>true</jk> if annotation if found.
*/
- public boolean hasAnnotation(Class<? extends Annotation> a) {
- return hasAnnotation(AnnotationProvider.DEFAULT, a);
+ public <A extends Annotation> boolean hasAnnotation(Class<A> type) {
+ return hasAnnotation(AnnotationProvider.DEFAULT, type);
}
/**
* Returns <jk>true</jk> if this class has the specified annotation.
*
- * @param ap The annotation provider.
- * @param a The annotation to search for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @return The <jk>true</jk> if annotation if found.
*/
- public boolean hasAnnotation(AnnotationProvider ap, Class<? extends
Annotation> a) {
- return ap.getAnnotation(a, c, x -> true) != null;
+ public <A extends Annotation> boolean hasAnnotation(AnnotationProvider
annotationProvider, Class<A> type) {
+ return annotationProvider.getAnnotation(type, c, x -> true) !=
null;
}
/**
* Returns the specified annotation only if it's been declared on the
package of this class.
*
- * @param <T> The annotation class type.
- * @param a The annotation class.
+ * @param <A> The annotation class type.
+ * @param type The annotation class.
* @return The annotation, or <jk>null</jk> if not found.
*/
- public <T extends Annotation> T getPackageAnnotation(Class<T> a) {
+ public <A extends Annotation> A getPackageAnnotation(Class<A> type) {
Package p = c == null ? null : c.getPackage();
- return (p == null ? null : p.getAnnotation(a));
+ return (p == null ? null : p.getAnnotation(type));
}
/**
* Returns the first matching annotation of the specified type defined
on the specified class or parent classes/interfaces in parent-to-child order.
*
- * @param a The annotation to search for.
+ * @param type The annotation to look for.
* @param predicate The predicate.
* @return This object.
*/
- public <T extends Annotation> T getAnnotation(Class<T> a, Predicate<T>
predicate) {
- return getAnnotation(AnnotationProvider.DEFAULT, a, predicate);
+ public <A extends Annotation> A getAnnotation(Class<A> type,
Predicate<A> predicate) {
+ return getAnnotation(AnnotationProvider.DEFAULT, type,
predicate);
}
/**
@@ -1104,7 +1100,7 @@ public final class ClassInfo {
return l;
}
- /**
+ /*
* If the annotation is an array of other annotations, returns the
inner annotations.
*
* @param a The annotation to split if repeated.
@@ -1122,39 +1118,39 @@ public final class ClassInfo {
return new Annotation[]{a};
}
- private <T extends Annotation> T findAnnotation(AnnotationProvider ap,
Class<T> a) {
+ private <A extends Annotation> A findAnnotation(AnnotationProvider ap,
Class<A> a) {
if (a == null)
return null;
- T t = ap.getDeclaredAnnotation(a, c, x -> true);
+ A t = ap.getDeclaredAnnotation(a, c, x -> true);
if (t != null)
return t;
ClassInfo sci = getParent();
if (sci != null) {
- t = sci.getLastAnnotation(ap, a);
+ t = sci.getAnnotation(ap, a);
if (t != null)
return t;
}
for (ClassInfo c2 : _getInterfaces()) {
- t = c2.getLastAnnotation(ap, a);
+ t = c2.getAnnotation(ap, a);
if (t != null)
return t;
}
return null;
}
- private <T extends Annotation> T getAnnotation(AnnotationProvider ap,
Class<T> a, Predicate<T> p) {
- T t2 = getPackageAnnotation(a);
+ private <A extends Annotation> A getAnnotation(AnnotationProvider ap,
Class<A> a, Predicate<A> p) {
+ A t2 = getPackageAnnotation(a);
if (t2 != null && p.test(t2))
return t2;
ClassInfo[] interfaces = _getInterfaces();
for (int i = interfaces.length-1; i >= 0; i--) {
- T o = ap.getDeclaredAnnotation(a,
interfaces[i].inner(), p);
+ A o = ap.getDeclaredAnnotation(a,
interfaces[i].inner(), p);
if (o != null)
return o;
}
ClassInfo[] parents = _getParents();
for (int i = parents.length-1; i >= 0; i--) {
- T o = ap.getDeclaredAnnotation(a, parents[i].inner(),
p);
+ A o = ap.getDeclaredAnnotation(a, parents[i].inner(),
p);
if (o != null)
return o;
}
@@ -2108,7 +2104,7 @@ public final class ClassInfo {
if (rt.isArray()) {
ClassInfo rct =
rt.getComponentType();
if
(rct.hasAnnotation(Repeatable.class)) {
- Repeatable r =
rct.getLastAnnotation(Repeatable.class);
+ Repeatable r =
rct.getAnnotation(Repeatable.class);
b = r.value().equals(c);
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConstructorInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConstructorInfo.java
index 48757f2..0712061 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConstructorInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConstructorInfo.java
@@ -92,45 +92,45 @@ public final class ConstructorInfo extends ExecutableInfo
implements Comparable<
/**
* Finds the annotation of the specified type defined on this
constructor.
*
- * @param a The annotation to search for.
+ * @param type The annotation to look for.
* @return The annotation if found, or <jk>null</jk> if not.
*/
- public final <T extends Annotation> T getAnnotation(Class<T> a) {
- return getAnnotation(AnnotationProvider.DEFAULT, a);
+ public final <A extends Annotation> A getAnnotation(Class<A> type) {
+ return getAnnotation(AnnotationProvider.DEFAULT, type);
}
/**
* Finds the annotation of the specified type defined on this
constructor.
*
- * @param ap The annotation provider.
- * @param a The annotation to search for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @return The first annotation found, or <jk>null</jk> if it doesn't
exist.
*/
- public final <T extends Annotation> T getAnnotation(AnnotationProvider
ap, Class<T> a) {
- Value<T> t = Value.empty();
- ap.getAnnotations(a, c, x-> true, x -> t.set(x));
+ public final <A extends Annotation> A getAnnotation(AnnotationProvider
annotationProvider, Class<A> type) {
+ Value<A> t = Value.empty();
+ annotationProvider.getAnnotations(type, c, x -> true, x ->
t.set(x));
return t.orElse(null);
}
/**
* Returns <jk>true</jk> if the specified annotation is present on this
constructor.
*
- * @param a The annotation to check for.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is present on this
constructor.
*/
- public final boolean hasAnnotation(Class<? extends Annotation> a) {
- return hasAnnotation(AnnotationProvider.DEFAULT, a);
+ public final <A extends Annotation> boolean hasAnnotation(Class<A>
type) {
+ return hasAnnotation(AnnotationProvider.DEFAULT, type);
}
/**
* Returns <jk>true</jk> if the specified annotation is present on this
constructor.
*
- * @param ap The annotation provider.
- * @param a The annotation to check for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is present on this
constructor.
*/
- public final boolean hasAnnotation(AnnotationProvider ap, Class<?
extends Annotation> a) {
- return ap.getAnnotation(a, c, x -> true) != null;
+ public final <A extends Annotation> boolean
hasAnnotation(AnnotationProvider annotationProvider, Class<A> type) {
+ return annotationProvider.getAnnotation(type, c, x -> true) !=
null;
}
//-----------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ContextApplyFilter.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ContextApplyFilter.java
deleted file mode 100644
index c50c7b8..0000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ContextApplyFilter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.reflect;
-
-import java.lang.annotation.*;
-import java.util.function.*;
-
-import org.apache.juneau.annotation.*;
-
-/**
- * Filter used to accept only annotations that themselves have the {@link
ContextApply} annotation.
- *
- * <ul class='seealso'>
- * <li class='extlink'>{@source}
- * </ul>
- */
-public class ContextApplyFilter implements Predicate<AnnotationInfo<?>> {
-
- /**
- * Reusable instance.
- */
- public static final ContextApplyFilter INSTANCE = new
ContextApplyFilter();
-
- @Override
- public boolean test(AnnotationInfo<? extends Annotation> t) {
- return t.hasAnnotation(ContextApply.class);
- }
-}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
index f7092f4..d2a9ca4 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ExecutableInfo.java
@@ -41,6 +41,7 @@ public abstract class ExecutableInfo {
private volatile Class<?>[] rawParamTypes;
private volatile Type[] rawGenericParamTypes;
private volatile Parameter[] rawParameters;
+ private volatile Annotation[][] parameterAnnotations;
/**
* Constructor.
@@ -313,24 +314,18 @@ public abstract class ExecutableInfo {
// Annotations
//-----------------------------------------------------------------------------------------------------------------
- /**
- * Returns the parameter annotations on this executable.
- *
- * @return The parameter annotations on this executable.
- */
- public final Annotation[][] getParameterAnnotations() {
- return e.getParameterAnnotations();
+ final Annotation[][] getParameterAnnotations() {
+ if (parameterAnnotations == null) {
+ synchronized(this) {
+ parameterAnnotations =
e.getParameterAnnotations();
+ }
+ }
+ return parameterAnnotations;
}
- /**
- * Returns the parameter annotations on the parameter at the specified
index.
- *
- * @param index The parameter index.
- * @return The parameter annotations on the parameter at the specified
index.
- */
- public final Annotation[] getParameterAnnotations(int index) {
+ final Annotation[] getParameterAnnotations(int index) {
checkIndex(index);
- Annotation[][] x = e.getParameterAnnotations();
+ Annotation[][] x = getParameterAnnotations();
int c = e.getParameterCount();
if (c != x.length) {
// Seems to be a JVM bug where
getParameterAnnotations() don't take mandated parameters into account.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
index 5a10114..d94d38f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
@@ -102,66 +102,66 @@ public final class FieldInfo implements
Comparable<FieldInfo> {
/**
* Returns the specified annotation on this field.
*
- * @param a The annotation to look for.
+ * @param type The annotation to look for.
* @return The annotation, or <jk>null</jk> if not found.
*/
- public <T extends Annotation> T getAnnotation(Class<T> a) {
- return getAnnotation(AnnotationProvider.DEFAULT, a);
+ public <A extends Annotation> A getAnnotation(Class<A> type) {
+ return getAnnotation(AnnotationProvider.DEFAULT, type);
}
/**
* Returns the specified annotation on this field.
*
- * @param ap The annotation provider.
- * @param a The annotation to look for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @return The annotation, or <jk>null</jk> if not found.
*/
- public <T extends Annotation> T getAnnotation(AnnotationProvider ap,
Class<T> a) {
- Value<T> t = Value.empty();
- ap.getAnnotations(a, f, x -> true, x -> t.set(x));
+ public <A extends Annotation> A getAnnotation(AnnotationProvider
annotationProvider, Class<A> type) {
+ Value<A> t = Value.empty();
+ annotationProvider.getAnnotations(type, f, x -> true, x ->
t.set(x));
return t.orElse(null);
}
/**
* Returns <jk>true</jk> if the specified annotation is present.
*
- * @param a The annotation to check for.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is present.
*/
- public boolean hasAnnotation(Class<? extends Annotation> a) {
- return f.isAnnotationPresent(a);
+ public <A extends Annotation> boolean hasAnnotation(Class<A> type) {
+ return f.isAnnotationPresent(type);
}
/**
* Returns <jk>true</jk> if the specified annotation is not present on
this field.
*
- * @param a The annotation to check for.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is not present on
this field.
*/
- public final boolean hasNoAnnotation(Class<? extends Annotation> a) {
- return ! hasAnnotation(a);
+ public final <A extends Annotation> boolean hasNoAnnotation(Class<A>
type) {
+ return ! hasAnnotation(type);
}
/**
* Returns <jk>true</jk> if the specified annotation is present.
*
- * @param ap The annotation provider.
- * @param a The annotation to check for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is present.
*/
- public boolean hasAnnotation(AnnotationProvider ap, Class<? extends
Annotation> a) {
- return ap.getAnnotation(a, f, x -> true) != null;
+ public <A extends Annotation> boolean hasAnnotation(AnnotationProvider
annotationProvider, Class<A> type) {
+ return annotationProvider.getAnnotation(type, f, x -> true) !=
null;
}
/**
* Returns <jk>true</jk> if the specified annotation is not present.
*
- * @param ap The annotation provider.
- * @param a The annotation to check for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is not present.
*/
- public boolean hasNoAnnotation(AnnotationProvider ap, Class<? extends
Annotation> a) {
- return ! hasAnnotation(ap, a);
+ public <A extends Annotation> boolean
hasNoAnnotation(AnnotationProvider annotationProvider, Class<A> type) {
+ return ! hasAnnotation(annotationProvider, type);
}
//-----------------------------------------------------------------------------------------------------------------
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 1a0fe56..353fae1 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
@@ -19,7 +19,6 @@ import java.util.*;
import java.util.function.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.internal.*;
/**
@@ -205,13 +204,11 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
* signature on the parent classes or interfaces.
* <br>The search is performed in child-to-parent order.
*
- * @param a
- * The annotation to search for.
- * @return
- * The annotation if found, or <jk>null</jk> if not.
+ * @param type The annotation to look for.
+ * @return The annotation if found, or <jk>null</jk> if not.
*/
- public final <T extends Annotation> T getLastAnnotation(Class<T> a) {
- return getLastAnnotation(AnnotationProvider.DEFAULT, a);
+ public final <A extends Annotation> A getAnnotation(Class<A> type) {
+ return getAnnotation(AnnotationProvider.DEFAULT, type);
}
/**
@@ -221,16 +218,16 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
* Searches all methods with the same signature on the parent classes
or interfaces
* and the return type on the method.
*
- * @param ap The annotation provider.
- * @param a The annotation to search for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @return The first annotation found, or <jk>null</jk> if it doesn't
exist.
*/
- public final <T extends Annotation> T
getLastAnnotation(AnnotationProvider ap, Class<T> a) {
- if (a == null)
+ public final <A extends Annotation> A getAnnotation(AnnotationProvider
annotationProvider, Class<A> type) {
+ if (type == null)
return null;
- Value<T> t = Value.empty();
+ Value<A> t = Value.empty();
for (Method m2 : _getMatching()) {
- ap.getAnnotations(a, m2, x -> true, x -> t.set(x));
+ annotationProvider.getAnnotations(type, m2, x -> true,
x -> t.set(x));
if (t.isPresent())
return t.get();
}
@@ -240,23 +237,23 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
/**
* Returns <jk>true</jk> if the specified annotation is present on this
method.
*
- * @param a The annotation to check for.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is present on this
method.
*/
- public final boolean hasAnnotation(Class<? extends Annotation> a) {
- return hasAnnotation(AnnotationProvider.DEFAULT, a);
+ public final <A extends Annotation> boolean hasAnnotation(Class<A>
type) {
+ return hasAnnotation(AnnotationProvider.DEFAULT, type);
}
/**
* Returns <jk>true</jk> if the specified annotation is present on this
method.
*
- * @param ap The annotation provider.
- * @param a The annotation to check for.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is present on this
method.
*/
- public final boolean hasAnnotation(AnnotationProvider ap, Class<?
extends Annotation> a) {
+ public final <A extends Annotation> boolean
hasAnnotation(AnnotationProvider annotationProvider, Class<A> type) {
for (Method m2 : _getMatching())
- if (ap.getAnnotation(a, m2, x -> true) != null)
+ if (annotationProvider.getAnnotation(type, m2, x ->
true) != null)
return true;
return false;
}
@@ -264,61 +261,28 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
/**
* Returns <jk>true</jk> if the specified annotation is not present on
this method.
*
- * @param a The annotation to check for.
+ * @param type The annotation to look for.
* @return <jk>true</jk> if the specified annotation is not present on
this method.
*/
- public final boolean hasNoAnnotation(Class<? extends Annotation> a) {
- return getLastAnnotation(a) == null;
+ public final <A extends Annotation> boolean hasNoAnnotation(Class<A>
type) {
+ return getAnnotation(type) == null;
}
/**
* Returns <jk>true</jk> if at least one of the specified annotation is
present on this method.
*
- * @param a The annotation to check for.
+ * @param types The annotation to look for.
* @return <jk>true</jk> if at least one of the specified annotation is
present on this method.
*/
@SafeVarargs
- public final boolean hasAnyAnnotations(Class<? extends Annotation>...a)
{
- for (Class<? extends Annotation> aa : a)
+ public final boolean hasAnyAnnotations(Class<? extends
Annotation>...types) {
+ for (Class<? extends Annotation> aa : types)
if (hasAnnotation(aa))
return true;
return false;
}
/**
- * Returns all annotations of the specified type defined on the
specified method.
- *
- * <p>
- * Searches all methods with the same signature on the parent classes
or interfaces
- * and the return type on the method.
- * <br>Results are parent-to-child ordered.
- *
- * @param a The annotation to search for.
- * @return A list of all matching annotations found or an empty list if
none found.
- */
- public <T extends Annotation> List<T> getAnnotations(Class<T> a) {
- return getAnnotations(AnnotationProvider.DEFAULT, a);
- }
-
- /**
- * Returns all annotations of the specified type defined on the
specified method.
- *
- * <p>
- * Searches all methods with the same signature on the parent classes
or interfaces
- * and the return type on the method.
- * <br>Results are parent-to-child ordered.
- *
- * @param ap The annotation provider.
- * @param a The annotation to search for.
- * @return A list of all matching annotations found or an empty
list if none found.
- */
- public <T extends Annotation> List<T> getAnnotations(AnnotationProvider
ap, Class<T> a) {
- List<T> l = new ArrayList<>();
- getAnnotations(ap, a, x -> true, x -> l.add(x));
- return l;
- }
-
- /**
* Consumes all matching annotations of the specified type defined on
this method.
*
* <p>
@@ -326,13 +290,13 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
* and the return type on the method.
* <br>Results are parent-to-child ordered.
*
- * @param a The annotation to search for.
+ * @param type The annotation to look for.
* @param predicate The predicate.
- * @param consumer The consumer of the annotation.
+ * @param consumer The consumer.
* @return This object.
*/
- public <T extends Annotation> MethodInfo getAnnotations(Class<T> a,
Predicate<T> predicate, Consumer<T> consumer) {
- return getAnnotations(AnnotationProvider.DEFAULT, a, predicate,
consumer);
+ public <A extends Annotation> MethodInfo getAnnotations(Class<A> type,
Predicate<A> predicate, Consumer<A> consumer) {
+ return getAnnotations(AnnotationProvider.DEFAULT, type,
predicate, consumer);
}
/**
@@ -343,33 +307,33 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
* and the return type on the method.
* <br>Results are parent-to-child ordered.
*
- * @param ap The annotation provider.
- * @param a The annotation.
+ * @param annotationProvider The annotation provider.
+ * @param type The annotation type.
* @param predicate The predicate.
* @param consumer The consumer.
* @return This object.
*/
@SuppressWarnings("unchecked")
- public <T extends Annotation> MethodInfo
getAnnotations(AnnotationProvider ap, Class<T> a, Predicate<T> predicate,
Consumer<T> consumer) {
- declaringClass.getAnnotations(ap, a, predicate, consumer);
+ public <A extends Annotation> MethodInfo
getAnnotations(AnnotationProvider annotationProvider, Class<A> type,
Predicate<A> predicate, Consumer<A> consumer) {
+ declaringClass.getAnnotations(annotationProvider, type,
predicate, consumer);
for (Method m2 : getMatchingParentFirst())
for (Annotation a2 : m2.getDeclaredAnnotations())
- if (a.isInstance(a2) && predicate.test((T)a2))
- consumer.accept((T)a2);
-
getReturnType().unwrap(Value.class,Optional.class).getAnnotations(ap, a,
predicate, consumer);
+ if (type.isInstance(a2) &&
predicate.test((A)a2))
+ consumer.accept((A)a2);
+
getReturnType().unwrap(Value.class,Optional.class).getAnnotations(annotationProvider,
type, predicate, consumer);
return this;
}
/**
* Returns the first annotation in the specified list on this method.
*
- * @param c The annotations that cannot be present on the method.
- * @return <jk>true</jk> if this method does not have any of the
specified annotations.
+ * @param types The annotations to look for.
+ * @return The first matching annotation.
*/
@SafeVarargs
- public final Annotation getAnyLastAnnotation(Class<? extends
Annotation>...c) {
- for (Class<? extends Annotation> cc : c) {
- Annotation a = getLastAnnotation(cc);
+ public final Annotation getAnyAnnotation(Class<? extends
Annotation>...types) {
+ for (Class<? extends Annotation> cc : types) {
+ Annotation a = getAnnotation(cc);
if (a != null)
return a;
}
@@ -408,45 +372,28 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
* <li>On this method and matching methods ordered parent-to-child.
* </ol>
*
- * @param filter
- * Optional filter to apply to limit which annotations are added
to the list.
- * <br>Can be <jk>null</jk> for no filtering.
+ * @param predicate The predicate.
* @return A new {@link AnnotationList} object on every call.
*/
- public AnnotationList getAnnotationList(Predicate<AnnotationInfo<?>>
filter) {
+ public AnnotationList getAnnotationList(Predicate<AnnotationInfo<?>>
predicate) {
AnnotationList al = new AnnotationList();
- getAnnotationInfos(filter, x -> al.add(x));
+ getAnnotationInfos(predicate, x -> al.add(x));
return al;
}
/**
* Same as {@link #getAnnotationList(Predicate)} except only returns
annotations defined on methods.
*
- * @param filter
- * Optional filter to apply to limit which annotations are added
to the list.
- * <br>Can be <jk>null</jk> for no filtering.
+ * @param predicate The predicate.
* @return A new {@link AnnotationList} object on every call.
*/
- public AnnotationList
getAnnotationListMethodOnly(Predicate<AnnotationInfo<?>> filter) {
+ public AnnotationList
getAnnotationListMethodOnly(Predicate<AnnotationInfo<?>> predicate) {
AnnotationList al = new AnnotationList();
- getAnnotationInfosMethodOnly(filter, x -> al.add(x));
+ getAnnotationInfosMethodOnly(predicate, x -> al.add(x));
return al;
}
/**
- * Returns <jk>true</jk> if this method or parent methods have any
annotations annotated with {@link ContextApply}.
- *
- * @return <jk>true</jk> if this method or parent methods have any
annotations annotated with {@link ContextApply}.
- */
- public boolean hasApplyAnnotations() {
- for (Method m2 : getMatching())
- for (Annotation a2 : m2.getAnnotations())
- if
(a2.annotationType().getAnnotation(ContextApply.class) != null)
- return true;
- return false;
- }
-
- /**
* Consumes the annotations that match the specified predicate on this
method.
*
* @param predicate The predicate.
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 205462b..eee8b3b 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
@@ -93,29 +93,36 @@ public final class ParamInfo {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Returns the parameter annotations declared on this parameter.
+ * Consumers the matching parameter annotations declared on this
parameter.
*
- * @return The parameter annotations declared on this parameter, or an
empty array if none found.
+ * @param type The annotation type.
+ * @param predicate The predicate.
+ * @param consumer The consumer.
+ * @return This object.
*/
- public Annotation[] getDeclaredAnnotations() {
- return eInfo.getParameterAnnotations(index);
+ @SuppressWarnings("unchecked")
+ public <A extends Annotation> ParamInfo getDeclaredAnnotations(Class<A>
type, Predicate<A> predicate, Consumer<A> consumer) {
+ for (Annotation a : eInfo.getParameterAnnotations(index))
+ if (type.isInstance(a) && predicate.test((A)a))
+ consumer.accept((A)a);
+ return this;
}
/**
* Returns the specified parameter annotation declared on this
parameter.
*
- * @param a
- * The annotation to search for.
- * @param <T>
+ * @param type
+ * The annotation to look for.
+ * @param <A>
* The annotation type.
* @return The specified parameter annotation declared on this
parameter, or <jk>null</jk> if not found.
*/
@SuppressWarnings("unchecked")
- public <T extends Annotation> T getDeclaredAnnotation(Class<T> a) {
- if (a != null)
+ public <A extends Annotation> A getDeclaredAnnotation(Class<A> type) {
+ if (type != null)
for (Annotation aa :
eInfo.getParameterAnnotations(index))
- if (a.isInstance(aa))
- return (T)aa;
+ if (type.isInstance(aa))
+ return (A)aa;
return null;
}
@@ -130,31 +137,31 @@ public final class ParamInfo {
* <p>
* If still not found, searches for the annotation on the return type
of the method.
*
- * @param a
- * The annotation to search for.
+ * @param type
+ * The annotation to look for.
* @return
* The annotation if found, or <jk>null</jk> if not.
*/
@SuppressWarnings("unchecked")
- public <T extends Annotation> T getLastAnnotation(Class<T> a) {
- Optional<Annotation> o = annotationMap().get(a);
+ public <A extends Annotation> A getAnnotation(Class<A> type) {
+ Optional<Annotation> o = annotationMap().get(type);
if (o == null) {
- o = Optional.ofNullable(findAnnotation(a));
- annotationMap().put(a, o);
+ o = Optional.ofNullable(findAnnotation(type));
+ annotationMap().put(type, o);
}
- return o.isPresent() ? (T)o.get() : null;
+ return o.isPresent() ? (A)o.get() : null;
}
/**
* Returns <jk>true</jk> if this parameter has the specified annotation.
*
- * @param a
- * The annotation to search for.
+ * @param type
+ * The annotation to look for.
* @return
* The <jk>true</jk> if annotation if found.
*/
- public boolean hasAnnotation(Class<? extends Annotation> a) {
- return getLastAnnotation(a) != null;
+ public <A extends Annotation> boolean hasAnnotation(Class<A> type) {
+ return getAnnotation(type) != null;
}
@SuppressWarnings("unchecked")
@@ -163,32 +170,14 @@ public final class ParamInfo {
for (Annotation a2 :
eInfo.getParameterAnnotations(index))
if (a.isInstance(a2))
return (T)a2;
- return
eInfo.getParamType(index).unwrap(Value.class,Optional.class).getLastAnnotation(a);
+ return
eInfo.getParamType(index).unwrap(Value.class,Optional.class).getAnnotation(a);
}
MethodInfo mi = (MethodInfo)eInfo;
for (Method m2 : mi.getMatching())
for (Annotation a2 :
m2.getParameterAnnotations()[index])
if (a.isInstance(a2))
return (T)a2;
- return
eInfo.getParamType(index).unwrap(Value.class,Optional.class).getLastAnnotation(a);
- }
-
- /**
- * Returns all annotations of the specified type defined on this method
parameter.
- *
- * <p>
- * Searches all methods with the same signature on the parent classes
or interfaces
- * and the return type on the method.
- * <p>
- * Results are in parent-to-child order.
- *
- * @param a The annotation to search for.
- * @return A list of all matching annotations found or an empty list if
none found.
- */
- public <T extends Annotation> List<T> getAnnotations(Class<T> a) {
- List<T> l = new ArrayList<>();
- getAnnotations(AnnotationProvider.DEFAULT, a, true, x -> true,
x -> l.add(x));
- return l;
+ return
eInfo.getParamType(index).unwrap(Value.class,Optional.class).getAnnotation(a);
}
/**
@@ -200,13 +189,13 @@ public final class ParamInfo {
* <p>
* Results are in parent-to-child order.
*
- * @param a The annotation to search for.
+ * @param type The annotation to look for.
* @param predicate The predicate.
- * @param consumer The consumer for the annotations.
+ * @param consumer The consumer.
* @return This object.
*/
- public <T extends Annotation> ParamInfo getAnnotations(Class<T> a,
Predicate<T> predicate, Consumer<T> consumer) {
- return getAnnotations(AnnotationProvider.DEFAULT, a, true,
predicate, consumer);
+ public <A extends Annotation> ParamInfo getAnnotations(Class<A> type,
Predicate<A> predicate, Consumer<A> consumer) {
+ return getAnnotations(AnnotationProvider.DEFAULT, type, true,
predicate, consumer);
}
/**
@@ -218,33 +207,28 @@ public final class ParamInfo {
* <p>
* Results are in parent-to-child order.
*
- * @param a The annotation to search for.
- * @param predicate The consumer for the annotations.
+ * @param type The annotation to look for.
+ * @param predicate The predicate.
* @return A list of all matching annotations found or an empty list if
none found.
*/
- public <T extends Annotation> T getAnnotation(Class<T> a, Predicate<T>
predicate) {
- return getAnnotation(a, true, predicate);
+ public <A extends Annotation> A getAnnotation(Class<A> type,
Predicate<A> predicate) {
+ return getAnnotation(type, true, predicate);
}
-// private <T extends Annotation> List<T> appendAnnotations(List<T> l,
Class<T> a, boolean parentFirst) {
-// getAnnotations(AnnotationProvider.DEFAULT, a, parentFirst, x ->
true, x -> l.add(x));
-// return l;
-// }
-
@SuppressWarnings("unchecked")
- private <T extends Annotation> ParamInfo
getAnnotations(AnnotationProvider ap, Class<T> a, boolean parentFirst,
Predicate<T> predicate, Consumer<T> consumer) {
+ private <A extends Annotation> ParamInfo
getAnnotations(AnnotationProvider ap, Class<A> a, boolean parentFirst,
Predicate<A> predicate, Consumer<A> consumer) {
if (eInfo.isConstructor) {
ClassInfo ci =
eInfo.getParamType(index).unwrap(Value.class,Optional.class);
Annotation[] annotations =
eInfo.getParameterAnnotations(index);
if (parentFirst) {
ci.getAnnotations(ap, a, predicate, consumer);
for (Annotation a2 : annotations)
- if (a.isInstance(a2) &&
predicate.test((T)a2))
- consumer.accept((T)a2);
+ if (a.isInstance(a2) &&
predicate.test((A)a2))
+ consumer.accept((A)a2);
} else {
for (Annotation a2 : annotations)
- if (a.isInstance(a2) &&
predicate.test((T)a2))
- consumer.accept((T)a2);
+ if (a.isInstance(a2) &&
predicate.test((A)a2))
+ consumer.accept((A)a2);
ci.getAnnotations(ap, a, predicate, consumer);
}
} else {
@@ -254,13 +238,13 @@ public final class ParamInfo {
ci.getAnnotations(ap, a, predicate, consumer);
for (Method m2 : mi.getMatchingParentFirst())
for (Annotation a2 :
m2.getParameterAnnotations()[index])
- if (a.isInstance(a2) &&
predicate.test((T)a2))
- consumer.accept((T)a2);
+ if (a.isInstance(a2) &&
predicate.test((A)a2))
+ consumer.accept((A)a2);
} else {
for (Method m2 : mi.getMatching())
for (Annotation a2 :
m2.getParameterAnnotations()[index])
- if (a.isInstance(a2) &&
predicate.test((T)a2))
- consumer.accept((T)a2);
+ if (a.isInstance(a2) &&
predicate.test((A)a2))
+ consumer.accept((A)a2);
ci.getAnnotations(ap, a, predicate, consumer);
}
}
@@ -268,22 +252,22 @@ public final class ParamInfo {
}
@SuppressWarnings("unchecked")
- private <T extends Annotation> T getAnnotation(Class<T> a, boolean
parentFirst, Predicate<T> predicate) {
+ private <A extends Annotation> A getAnnotation(Class<A> a, boolean
parentFirst, Predicate<A> predicate) {
if (eInfo.isConstructor) {
ClassInfo ci =
eInfo.getParamType(index).unwrap(Value.class,Optional.class);
Annotation[] annotations =
eInfo.getParameterAnnotations(index);
if (parentFirst) {
- T o = ci.getAnnotation(a, predicate);
+ A o = ci.getAnnotation(a, predicate);
if (o != null)
return o;
for (Annotation a2 : annotations)
- if (a.isInstance(a2) &&
predicate.test((T)a2))
- return (T)a2;
+ if (a.isInstance(a2) &&
predicate.test((A)a2))
+ return (A)a2;
} else {
for (Annotation a2 : annotations)
- if (a.isInstance(a2) &&
predicate.test((T)a2))
- return (T)a2;
- T o = ci.getAnnotation(a, predicate);
+ if (a.isInstance(a2) &&
predicate.test((A)a2))
+ return (A)a2;
+ A o = ci.getAnnotation(a, predicate);
if (o != null)
return o;
}
@@ -291,19 +275,19 @@ public final class ParamInfo {
MethodInfo mi = (MethodInfo)eInfo;
ClassInfo ci =
eInfo.getParamType(index).unwrap(Value.class,Optional.class);
if (parentFirst) {
- T o = ci.getAnnotation(a, predicate);
+ A o = ci.getAnnotation(a, predicate);
if (o != null)
return o;
for (Method m2 : mi.getMatchingParentFirst())
for (Annotation a2 :
m2.getParameterAnnotations()[index])
- if (a.isInstance(a2) &&
predicate.test((T)a2))
- return (T)a2;
+ if (a.isInstance(a2) &&
predicate.test((A)a2))
+ return (A)a2;
} else {
for (Method m2 : mi.getMatching())
for (Annotation a2 :
m2.getParameterAnnotations()[index])
- if (a.isInstance(a2) &&
predicate.test((T)a2))
- return (T)a2;
- T o = ci.getAnnotation(a, predicate);
+ if (a.isInstance(a2) &&
predicate.test((A)a2))
+ return (A)a2;
+ A o = ci.getAnnotation(a, predicate);
if (o != null)
return o;
}
@@ -312,8 +296,11 @@ public final class ParamInfo {
}
private synchronized Map<Class<?>,Optional<Annotation>> annotationMap()
{
- if (annotationMap == null)
- annotationMap = new ConcurrentHashMap<>();
+ if (annotationMap == null) {
+ synchronized(this) {
+ annotationMap = new ConcurrentHashMap<>();
+ }
+ }
return annotationMap;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ReflectionFilters.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ReflectionFilters.java
deleted file mode 100644
index e0cfb5f..0000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ReflectionFilters.java
+++ /dev/null
@@ -1,98 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.reflect;
-
-import java.util.function.*;
-
-import org.apache.juneau.*;
-
-/**
- * Predefined predicates for filtering out executable methods/constructors.
- *
- * <ul class='seealso'>
- * <li class='extlink'>{@source}
- * </ul>
- */
-public class ReflectionFilters {
-
- /**
- * Predicate for testing that a method or constructor has the exact
specified args.
- *
- * @param args The args to test.
- * @return A new predicate.
- */
- public static <T extends ExecutableInfo> Predicate<T>
hasArgs(Class<?>...args) {
- return new Predicate<T>() {
- @Override
- public boolean test(T t) {
- Class<?>[] pt = t._getRawParamTypes();
- if (pt.length == args.length) {
- for (int i = 0; i < pt.length; i++)
- if (! pt[i].equals(args[i]))
- return false;
- return true;
- }
- return false;
- }
- };
- }
-
- /**
- * Predicate for testing that a method or constructor has arguments
that will take all of the specified
- * arguments.
- *
- * <p>
- * Unlike {@link #hasArgs(Class...)}, this allows for matching based on
parent classes.
- *
- * @param args The args to test.
- * @return A new predicate.
- */
- public static <T extends ExecutableInfo> Predicate<T>
hasParentArgs(Object...args) {
- return new Predicate<T>() {
- @Override
- public boolean test(T t) {
- ClassInfo[] pt = t._getParamTypes();
- if (pt.length != args.length)
- return false;
- for (int i = 0; i < pt.length; i++) {
- boolean matched = false;
- for (int j = 0; j < args.length; j++)
- if
(pt[i].isParentOfFuzzyPrimitives(args[j].getClass()))
- matched = true;
- if (! matched)
- return false;
- }
- return true;
- }
- };
- }
-
- /**
- * Predicate for testing that a method or constructor has the minimum
specified visibility.
- * arguments.
- *
- * <p>
- * Unlike {@link #hasArgs(Class...)}, this allows for matching based on
parent classes.
- *
- * @param value The minimum visibility for the method or constructor.
- * @return A new predicate.
- */
- public static <T extends ExecutableInfo> Predicate<T>
isVisible(Visibility value) {
- return new Predicate<T>() {
- @Override
- public boolean test(T t) {
- return t.isVisible(value);
- }
- };
- }
-}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index fdb8704..3244463 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -352,7 +352,7 @@ public class RestContext extends Context {
ClassInfo rci = ClassInfo.of(resourceClass);
VarResolverSession vrs =
varResolver().build().createSession();
- AnnotationWorkList work = AnnotationWorkList.of(vrs,
rci.getAnnotationList(ContextApplyFilter.INSTANCE));
+ AnnotationWorkList work = AnnotationWorkList.of(vrs,
rci.getAnnotationList(CONTEXT_APPLY_FILTER));
apply(work);
beanContext().apply(work);
@@ -371,7 +371,7 @@ public class RestContext extends Context {
Map<String,MethodInfo> map = new LinkedHashMap<>();
ClassInfo.ofProxy(r).getAllMethodsParentFirst(
- y -> y.hasAnnotation(RestHook.class) &&
y.getLastAnnotation(RestHook.class).value() == HookEvent.INIT,
+ y -> y.hasAnnotation(RestHook.class) &&
y.getAnnotation(RestHook.class).value() == HookEvent.INIT,
y -> {
String sig = y.getSignature();
if (! map.containsKey(sig))
@@ -5752,11 +5752,7 @@ public class RestContext extends Context {
ClassInfo.ofProxy(r).getAllMethodsParentFirst(
y -> y.hasAnnotation(RestHook.class),
- y -> {
- for (RestHook h :
y.getAnnotations(RestHook.class))
- if (h.value() == event)
- x.put(y.getSignature(),
y.accessible().inner());
- }
+ y -> y.getAnnotations(RestHook.class, z ->
z.value() == event, z -> x.put(y.getSignature(), y.accessible().inner()))
);
MethodList x2 = MethodList.of(x.values());
@@ -6952,7 +6948,7 @@ public class RestContext extends Context {
int code = 500;
ClassInfo ci = ClassInfo.of(e);
- StatusCode r = ci.getLastAnnotation(StatusCode.class);
+ StatusCode r = ci.getAnnotation(StatusCode.class);
if (r != null)
if (r.value().length > 0)
code = r.value()[0];
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
index 50fb923..3f0f4c1 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
@@ -184,7 +184,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
VarResolver vr = context.getVarResolver();
VarResolverSession vrs = vr.createSession();
- AnnotationWorkList work =
AnnotationWorkList.of(vrs, mi.getAnnotationList(ContextApplyFilter.INSTANCE));
+ AnnotationWorkList work =
AnnotationWorkList.of(vrs, mi.getAnnotationList(CONTEXT_APPLY_FILTER));
apply(work);
@@ -1222,8 +1222,11 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
httpMethod = "post";
else if (mi.hasAnnotation(RestDelete.class))
httpMethod = "delete";
- else if (mi.hasAnnotation(RestOp.class))
- httpMethod =
mi.getAnnotations(RestOp.class).stream().map(y -> y.method()).filter(y -> !
y.isEmpty()).findFirst().orElse(null);
+ else if (mi.hasAnnotation(RestOp.class)) {
+ Value<String> _httpMethod =
Value.empty();
+ mi.getAnnotations(RestOp.class, x ->
isNotEmpty(x.method()), x -> _httpMethod.set(x.method()));
+ httpMethod = _httpMethod.orElse(null);
+ }
p = HttpUtils.detectHttpPath(restMethod,
httpMethod);
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HasFormDataArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HasFormDataArg.java
index 1badc97..7f5a663 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HasFormDataArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HasFormDataArg.java
@@ -12,10 +12,9 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest.arg;
-import static org.apache.juneau.http.annotation.HasFormDataAnnotation.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.lang.reflect.*;
-
import org.apache.juneau.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.reflect.*;
@@ -66,10 +65,20 @@ public class HasFormDataArg implements RestOpArg {
* @param pi The Java method parameter being resolved.
*/
protected HasFormDataArg(ParamInfo pi) {
- this.name =
findName(pi.getAnnotations(HasFormData.class)).orElseThrow(() -> new
ArgException(pi, "@HasFormData used without name or value"));
+ Value<String> _name = Value.empty();
+ pi.getAnnotations(HasFormData.class, x -> hasName(x), x ->
_name.set(getName(x)));
+ this.name = _name.orElseThrow(() -> new ArgException(pi,
"@HasFormData used without name or value"));
this.type = pi.getParameterType().innerType();
}
+ private static boolean hasName(HasFormData x) {
+ return isNotEmpty(x.name()) || isNotEmpty(x.value());
+ }
+
+ private static String getName(HasFormData x) {
+ return firstNonEmpty(x.name(), x.value());
+ }
+
@Override /* RestOpArg */
public Object resolve(RestOpSession opSession) throws Exception {
RestRequest req = opSession.getRequest();
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HasQueryArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HasQueryArg.java
index b0a02e8..1f5095b 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HasQueryArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HasQueryArg.java
@@ -12,7 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest.arg;
-import static org.apache.juneau.http.annotation.HasQueryAnnotation.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.lang.reflect.*;
@@ -66,10 +66,20 @@ public class HasQueryArg implements RestOpArg {
* @param pi The Java method parameter being resolved.
*/
protected HasQueryArg(ParamInfo pi) {
- this.name =
findName(pi.getAnnotations(HasQuery.class)).orElseThrow(() -> new
ArgException(pi, "@HasQuery used without name or value"));
+ Value<String> _name = Value.empty();
+ pi.getAnnotations(HasQuery.class, x -> hasName(x), x ->
_name.set(getName(x)));
+ this.name = _name.orElseThrow(() -> new ArgException(pi,
"@HasQuery used without name or value"));
this.type = pi.getParameterType().innerType();
}
+ private static boolean hasName(HasQuery x) {
+ return isNotEmpty(x.name()) || isNotEmpty(x.value());
+ }
+
+ private static String getName(HasQuery x) {
+ return firstNonEmpty(x.name(), x.value());
+ }
+
@Override /* RestOpArg */
public Object resolve(RestOpSession opSession) throws Exception {
RestRequest req = opSession.getRequest();
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathArg.java
index 042b186..746d2ec 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathArg.java
@@ -93,7 +93,7 @@ public class PathArg implements RestOpArg {
MethodInfo mi = pi.getMethod();
for (int j = 0; j < i; j++)
- if
(mi.getParam(i).getLastAnnotation(Path.class) != null)
+ if (mi.getParam(i).getAnnotation(Path.class) !=
null)
idx++;
String[] vars = pathMatcher.getVars();
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 680f944..077545d 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
@@ -394,9 +394,9 @@ public class BasicSwaggerProviderSession {
List<MethodInfo> methods =
eci.getMethods();
for (int i = methods.size()-1; i>=0;
i--) {
MethodInfo ecmi =
methods.get(i);
- Header a =
ecmi.getLastAnnotation(Header.class);
+ Header a =
ecmi.getAnnotation(Header.class);
if (a == null)
- a =
ecmi.getReturnType().unwrap(Value.class,Optional.class).getLastAnnotation(Header.class);
+ a =
ecmi.getReturnType().unwrap(Value.class,Optional.class).getAnnotation(Header.class);
if (a != null && ! isMulti(a)) {
String ha = a.name();
for (Integer code :
codes) {
@@ -411,8 +411,10 @@ public class BasicSwaggerProviderSession {
}
if (mi.hasAnnotation(Response.class) ||
mi.getReturnType().unwrap(Value.class,Optional.class).hasAnnotation(Response.class))
{
- List<Response> la = mi.getAnnotations(context,
Response.class);
- List<StatusCode> la2 =
mi.getAnnotations(context, StatusCode.class);
+ List<Response> la = new ArrayList<>();
+ mi.getAnnotations(context, Response.class, x ->
true, x -> la.add(x));
+ List<StatusCode> la2 = new ArrayList<>();
+ mi.getAnnotations(context, StatusCode.class, x
-> true, x -> la2.add(x));
Set<Integer> codes = getCodes(la2, 200);
for (Response a : la) {
for (Integer code : codes) {
@@ -430,7 +432,7 @@ public class BasicSwaggerProviderSession {
for (int i = methods.size()-1; i>=0;
i--) {
MethodInfo ecmi =
methods.get(i);
if
(ecmi.hasAnnotation(Header.class)) {
- Header a =
ecmi.getLastAnnotation(Header.class);
+ Header a =
ecmi.getAnnotation(Header.class);
String ha = a.name();
if (! isMulti(a)) {
for (Integer
code : codes) {
@@ -460,8 +462,12 @@ public class BasicSwaggerProviderSession {
ClassInfo pt = mpi.getParameterType();
if (pt.is(Value.class) &&
(mpi.hasAnnotation(Header.class) || pt.hasAnnotation(Header.class))) {
- List<Header> la =
AList.of(mpi.getAnnotations(Header.class)).a(pt.getAnnotations(Header.class));
- List<StatusCode> la2 =
AList.of(mpi.getAnnotations(StatusCode.class)).a(pt.getAnnotations(StatusCode.class));
+ List<Header> la = new ArrayList<>();
+ mpi.getAnnotations(Header.class, x ->
true, x -> la.add(x));
+ pt.getAnnotations(Header.class, x ->
true, x -> la.add(x));
+ List<StatusCode> la2 = new
ArrayList<>();
+ mpi.getAnnotations(StatusCode.class, x
-> true, x -> la2.add(x));
+ pt.getAnnotations(StatusCode.class, x
-> true, x -> la2.add(x));
Set<Integer> codes = getCodes(la2, 200);
String name =
HeaderAnnotation.findName(mpi).orElse(null);
Type type =
Value.unwrap(mpi.getParameterType().innerType());
@@ -477,8 +483,12 @@ public class BasicSwaggerProviderSession {
}
} else if (mpi.hasAnnotation(Response.class) ||
pt.hasAnnotation(Response.class)) {
- List<Response> la =
AList.of(mpi.getAnnotations(Response.class)).a(pt.getAnnotations(Response.class));
- List<StatusCode> la2 =
AList.of(mpi.getAnnotations(StatusCode.class)).a(pt.getAnnotations(StatusCode.class));
+ List<Response> la = new ArrayList<>();
+ mpi.getAnnotations(Response.class, x ->
true, x -> la.add(x));
+ pt.getAnnotations(Response.class, x ->
true, x -> la.add(x));
+ List<StatusCode> la2 = new
ArrayList<>();
+ mpi.getAnnotations(StatusCode.class, x
-> true, x -> la2.add(x));
+ pt.getAnnotations(StatusCode.class, x
-> true, x -> la2.add(x));
Set<Integer> codes = getCodes(la2, 200);
Type type =
Value.unwrap(mpi.getParameterType().innerType());
for (Response a : la) {
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/AClass.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/AClass.java
similarity index 97%
rename from juneau-utest/src/test/java/org/apache/juneau/reflection/AClass.java
rename to juneau-utest/src/test/java/org/apache/juneau/reflect/AClass.java
index cf9abcc..618401e 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflection/AClass.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/AClass.java
@@ -10,6 +10,6 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
public class AClass {}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/AInterface.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/AInterface.java
similarity index 97%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/AInterface.java
rename to juneau-utest/src/test/java/org/apache/juneau/reflect/AInterface.java
index 5c77c2f..bc37354 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflection/AInterface.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/AInterface.java
@@ -10,6 +10,6 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
public interface AInterface {}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/AnnotationInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/AnnotationInfoTest.java
similarity index 97%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/AnnotationInfoTest.java
rename to
juneau-utest/src/test/java/org/apache/juneau/reflect/AnnotationInfoTest.java
index cfacdc1..d5c6607 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/reflection/AnnotationInfoTest.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/reflect/AnnotationInfoTest.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
@@ -20,7 +20,6 @@ import static org.apache.juneau.assertions.Assertions.*;
import org.apache.juneau.annotation.*;
import java.lang.annotation.*;
-import org.apache.juneau.reflect.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ClassInfoTest.java
similarity index 96%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
rename to
juneau-utest/src/test/java/org/apache/juneau/reflect/ClassInfoTest.java
index d30fe0f..42d2d41 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/ClassInfoTest.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
@@ -19,6 +19,7 @@ import static org.apache.juneau.reflect.ClassInfo.*;
import static org.apache.juneau.reflect.ReflectFlags.*;
import static org.junit.Assert.*;
import static org.junit.runners.MethodSorters.*;
+import static org.apache.juneau.Context.*;
import java.io.*;
import java.lang.annotation.*;
@@ -30,8 +31,7 @@ import java.util.stream.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.*;
-import org.apache.juneau.reflect.*;
-import org.apache.juneau.reflection.MethodInfoTest.*;
+import org.apache.juneau.reflect.MethodInfoTest.*;
import org.apache.juneau.svl.*;
import org.junit.*;
@@ -592,29 +592,29 @@ public class ClassInfoTest {
@Test
public void getAnnotation() {
- check("@A(7)", g3.getLastAnnotation(A.class));
- check(null, g3.getLastAnnotation(B.class));
- check(null, g3.getLastAnnotation(null));
+ check("@A(7)", g3.getAnnotation(A.class));
+ check(null, g3.getAnnotation(B.class));
+ check(null, g3.getAnnotation(null));
}
@Test
public void getAnnotation_twice() {
- check("@A(7)", g3.getLastAnnotation(A.class));
- check("@A(7)", g3.getLastAnnotation(A.class));
+ check("@A(7)", g3.getAnnotation(A.class));
+ check("@A(7)", g3.getAnnotation(A.class));
}
@Test
public void getAnnotation_onParent() {
- check("@A(7)", g4.getLastAnnotation(A.class));
- check(null, g4.getLastAnnotation(B.class));
- check(null, g4.getLastAnnotation(null));
+ check("@A(7)", g4.getAnnotation(A.class));
+ check(null, g4.getAnnotation(B.class));
+ check(null, g4.getAnnotation(null));
}
@Test
public void getAnnotation_onInterface() {
- check("@A(3)", g5.getLastAnnotation(A.class));
- check(null, g5.getLastAnnotation(B.class));
- check(null, g5.getLastAnnotation(null));
+ check("@A(3)", g5.getAnnotation(A.class));
+ check(null, g5.getAnnotation(B.class));
+ check(null, g5.getAnnotation(null));
}
@Test
@@ -664,9 +664,9 @@ public class ClassInfoTest {
@Test
public void getConfigAnnotationsMapParentFirst() {
-
check("@AConfig(2),@AConfig(1),@AConfig(3),@AConfig(5),@AConfig(6),@AConfig(7)",
gb3.getAnnotationList(ContextApplyFilter.INSTANCE));
-
check("@AConfig(2),@AConfig(1),@AConfig(3),@AConfig(5),@AConfig(6),@AConfig(7)",
gb4.getAnnotationList(ContextApplyFilter.INSTANCE));
- check("@AConfig(3)",
gb5.getAnnotationList(ContextApplyFilter.INSTANCE));
+
check("@AConfig(2),@AConfig(1),@AConfig(3),@AConfig(5),@AConfig(6),@AConfig(7)",
gb3.getAnnotationList(CONTEXT_APPLY_FILTER));
+
check("@AConfig(2),@AConfig(1),@AConfig(3),@AConfig(5),@AConfig(6),@AConfig(7)",
gb4.getAnnotationList(CONTEXT_APPLY_FILTER));
+ check("@AConfig(3)",
gb5.getAnnotationList(CONTEXT_APPLY_FILTER));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -1248,7 +1248,7 @@ public class ClassInfoTest {
@Test
public void getWrapperIfPrimitive_onType() {
- assertEquals("class
org.apache.juneau.reflection.ClassInfoTest$A1",
aTypeInfo.getWrapperIfPrimitive().toString());
+ assertEquals("class
org.apache.juneau.reflect.ClassInfoTest$A1",
aTypeInfo.getWrapperIfPrimitive().toString());
assertEquals("interface java.util.Map",
pTypeInfo.getWrapperIfPrimitive().toString());
assertEquals("interface java.util.Map",
pTypeDimensionalInfo.getWrapperIfPrimitive().toString());
assertEquals("class java.util.AbstractMap",
pTypeGenericInfo.getWrapperIfPrimitive().toString());
@@ -1291,30 +1291,30 @@ public class ClassInfoTest {
@Test
public void getFullName_simple() {
- assertEquals("org.apache.juneau.reflection.AClass",
aClass.getFullName());
+ assertEquals("org.apache.juneau.reflect.AClass",
aClass.getFullName());
}
@Test
public void getFullName_simpleTwice() {
- assertEquals("org.apache.juneau.reflection.AClass",
aClass.getFullName());
- assertEquals("org.apache.juneau.reflection.AClass",
aClass.getFullName());
+ assertEquals("org.apache.juneau.reflect.AClass",
aClass.getFullName());
+ assertEquals("org.apache.juneau.reflect.AClass",
aClass.getFullName());
}
@Test
public void getFullName_simpleArray() {
- assertEquals("org.apache.juneau.reflection.AClass[][]",
of(AClass[][].class).getFullName());
+ assertEquals("org.apache.juneau.reflect.AClass[][]",
of(AClass[][].class).getFullName());
}
@Test
public void getFullName_inner() {
- assertEquals("org.apache.juneau.reflection.ClassInfoTest$J1",
j1.getFullName());
- assertEquals("org.apache.juneau.reflection.ClassInfoTest$J2",
j2.getFullName());
+ assertEquals("org.apache.juneau.reflect.ClassInfoTest$J1",
j1.getFullName());
+ assertEquals("org.apache.juneau.reflect.ClassInfoTest$J2",
j2.getFullName());
}
@Test
public void getFullName_innerArray() {
-
assertEquals("org.apache.juneau.reflection.ClassInfoTest$J1[][]",
j1_3d.getFullName());
-
assertEquals("org.apache.juneau.reflection.ClassInfoTest$J2[][]",
j2_3d.getFullName());
+ assertEquals("org.apache.juneau.reflect.ClassInfoTest$J1[][]",
j1_3d.getFullName());
+ assertEquals("org.apache.juneau.reflect.ClassInfoTest$J2[][]",
j2_3d.getFullName());
}
@Test
@@ -1329,7 +1329,7 @@ public class ClassInfoTest {
@Test
public void getFullName_simpleType() {
- assertEquals("org.apache.juneau.reflection.ClassInfoTest$A1",
aTypeInfo.getFullName());
+ assertEquals("org.apache.juneau.reflect.ClassInfoTest$A1",
aTypeInfo.getFullName());
}
@Test
@@ -1356,7 +1356,7 @@ public class ClassInfoTest {
public void getFullName_localClass() {
@SuppressWarnings("serial")
class LocalClass implements Serializable {};
-
assertEquals("org.apache.juneau.reflection.ClassInfoTest$1LocalClass",
of(LocalClass.class).getFullName());
+
assertEquals("org.apache.juneau.reflect.ClassInfoTest$1LocalClass",
of(LocalClass.class).getFullName());
}
@Test
@@ -1502,7 +1502,7 @@ public class ClassInfoTest {
@Test
public void getName() {
- assertEquals("org.apache.juneau.reflection.AClass",
aClass.getName());
+ assertEquals("org.apache.juneau.reflect.AClass",
aClass.getName());
assertEquals("java.util.AbstractMap",
pTypeGenericInfo.getName());
assertEquals("V", pTypeGenericArgInfo.getName());
}
@@ -1691,12 +1691,12 @@ public class ClassInfoTest {
@Test
public void getPackage() {
- check("org.apache.juneau.reflection",
ka.getPackage().getName());
+ check("org.apache.juneau.reflect", ka.getPackage().getName());
}
@Test
public void getPackage_type() {
- check("org.apache.juneau.reflection", aTypeInfo.getPackage());
+ check("org.apache.juneau.reflect", aTypeInfo.getPackage());
check("java.util", pTypeInfo.getPackage());
check("java.util", pTypeDimensionalInfo.getPackage());
check("java.util", pTypeGenericInfo.getPackage());
@@ -1912,9 +1912,9 @@ public class ClassInfoTest {
@Test
public void xToString() {
- assertEquals("class org.apache.juneau.reflection.AClass",
aClass.toString());
- assertEquals("interface
org.apache.juneau.reflection.AInterface", aInterface.toString());
- assertEquals("class
org.apache.juneau.reflection.ClassInfoTest$A1", aType.toString());
+ assertEquals("class org.apache.juneau.reflect.AClass",
aClass.toString());
+ assertEquals("interface org.apache.juneau.reflect.AInterface",
aInterface.toString());
+ assertEquals("class
org.apache.juneau.reflect.ClassInfoTest$A1", aType.toString());
assertEquals("java.util.Map<java.lang.String,
java.util.List<java.lang.String>>", pType.toString());
assertEquals("java.util.Map<java.lang.String,
java.lang.String[][]>", pTypeDimensional.toString());
assertEquals("java.util.AbstractMap<K, V>",
pTypeGeneric.toString());
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/ConstructorInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ConstructorInfoTest.java
similarity index 98%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/ConstructorInfoTest.java
rename to
juneau-utest/src/test/java/org/apache/juneau/reflect/ConstructorInfoTest.java
index a7e3e33..feca531 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/reflection/ConstructorInfoTest.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ConstructorInfoTest.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
import static org.apache.juneau.reflect.ConstructorInfo.*;
import static org.junit.Assert.*;
@@ -22,7 +22,6 @@ import java.util.function.*;
import java.util.stream.*;
import org.apache.juneau.*;
-import org.apache.juneau.reflect.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/ExecutableInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfoTest.java
similarity index 94%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/ExecutableInfoTest.java
rename to
juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfoTest.java
index eb9defe..987fe2a 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/reflection/ExecutableInfoTest.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ExecutableInfoTest.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
@@ -28,7 +28,6 @@ import java.util.stream.*;
import org.apache.juneau.*;
import org.apache.juneau.internal.*;
-import org.apache.juneau.reflect.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
@@ -309,9 +308,9 @@ public class ExecutableInfoTest {
check(null, c_c1.getAnnotation(CA.class));
check(null, c_c2.getAnnotation(CA.class));
check("@CA()", c_c3.getAnnotation(CA.class));
- check(null, c_m1.getLastAnnotation(CA.class));
- check(null, c_m2.getLastAnnotation(CA.class));
- check("@CA()", c_m3.getLastAnnotation(CA.class));
+ check(null, c_m1.getAnnotation(CA.class));
+ check(null, c_m2.getAnnotation(CA.class));
+ check("@CA()", c_m3.getAnnotation(CA.class));
}
@Test
@@ -578,16 +577,16 @@ public class ExecutableInfoTest {
@Test
public void getFullName_method() {
-
assertEquals("org.apache.juneau.reflection.ExecutableInfoTest$X.foo()",
x.getPublicMethod(x -> x.hasName("foo") && x.hasNoParams()).getFullName());
-
assertEquals("org.apache.juneau.reflection.ExecutableInfoTest$X.foo(java.lang.String)",
x.getPublicMethod(x -> x.hasName("foo") &&
x.hasParamTypes(String.class)).getFullName());
-
assertEquals("org.apache.juneau.reflection.ExecutableInfoTest$X.foo(java.util.Map<java.lang.String,java.lang.Object>)",
x.getPublicMethod(x -> x.hasName("foo") &&
x.hasParamTypes(Map.class)).getFullName());
+
assertEquals("org.apache.juneau.reflect.ExecutableInfoTest$X.foo()",
x.getPublicMethod(x -> x.hasName("foo") && x.hasNoParams()).getFullName());
+
assertEquals("org.apache.juneau.reflect.ExecutableInfoTest$X.foo(java.lang.String)",
x.getPublicMethod(x -> x.hasName("foo") &&
x.hasParamTypes(String.class)).getFullName());
+
assertEquals("org.apache.juneau.reflect.ExecutableInfoTest$X.foo(java.util.Map<java.lang.String,java.lang.Object>)",
x.getPublicMethod(x -> x.hasName("foo") &&
x.hasParamTypes(Map.class)).getFullName());
}
@Test
public void getFullName_constructor() {
-
assertEquals("org.apache.juneau.reflection.ExecutableInfoTest$X()",
x.getPublicConstructor(x -> x.hasNoParams()).getFullName());
-
assertEquals("org.apache.juneau.reflection.ExecutableInfoTest$X(java.lang.String)",
x.getPublicConstructor(x -> x.hasParamTypes(String.class)).getFullName());
-
assertEquals("org.apache.juneau.reflection.ExecutableInfoTest$X(java.util.Map<java.lang.String,java.lang.Object>)",
x.getPublicConstructor(x -> x.hasParamTypes(Map.class)).getFullName());
+
assertEquals("org.apache.juneau.reflect.ExecutableInfoTest$X()",
x.getPublicConstructor(x -> x.hasNoParams()).getFullName());
+
assertEquals("org.apache.juneau.reflect.ExecutableInfoTest$X(java.lang.String)",
x.getPublicConstructor(x -> x.hasParamTypes(String.class)).getFullName());
+
assertEquals("org.apache.juneau.reflect.ExecutableInfoTest$X(java.util.Map<java.lang.String,java.lang.Object>)",
x.getPublicConstructor(x -> x.hasParamTypes(Map.class)).getFullName());
}
@Test
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/FieldInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/FieldInfoTest.java
similarity index 98%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/FieldInfoTest.java
rename to
juneau-utest/src/test/java/org/apache/juneau/reflect/FieldInfoTest.java
index 6fe1aff..7b1f5c0 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflection/FieldInfoTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/FieldInfoTest.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
@@ -24,7 +24,6 @@ import java.lang.reflect.*;
import java.util.function.*;
import org.apache.juneau.*;
-import org.apache.juneau.reflect.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
@@ -360,6 +359,6 @@ public class FieldInfoTest {
@Test
public void toString2() {
- assertEquals("org.apache.juneau.reflection.FieldInfoTest$E.a1",
e_a1.toString());
+ assertEquals("org.apache.juneau.reflect.FieldInfoTest$E.a1",
e_a1.toString());
}
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/MethodInfoTest.java
similarity index 88%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
rename to
juneau-utest/src/test/java/org/apache/juneau/reflect/MethodInfoTest.java
index 27af6ab..2bfef55 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/MethodInfoTest.java
@@ -10,13 +10,14 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.runners.MethodSorters.*;
+import static org.apache.juneau.Context.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -26,7 +27,6 @@ import java.util.stream.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
-import org.apache.juneau.reflect.*;
import org.apache.juneau.svl.*;
import org.junit.*;
@@ -207,38 +207,44 @@ public class MethodInfoTest {
@Test
public void getAnnotationsParentFirst() {
- check("@A(C1),@A(C2),@A(C3),@A(a1)",
c_a1.getAnnotations(A.class));
- check("@A(C1),@A(C2),@A(C3),@A(a2a),@A(a2b)",
c_a2.getAnnotations(A.class));
- check("@A(C1),@A(C2),@A(C3),@A(a3)",
c_a3.getAnnotations(A.class));
- check("@A(C1),@A(C2),@A(C3),@A(a4)",
c_a4.getAnnotations(A.class));
- check("@A(C1),@A(C2),@A(C3)", c_a5.getAnnotations(A.class));
+ check("@A(C1),@A(C2),@A(C3),@A(a1)", annotations(c_a1,
A.class));
+ check("@A(C1),@A(C2),@A(C3),@A(a2a),@A(a2b)", annotations(c_a2,
A.class));
+ check("@A(C1),@A(C2),@A(C3),@A(a3)", annotations(c_a3,
A.class));
+ check("@A(C1),@A(C2),@A(C3),@A(a4)", annotations(c_a4,
A.class));
+ check("@A(C1),@A(C2),@A(C3)", annotations(c_a5, A.class));
}
@Test
public void getAnnotationsParentFirst_notExistent() {
- check("", c_a1.getAnnotations(AX.class));
- check("", c_a2.getAnnotations(AX.class));
- check("", c_a3.getAnnotations(AX.class));
- check("", c_a4.getAnnotations(AX.class));
- check("", c_a5.getAnnotations(AX.class));
+ check("", annotations(c_a1, AX.class));
+ check("", annotations(c_a2, AX.class));
+ check("", annotations(c_a3, AX.class));
+ check("", annotations(c_a4, AX.class));
+ check("", annotations(c_a5, AX.class));
+ }
+
+ private static List<A> annotations(MethodInfo mi, Class<? extends
Annotation> a) {
+ List<A> l = new ArrayList<>();
+ mi.getAnnotations(a, x -> true, x -> l.add((A)x));
+ return l;
}
@Test
public void getAnnotation() {
- check("@A(a1)", c_a1.getLastAnnotation(A.class));
- check("@A(a2b)", c_a2.getLastAnnotation(A.class));
- check("@A(a3)", c_a3.getLastAnnotation(A.class));
- check("@A(a4)", c_a4.getLastAnnotation(A.class));
- check(null, c_a5.getLastAnnotation(A.class));
+ check("@A(a1)", c_a1.getAnnotation(A.class));
+ check("@A(a2b)", c_a2.getAnnotation(A.class));
+ check("@A(a3)", c_a3.getAnnotation(A.class));
+ check("@A(a4)", c_a4.getAnnotation(A.class));
+ check(null, c_a5.getAnnotation(A.class));
}
@Test
public void getAnnotationAny() {
- check("@A(a1)", c_a1.getAnyLastAnnotation(AX.class, A.class));
- check("@A(a2b)", c_a2.getAnyLastAnnotation(AX.class, A.class));
- check("@A(a3)", c_a3.getAnyLastAnnotation(AX.class, A.class));
- check("@A(a4)", c_a4.getAnyLastAnnotation(AX.class, A.class));
- check(null, c_a5.getAnyLastAnnotation(AX.class, A.class));
+ check("@A(a1)", c_a1.getAnyAnnotation(AX.class, A.class));
+ check("@A(a2b)", c_a2.getAnyAnnotation(AX.class, A.class));
+ check("@A(a3)", c_a3.getAnyAnnotation(AX.class, A.class));
+ check("@A(a4)", c_a4.getAnyAnnotation(AX.class, A.class));
+ check(null, c_a5.getAnyAnnotation(AX.class, A.class));
}
@Test
@@ -286,11 +292,11 @@ public class MethodInfoTest {
@Test
public void getConfigAnnotationsMapParentFirst() {
- check("@AConfig(C1),@AConfig(a1),@AConfig(C2),@AConfig(C3)",
cb_a1.getAnnotationList(ContextApplyFilter.INSTANCE));
-
check("@AConfig(C1),@AConfig(a2a),@AConfig(C2),@AConfig(a2b),@AConfig(C3)",
cb_a2.getAnnotationList(ContextApplyFilter.INSTANCE));
- check("@AConfig(C1),@AConfig(a3),@AConfig(C2),@AConfig(C3)",
cb_a3.getAnnotationList(ContextApplyFilter.INSTANCE));
- check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a4)",
cb_a4.getAnnotationList(ContextApplyFilter.INSTANCE));
- check("@AConfig(C1),@AConfig(C2),@AConfig(C3)",
cb_a5.getAnnotationList(ContextApplyFilter.INSTANCE));
+ check("@AConfig(C1),@AConfig(a1),@AConfig(C2),@AConfig(C3)",
cb_a1.getAnnotationList(CONTEXT_APPLY_FILTER));
+
check("@AConfig(C1),@AConfig(a2a),@AConfig(C2),@AConfig(a2b),@AConfig(C3)",
cb_a2.getAnnotationList(CONTEXT_APPLY_FILTER));
+ check("@AConfig(C1),@AConfig(a3),@AConfig(C2),@AConfig(C3)",
cb_a3.getAnnotationList(CONTEXT_APPLY_FILTER));
+ check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a4)",
cb_a4.getAnnotationList(CONTEXT_APPLY_FILTER));
+ check("@AConfig(C1),@AConfig(C2),@AConfig(C3)",
cb_a5.getAnnotationList(CONTEXT_APPLY_FILTER));
}
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-utest/src/test/java/org/apache/juneau/reflection/PA.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/PA.java
similarity index 97%
rename from juneau-utest/src/test/java/org/apache/juneau/reflection/PA.java
rename to juneau-utest/src/test/java/org/apache/juneau/reflect/PA.java
index 1d786e5..aae533f 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflection/PA.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/PA.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
similarity index 81%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
rename to
juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
index a804655..1f97c7b 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
@@ -10,7 +10,7 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.reflection;
+package org.apache.juneau.reflect;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
@@ -23,8 +23,8 @@ import java.util.function.*;
import java.util.stream.*;
import org.apache.juneau.annotation.*;
+import org.apache.juneau.collections.*;
import org.apache.juneau.internal.*;
-import org.apache.juneau.reflect.*;
import org.junit.*;
/**
@@ -180,15 +180,21 @@ public class ParamInfoTest {
@Test
public void getDeclaredAnnotations() throws Exception {
- check("@CA(5)", cb_a1.getDeclaredAnnotations());
- check("@CA(5)", cb_a2.getDeclaredAnnotations());
- check("", cc_a1.getDeclaredAnnotations());
- check("@CA(6)", cc_a2.getDeclaredAnnotations());
+ check("@CA(5)", declaredAnnotations(cb_a1, CA.class));
+ check("@CA(5)", declaredAnnotations(cb_a2, CA.class));
+ check("", declaredAnnotations(cc_a1, CA.class));
+ check("@CA(6)", declaredAnnotations(cc_a2, CA.class));
}
@Test
public void getDeclaredAnnotations_constructor() throws Exception {
- check("@CA(9)", cc_cc.getDeclaredAnnotations());
+ check("@CA(9)", declaredAnnotations(cc_cc, CA.class));
+ }
+
+ private static <T extends Annotation> List<T>
declaredAnnotations(ParamInfo pi, Class<T> type) {
+ List<T> l = new ArrayList<>();
+ pi.getDeclaredAnnotations(type, x -> true, x -> l.add(x));
+ return l;
}
@Test
@@ -226,60 +232,60 @@ public class ParamInfoTest {
@Test
public void getAnnotationsParentFirst() throws Exception {
- check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5)",
cb_a1.getAnnotations(CA.class));
- check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5)",
cb_a2.getAnnotations(CA.class));
- check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5)",
cc_a1.getAnnotations(CA.class));
- check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5),@CA(6)",
cc_a2.getAnnotations(CA.class));
+ check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5)", annotations(cb_a1,
CA.class));
+ check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5)", annotations(cb_a2,
CA.class));
+ check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5)", annotations(cc_a1,
CA.class));
+ check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5),@CA(6)",
annotations(cc_a2, CA.class));
}
@Test
public void getAnnotationsParentFirst_notFound() throws Exception {
- check("", cb_a1.getAnnotations(DA.class));
+ check("", annotations(cb_a1, DA.class));
}
@Test
public void getAnnotationsParentFirst_constructor() throws Exception {
- check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(9)",
cc_cc.getAnnotations(CA.class));
+ check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(9)", annotations(cc_cc,
CA.class));
}
@Test
public void getAnnotationsParentFirst_notFound_constructor() throws
Exception {
- check("", cc_cc.getAnnotations(DA.class));
+ check("", annotations(cc_cc, DA.class));
}
@Test
public void getAnnotation() throws Exception {
- 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));
+ 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));
}
@Test
public void getAnnotation_notFound() throws Exception {
- check(null, cb_a1.getLastAnnotation(DA.class));
+ check(null, cb_a1.getAnnotation(DA.class));
}
@Test
public void getAnnotation_constructor() throws Exception {
- check("@CA(9)", cc_cc.getLastAnnotation(CA.class));
+ check("@CA(9)", cc_cc.getAnnotation(CA.class));
}
@Test
public void getAnnotation_notFound_constructor() throws Exception {
- check(null, cc_cc.getLastAnnotation(DA.class));
+ check(null, cc_cc.getAnnotation(DA.class));
}
@Test
public void getAnnotation_twice() throws Exception {
- check("@CA(5)", cb_a1.getLastAnnotation(CA.class));
- check("@CA(5)", cb_a1.getLastAnnotation(CA.class));
+ check("@CA(5)", cb_a1.getAnnotation(CA.class));
+ check("@CA(5)", cb_a1.getAnnotation(CA.class));
}
@Test
public void getAnnotation_twice_constructor() throws Exception {
- check("@CA(9)", cc_cc.getLastAnnotation(CA.class));
- check("@CA(9)", cc_cc.getLastAnnotation(CA.class));
+ check("@CA(9)", cc_cc.getAnnotation(CA.class));
+ check("@CA(9)", cc_cc.getAnnotation(CA.class));
}
@Test
@@ -325,24 +331,24 @@ public class ParamInfoTest {
@Test
public void getAnnotationsParentFirst_inherited() throws Exception {
- check("@DA(4),@DA(3),@DA(2),@DA(1),@DA(0)",
db_a1.getAnnotations(DA.class));
- check("@DA(4),@DA(3),@DA(2),@DA(1),@DA(0),@DA(5)",
dc_a1.getAnnotations(DA.class));
+ check("@DA(4),@DA(3),@DA(2),@DA(1),@DA(0)", annotations(db_a1,
DA.class));
+ check("@DA(4),@DA(3),@DA(2),@DA(1),@DA(0),@DA(5)",
annotations(dc_a1, DA.class));
}
@Test
public void getAnnotationsParentFirst_inherited_notFound() throws
Exception {
- check("", db_a1.getAnnotations(CA.class));
+ check("", annotations(db_a1, CA.class));
}
@Test
public void getAnnotation_inherited() throws Exception {
- check("@DA(0)", db_a1.getLastAnnotation(DA.class));
- check("@DA(5)", dc_a1.getLastAnnotation(DA.class));
+ check("@DA(0)", db_a1.getAnnotation(DA.class));
+ check("@DA(5)", dc_a1.getAnnotation(DA.class));
}
@Test
public void getAnnotation_inherited_notFound() throws Exception {
- check(null, db_a1.getLastAnnotation(CA.class));
+ check(null, db_a1.getAnnotation(CA.class));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -374,4 +380,14 @@ public class ParamInfoTest {
public void toString2() {
assertEquals("a1[1]", e_a1_b.toString());
}
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Helpers
+
//-----------------------------------------------------------------------------------------------------------------
+
+ private static <T extends Annotation> List<T> annotations(ParamInfo pi,
Class<T> a) {
+ List<T> l = AList.create();
+ pi.getAnnotations(a, x -> true, x -> l.add(x));
+ return l;
+ }
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/package-info.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/package-info.java
similarity index 97%
rename from
juneau-utest/src/test/java/org/apache/juneau/reflection/package-info.java
rename to juneau-utest/src/test/java/org/apache/juneau/reflect/package-info.java
index 4eebc8b..03a23b0 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflection/package-info.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/package-info.java
@@ -12,4 +12,4 @@
//
***************************************************************************************************************************
@PA(10)
-package org.apache.juneau.reflection;
\ No newline at end of file
+package org.apache.juneau.reflect;
\ No newline at end of file
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_Context_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_Context_Test.java
index 9c100ba..c869bc1 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_Context_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_Context_Test.java
@@ -14,6 +14,8 @@ package org.apache.juneau.rest.client;
import static org.junit.Assert.*;
import static org.junit.runners.MethodSorters.*;
+import static org.apache.juneau.Context.*;
+
import java.io.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
@@ -111,7 +113,7 @@ public class RestClient_Config_Context_Test {
client().applyAnnotations(A6b.class).build().post("/echoBody",A6a.get()).run().cacheBody().assertBody().is("{bar:2,baz:3,foo:1}").getBody().asType(A6a.class);
client().applyAnnotations(A6c.class).build().post("/echoBody",A6a.get()).run().cacheBody().assertBody().is("{bar:2,baz:3,foo:1}").getBody().asType(A6a.class);
client().applyAnnotations(A6d.class.getMethod("foo")).build().post("/echoBody",A6a.get()).run().cacheBody().assertBody().is("{bar:2,baz:3,foo:1}").getBody().asType(A6a.class);
- AnnotationWorkList al =
AnnotationWorkList.of(ClassInfo.of(A6c.class).getAnnotationList(ContextApplyFilter.INSTANCE));
+ AnnotationWorkList al =
AnnotationWorkList.of(ClassInfo.of(A6c.class).getAnnotationList(CONTEXT_APPLY_FILTER));
client().apply(al).build().post("/echoBody",A6a.get()).run().cacheBody().assertBody().is("{bar:2,baz:3,foo:1}").getBody().asType(A6a.class);
}