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 6979ce6c25 Utility class modernization
6979ce6c25 is described below
commit 6979ce6c25927a98753dc600362d7855e5b708a7
Author: James Bognar <[email protected]>
AuthorDate: Fri Nov 7 12:44:27 2025 -0500
Utility class modernization
---
.../juneau/common/reflect/AnnotationProvider.java | 2 +-
.../apache/juneau/common/reflect/FieldInfo.java | 12 ++--
.../juneau/common/reflect/ParameterInfo.java | 22 ++++----
.../juneau/httppart/bean/RequestBeanMeta.java | 2 +-
.../java/org/apache/juneau/rest/RestContext.java | 22 ++++----
.../org/apache/juneau/rest/arg/FormDataArg.java | 2 +-
.../java/org/apache/juneau/rest/arg/HeaderArg.java | 2 +-
.../java/org/apache/juneau/rest/arg/PathArg.java | 4 +-
.../java/org/apache/juneau/rest/arg/QueryArg.java | 2 +-
.../reflect/FieldInfo_AnnotationInfos_Test.java | 24 ++++----
.../juneau/common/reflect/ParamInfoTest.java | 66 +++++++++++-----------
.../org/apache/juneau/reflect/ParamInfoTest.java | 44 +++++++--------
12 files changed, 102 insertions(+), 102 deletions(-)
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/AnnotationProvider.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/AnnotationProvider.java
index 9fa4054943..54ef0c396f 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/AnnotationProvider.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/AnnotationProvider.java
@@ -825,7 +825,7 @@ public class AnnotationProvider {
FieldInfo fi = FieldInfo.of(forField);
runtimeAnnotations.findMatching(forField).forEach(a ->
list.add(AnnotationInfo.of(fi, a)));
- list.addAll(fi.getAnnotationInfos());
+ list.addAll(fi.getDeclaredAnnotationInfos());
return u(list);
}
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/FieldInfo.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/FieldInfo.java
index 612ec69fa3..b38a95749c 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/FieldInfo.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/FieldInfo.java
@@ -68,7 +68,7 @@ public class FieldInfo extends AccessibleInfo implements
Comparable<FieldInfo>,
private final Field inner;
private final ClassInfo declaringClass;
private final Supplier<ClassInfo> type;
- private final Supplier<List<AnnotationInfo<Annotation>>> annotations;
// All annotations on this field.
+ private final Supplier<List<AnnotationInfo<Annotation>>>
declaredAnnotations; // All annotations declared directly on this field.
private final Supplier<String> fullName; // Fully qualified field name
(declaring-class.field-name).
/**
@@ -82,7 +82,7 @@ public class FieldInfo extends AccessibleInfo implements
Comparable<FieldInfo>,
this.declaringClass = declaringClass;
this.inner = f;
this.type = memoize(() -> ClassInfo.of(f.getType()));
- this.annotations = memoize(() ->
stream(inner.getAnnotations()).map(a -> AnnotationInfo.of(this, a)).toList());
+ this.declaredAnnotations = memoize(() ->
stream(inner.getAnnotations()).map(a -> AnnotationInfo.of(this, a)).toList());
this.fullName = memoize(this::findFullName);
}
@@ -102,8 +102,8 @@ public class FieldInfo extends AccessibleInfo implements
Comparable<FieldInfo>,
*
* @return An unmodifiable list of all annotations declared on this
field.
*/
- public List<AnnotationInfo<Annotation>> getAnnotationInfos() {
- return annotations.get();
+ public List<AnnotationInfo<Annotation>> getDeclaredAnnotationInfos() {
+ return declaredAnnotations.get();
}
/**
@@ -114,8 +114,8 @@ public class FieldInfo extends AccessibleInfo implements
Comparable<FieldInfo>,
* @return A stream of all matching annotations.
*/
@SuppressWarnings("unchecked")
- public <A extends Annotation> Stream<AnnotationInfo<A>>
getAnnotationInfos(Class<A> type) {
- return annotations.get().stream()
+ public <A extends Annotation> Stream<AnnotationInfo<A>>
getDeclaredAnnotationInfos(Class<A> type) {
+ return declaredAnnotations.get().stream()
.filter(x -> type.isInstance(x.inner()))
.map(x -> (AnnotationInfo<A>)x);
}
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ParameterInfo.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ParameterInfo.java
index 33f410294d..6e7d05c816 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ParameterInfo.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ParameterInfo.java
@@ -59,9 +59,9 @@ public class ParameterInfo extends ElementInfo implements
Annotatable {
private final ClassInfo type;
@SuppressWarnings({"rawtypes","unchecked"})
- private final Cache<Class,List<AnnotationInfo<Annotation>>>
foundAnnotations =
Cache.<Class,List<AnnotationInfo<Annotation>>>create().supplier((k) ->
findAnnotationInfosInternal(k)).build();
+ private final Cache<Class,List<AnnotationInfo<Annotation>>>
allAnnotations =
Cache.<Class,List<AnnotationInfo<Annotation>>>create().supplier((k) ->
findAnnotationInfosInternal(k)).build();
- private final Supplier<List<AnnotationInfo<Annotation>>> annotations;
// All annotations on this parameter.
+ private final Supplier<List<AnnotationInfo<Annotation>>>
declaredAnnotations; // All annotations declared directly on this parameter.
private final Supplier<List<ParameterInfo>> matchingParameters; //
Matching parameters in parent methods.
private final ResettableSupplier<String> foundName =
memoizeResettable(this::findNameInternal);
private final ResettableSupplier<String> foundQualifier =
memoizeResettable(this::findQualifierInternal);
@@ -81,7 +81,7 @@ public class ParameterInfo extends ElementInfo implements
Annotatable {
this.inner = inner;
this.index = index;
this.type = type;
- this.annotations = memoize(() ->
stream(inner.getAnnotations()).map(a -> AnnotationInfo.of(this, a)).toList());
+ this.declaredAnnotations = memoize(() ->
stream(inner.getAnnotations()).map(a -> AnnotationInfo.of(this, a)).toList());
this.matchingParameters = memoize(this::findMatchingParameters);
}
@@ -103,7 +103,7 @@ public class ParameterInfo extends ElementInfo implements
Annotatable {
* @return An unmodifiable list of annotations on this parameter, never
<jk>null</jk>.
*/
public List<AnnotationInfo<Annotation>> getAnnotationInfos() {
- return annotations.get();
+ return declaredAnnotations.get();
}
/**
@@ -256,7 +256,7 @@ public class ParameterInfo extends ElementInfo implements
Annotatable {
}
/**
- * Finds all annotation infos of the specified type defined on this
method parameter.
+ * Returns all annotation infos of the specified type defined on this
method parameter.
*
* <p>
* Searches through matching parameters in the hierarchy and the
parameter type.
@@ -266,12 +266,12 @@ public class ParameterInfo extends ElementInfo implements
Annotatable {
* @return A list of annotation infos found, or an empty list if none
found.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
- public <A extends Annotation> List<AnnotationInfo<A>>
findAnnotationInfos(Class<A> type) {
- return (List)foundAnnotations.get(type);
+ public <A extends Annotation> List<AnnotationInfo<A>>
getAllAnnotationInfos(Class<A> type) {
+ return (List)allAnnotations.get(type);
}
/**
- * Finds the first annotation info of the specified type defined on
this method parameter.
+ * Returns the first annotation info of the specified type defined on
this method parameter.
*
* <p>
* Searches through matching parameters in the hierarchy and the
parameter type.
@@ -280,8 +280,8 @@ public class ParameterInfo extends ElementInfo implements
Annotatable {
* @param type The annotation type to look for.
* @return The annotation info if found, or <jk>null</jk> if not.
*/
- public <A extends Annotation> AnnotationInfo<A>
findAnnotationInfo(Class<A> type) {
- var list = findAnnotationInfos(type);
+ public <A extends Annotation> AnnotationInfo<A>
getAllAnnotationInfo(Class<A> type) {
+ var list = getAllAnnotationInfos(type);
return list.isEmpty() ? null : list.get(0);
}
@@ -444,7 +444,7 @@ public class ParameterInfo extends ElementInfo implements
Annotatable {
* The <jk>true</jk> if annotation if found.
*/
public <A extends Annotation> boolean hasAnnotation(Class<A> type) {
- return nn(findAnnotationInfo(type));
+ return nn(getAllAnnotationInfo(type));
}
/**
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 c2f98ccaaf..dcf29d97cb 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
@@ -81,7 +81,7 @@ public class RequestBeanMeta {
}
Builder apply(ParameterInfo mpi) {
- return
apply(mpi.getParameterType().inner()).apply(opt(mpi.findAnnotationInfo(Request.class)).map(x
-> x.inner()).orElse(null));
+ return
apply(mpi.getParameterType().inner()).apply(opt(mpi.getAllAnnotationInfo(Request.class)).map(x
-> x.inner()).orElse(null));
}
Builder apply(Request a) {
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 b47e0efbf7..9529fbd3ab 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
@@ -1765,12 +1765,12 @@ public class RestContext extends Context {
.filter(x -> x.hasAnnotation(RestInject.class))
.forEach(x ->
opt(x.get(resource.get())).ifPresent(
y -> beanStore.add(
- x.getFieldType().inner(),
- y,
-
RestInjectAnnotation.name(x.getAnnotationInfos(RestInject.class).findFirst().map(AnnotationInfo::inner).orElse(null))
- )
- ));
- // @formatter:on
+ x.getFieldType().inner(),
+ y,
+
RestInjectAnnotation.name(x.getDeclaredAnnotationInfos(RestInject.class).findFirst().map(AnnotationInfo::inner).orElse(null))
+ )
+ ));
+ // @formatter:on
rci.getAllMethods().stream().filter(x ->
x.hasAnnotation(RestInject.class)).forEach(x -> {
var rt = x.getReturnType().<Object>inner();
@@ -1802,11 +1802,11 @@ public class RestContext extends Context {
.filter(x -> x.hasAnnotation(RestInject.class))
.forEach(x -> x.setIfNull(
resource.get(),
- beanStore.getBean(
- x.getFieldType().inner(),
-
RestInjectAnnotation.name(x.getAnnotationInfos(RestInject.class).findFirst().map(AnnotationInfo::inner).orElse(null))
- ).orElse(null)
- ));
+ beanStore.getBean(
+ x.getFieldType().inner(),
+
RestInjectAnnotation.name(x.getDeclaredAnnotationInfos(RestInject.class).findFirst().map(AnnotationInfo::inner).orElse(null))
+ ).orElse(null)
+ ));
// @formatter:on
return this;
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/FormDataArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/FormDataArg.java
index 6c0b6d9093..617e3476b7 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/FormDataArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/FormDataArg.java
@@ -102,7 +102,7 @@ public class FormDataArg implements RestOpArg {
return null;
// Get parameter-level @FormData
- FormData paramFormData =
opt(pi.findAnnotationInfo(FormData.class)).map(x -> x.inner()).orElse(null);
+ FormData paramFormData =
opt(pi.getAllAnnotationInfo(FormData.class)).map(x -> x.inner()).orElse(null);
if (paramFormData == null)
paramFormData =
pi.getParameterType().getAnnotationInfos(FormData.class).findFirst().map(AnnotationInfo::inner).orElse(null);
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HeaderArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HeaderArg.java
index 1b46f5779b..1d57375a1b 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HeaderArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HeaderArg.java
@@ -144,7 +144,7 @@ public class HeaderArg implements RestOpArg {
return null;
// Get parameter-level @Header
- Header paramHeader = opt(pi.findAnnotationInfo(Header.class)).map(x ->
x.inner()).orElse(null);
+ Header paramHeader = opt(pi.getAllAnnotationInfo(Header.class)).map(x
-> x.inner()).orElse(null);
if (paramHeader == null)
paramHeader =
pi.getParameterType().getAnnotationInfos(Header.class).findFirst().map(AnnotationInfo::inner).orElse(null);
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 ddea81f623..094a0fd848 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
@@ -101,7 +101,7 @@ public class PathArg implements RestOpArg {
return null;
// Get parameter-level @Path
- Path paramPath = opt(pi.findAnnotationInfo(Path.class)).map(x ->
x.inner()).orElse(null);
+ Path paramPath = opt(pi.getAllAnnotationInfo(Path.class)).map(x ->
x.inner()).orElse(null);
if (paramPath == null)
paramPath =
pi.getParameterType().getAnnotationInfos(Path.class).findFirst().map(AnnotationInfo::inner).orElse(null);
@@ -201,7 +201,7 @@ public class PathArg implements RestOpArg {
MethodInfo mi = pi.getMethod();
for (int j = 0; j < i; j++)
- if
(nn(mi.getParameter(j).findAnnotationInfo(Path.class)))
+ if
(nn(mi.getParameter(j).getAllAnnotationInfo(Path.class)))
idx++;
String[] vars = pathMatcher.getVars();
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/QueryArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/QueryArg.java
index 1a5ed7ac93..b9527d4906 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/QueryArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/QueryArg.java
@@ -102,7 +102,7 @@ public class QueryArg implements RestOpArg {
return null;
// Get parameter-level @Query
- Query paramQuery = opt(pi.findAnnotationInfo(Query.class)).map(x ->
x.inner()).orElse(null);
+ Query paramQuery = opt(pi.getAllAnnotationInfo(Query.class)).map(x ->
x.inner()).orElse(null);
if (paramQuery == null)
paramQuery =
pi.getParameterType().getAnnotationInfos(Query.class).findFirst().map(AnnotationInfo::inner).orElse(null);
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/FieldInfo_AnnotationInfos_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/FieldInfo_AnnotationInfos_Test.java
index 9ca8755a2b..16e11f0c6b 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/FieldInfo_AnnotationInfos_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/FieldInfo_AnnotationInfos_Test.java
@@ -19,7 +19,7 @@ import java.lang.annotation.*;
import org.junit.jupiter.api.*;
/**
- * Tests for {@link FieldInfo#getAnnotationInfos()} methods.
+ * Tests for {@link FieldInfo#getDeclaredAnnotationInfos()} methods.
*/
public class FieldInfo_AnnotationInfos_Test {
@@ -60,18 +60,18 @@ public class FieldInfo_AnnotationInfos_Test {
var field3 = ci.getPublicField(x ->
x.getName().equals("field3"));
// field1 has 2 annotations
- var annotations1 = field1.getAnnotationInfos();
+ var annotations1 = field1.getDeclaredAnnotationInfos();
assertEquals(2, annotations1.size());
assertTrue(annotations1.stream().anyMatch(a ->
a.hasSimpleName("TestAnnotation1")));
assertTrue(annotations1.stream().anyMatch(a ->
a.hasSimpleName("TestAnnotation2")));
// field2 has 1 annotation
- var annotations2 = field2.getAnnotationInfos();
+ var annotations2 = field2.getDeclaredAnnotationInfos();
assertEquals(1, annotations2.size());
assertTrue(annotations2.stream().anyMatch(a ->
a.hasSimpleName("TestAnnotation1")));
// field3 has no annotations
- var annotations3 = field3.getAnnotationInfos();
+ var annotations3 = field3.getDeclaredAnnotationInfos();
assertEquals(0, annotations3.size());
}
@@ -82,24 +82,24 @@ public class FieldInfo_AnnotationInfos_Test {
var field2 = ci.getPublicField(x ->
x.getName().equals("field2"));
// Test filtering by type for field1
- var ann1_type1 =
field1.getAnnotationInfos(TestAnnotation1.class).toList();
+ var ann1_type1 =
field1.getDeclaredAnnotationInfos(TestAnnotation1.class).toList();
assertEquals(1, ann1_type1.size());
assertEquals("test1", ann1_type1.get(0).getValue().get());
- var ann1_type2 =
field1.getAnnotationInfos(TestAnnotation2.class).toList();
+ var ann1_type2 =
field1.getDeclaredAnnotationInfos(TestAnnotation2.class).toList();
assertEquals(1, ann1_type2.size());
assertEquals(42, ann1_type2.get(0).getInt("value").get());
// Test filtering by type that doesn't exist
- var ann1_type3 =
field1.getAnnotationInfos(TestAnnotation3.class).toList();
+ var ann1_type3 =
field1.getDeclaredAnnotationInfos(TestAnnotation3.class).toList();
assertEquals(0, ann1_type3.size());
// Test filtering for field2
- var ann2_type1 =
field2.getAnnotationInfos(TestAnnotation1.class).toList();
+ var ann2_type1 =
field2.getDeclaredAnnotationInfos(TestAnnotation1.class).toList();
assertEquals(1, ann2_type1.size());
assertEquals("test2", ann2_type1.get(0).getValue().get());
- var ann2_type2 =
field2.getAnnotationInfos(TestAnnotation2.class).toList();
+ var ann2_type2 =
field2.getDeclaredAnnotationInfos(TestAnnotation2.class).toList();
assertEquals(0, ann2_type2.size());
}
@@ -108,9 +108,9 @@ public class FieldInfo_AnnotationInfos_Test {
var ci = ClassInfo.of(TestClass.class);
var field1 = ci.getPublicField(x ->
x.getName().equals("field1"));
- // Calling getAnnotationInfos() multiple times should return
the same list instance
- var annotations1 = field1.getAnnotationInfos();
- var annotations2 = field1.getAnnotationInfos();
+ // Calling getDeclaredAnnotationInfos() multiple times should
return the same list instance
+ var annotations1 = field1.getDeclaredAnnotationInfos();
+ var annotations2 = field1.getDeclaredAnnotationInfos();
assertSame(annotations1, annotations2);
}
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ParamInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ParamInfoTest.java
index 6a17a956cc..f6614bac82 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ParamInfoTest.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/common/reflect/ParamInfoTest.java
@@ -259,35 +259,35 @@ class ParamInfoTest extends TestBase {
check("", annotations(cc_cc, DA.class));
}
- @Test void findAnnotationInfo() {
- check("@CA(5)", cb_a1.findAnnotationInfo(CA.class).inner());
- check("@CA(5)", cb_a2.findAnnotationInfo(CA.class).inner());
- check("@CA(5)", cc_a1.findAnnotationInfo(CA.class).inner());
- check("@CA(6)", cc_a2.findAnnotationInfo(CA.class).inner());
+ @Test void getAllAnnotationInfo() {
+ check("@CA(5)", cb_a1.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(5)", cb_a2.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(5)", cc_a1.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(6)", cc_a2.getAllAnnotationInfo(CA.class).inner());
}
- @Test void findAnnotationInfo_notFound() {
- var ai = cb_a1.findAnnotationInfo(DA.class);
+ @Test void getAllAnnotationInfo_notFound() {
+ var ai = cb_a1.getAllAnnotationInfo(DA.class);
check(null, ai == null ? null : ai.inner());
}
- @Test void findAnnotationInfo_constructor() {
- check("@CA(9)", cc_cc.findAnnotationInfo(CA.class).inner());
+ @Test void getAllAnnotationInfo_constructor() {
+ check("@CA(9)", cc_cc.getAllAnnotationInfo(CA.class).inner());
}
- @Test void findAnnotationInfo_notFound_constructor() {
- var ai = cc_cc.findAnnotationInfo(DA.class);
+ @Test void getAllAnnotationInfo_notFound_constructor() {
+ var ai = cc_cc.getAllAnnotationInfo(DA.class);
check(null, ai == null ? null : ai.inner());
}
- @Test void findAnnotationInfo_twice() {
- check("@CA(5)", cb_a1.findAnnotationInfo(CA.class).inner());
- check("@CA(5)", cb_a1.findAnnotationInfo(CA.class).inner());
+ @Test void getAllAnnotationInfo_twice() {
+ check("@CA(5)", cb_a1.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(5)", cb_a1.getAllAnnotationInfo(CA.class).inner());
}
- @Test void findAnnotationInfo_twice_constructor() {
- check("@CA(9)", cc_cc.findAnnotationInfo(CA.class).inner());
- check("@CA(9)", cc_cc.findAnnotationInfo(CA.class).inner());
+ @Test void getAllAnnotationInfo_twice_constructor() {
+ check("@CA(9)", cc_cc.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(9)", cc_cc.getAllAnnotationInfo(CA.class).inner());
}
@Test void hasAnnotation() {
@@ -338,13 +338,13 @@ class ParamInfoTest extends TestBase {
check("", annotations(db_a1, CA.class));
}
- @Test void findAnnotationInfo_inherited() {
- check("@DA(0)", db_a1.findAnnotationInfo(DA.class).inner());
- check("@DA(5)", dc_a1.findAnnotationInfo(DA.class).inner());
+ @Test void getAllAnnotationInfo_inherited() {
+ check("@DA(0)", db_a1.getAllAnnotationInfo(DA.class).inner());
+ check("@DA(5)", dc_a1.getAllAnnotationInfo(DA.class).inner());
}
- @Test void findAnnotationInfo_inherited_notFound() {
- var ai = db_a1.findAnnotationInfo(CA.class);
+ @Test void getAllAnnotationInfo_inherited_notFound() {
+ var ai = db_a1.getAllAnnotationInfo(CA.class);
check(null, ai == null ? null : ai.inner());
}
@@ -652,7 +652,7 @@ class ParamInfoTest extends TestBase {
}
//-----------------------------------------------------------------------------------------------------------------
- // findAnnotationInfos() / findAnnotationInfo()
+ // getAllAnnotationInfos() / getAllAnnotationInfo()
//-----------------------------------------------------------------------------------------------------------------
@Nested
@@ -681,7 +681,7 @@ class ParamInfoTest extends TestBase {
@Test void findOnParameter() throws Exception {
var mi = MethodInfo.of(F1.class.getMethod("test",
String.class));
var pi = mi.getParameter(0);
- var infos = pi.findAnnotationInfos(FA1.class);
+ var infos = pi.getAllAnnotationInfos(FA1.class);
assertEquals(1, infos.size());
assertEquals(1, infos.get(0).inner().value());
}
@@ -689,7 +689,7 @@ class ParamInfoTest extends TestBase {
@Test void findOnParameter_single() throws Exception {
var mi = MethodInfo.of(F1.class.getMethod("test",
String.class));
var pi = mi.getParameter(0);
- var info = pi.findAnnotationInfo(FA1.class);
+ var info = pi.getAllAnnotationInfo(FA1.class);
assertNotNull(info);
assertEquals(1, info.inner().value());
}
@@ -706,7 +706,7 @@ class ParamInfoTest extends TestBase {
@Test void findFromMatchingMethod() throws Exception {
var mi = MethodInfo.of(F3.class.getMethod("test",
String.class));
var pi = mi.getParameter(0);
- var infos = pi.findAnnotationInfos(FA1.class);
+ var infos = pi.getAllAnnotationInfos(FA1.class);
assertEquals(1, infos.size());
assertEquals(2, infos.get(0).inner().value());
}
@@ -722,7 +722,7 @@ class ParamInfoTest extends TestBase {
@Test void findFromParameterType() throws Exception {
var mi = MethodInfo.of(F5.class.getMethod("test",
F4Type.class));
var pi = mi.getParameter(0);
- var infos = pi.findAnnotationInfos(FA1.class);
+ var infos = pi.getAllAnnotationInfos(FA1.class);
assertEquals(1, infos.size());
assertEquals(3, infos.get(0).inner().value());
}
@@ -743,7 +743,7 @@ class ParamInfoTest extends TestBase {
@Test void findMultipleFromHierarchy() throws Exception {
var mi = MethodInfo.of(F8.class.getMethod("test",
String.class));
var pi = mi.getParameter(0);
- var infos = pi.findAnnotationInfos(FA1.class);
+ var infos = pi.getAllAnnotationInfos(FA1.class);
assertEquals(3, infos.size());
assertEquals(6, infos.get(0).inner().value()); // F8
assertEquals(4, infos.get(1).inner().value()); // F6
@@ -753,7 +753,7 @@ class ParamInfoTest extends TestBase {
@Test void findMultipleFromHierarchy_single() throws Exception {
var mi = MethodInfo.of(F8.class.getMethod("test",
String.class));
var pi = mi.getParameter(0);
- var info = pi.findAnnotationInfo(FA1.class);
+ var info = pi.getAllAnnotationInfo(FA1.class);
assertNotNull(info);
assertEquals(6, info.inner().value()); // Returns first
(F8)
}
@@ -770,7 +770,7 @@ class ParamInfoTest extends TestBase {
@Test void findFromMatchingConstructor() throws Exception {
var ci =
ConstructorInfo.of(F10.class.getConstructor(String.class));
var pi = ci.getParameter(0);
- var infos = pi.findAnnotationInfos(FA1.class);
+ var infos = pi.getAllAnnotationInfos(FA1.class);
assertEquals(2, infos.size());
assertEquals(8, infos.get(0).inner().value()); // F10
assertEquals(7, infos.get(1).inner().value()); // F9
@@ -784,14 +784,14 @@ class ParamInfoTest extends TestBase {
@Test void notFound() throws Exception {
var mi = MethodInfo.of(F11.class.getMethod("test",
String.class));
var pi = mi.getParameter(0);
- var infos = pi.findAnnotationInfos(FA1.class);
+ var infos = pi.getAllAnnotationInfos(FA1.class);
assertEquals(0, infos.size());
}
@Test void notFound_single() throws Exception {
var mi = MethodInfo.of(F11.class.getMethod("test",
String.class));
var pi = mi.getParameter(0);
- var info = pi.findAnnotationInfo(FA1.class);
+ var info = pi.getAllAnnotationInfo(FA1.class);
assertNull(info);
}
@@ -806,7 +806,7 @@ class ParamInfoTest extends TestBase {
@Test void parameterAnnotationBeforeTypeAnnotation() throws
Exception {
var mi = MethodInfo.of(F13.class.getMethod("test",
F12Type.class));
var pi = mi.getParameter(0);
- var infos = pi.findAnnotationInfos(FA1.class);
+ var infos = pi.getAllAnnotationInfos(FA1.class);
assertEquals(2, infos.size());
assertEquals(10, infos.get(0).inner().value()); //
Parameter annotation first
assertEquals(9, infos.get(1).inner().value()); // Type
annotation second
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
index bf8b9446b3..1e462ff745 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflect/ParamInfoTest.java
@@ -236,35 +236,35 @@ class ParamInfoTest extends TestBase {
check("", annotations(cc_cc, DA.class));
}
- @Test void findAnnotationInfo() {
- check("@CA(5)", cb_a1.findAnnotationInfo(CA.class).inner());
- check("@CA(5)", cb_a2.findAnnotationInfo(CA.class).inner());
- check("@CA(5)", cc_a1.findAnnotationInfo(CA.class).inner());
- check("@CA(6)", cc_a2.findAnnotationInfo(CA.class).inner());
+ @Test void getAllAnnotationInfo() {
+ check("@CA(5)", cb_a1.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(5)", cb_a2.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(5)", cc_a1.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(6)", cc_a2.getAllAnnotationInfo(CA.class).inner());
}
- @Test void findAnnotationInfo_notFound() {
- var ai = cb_a1.findAnnotationInfo(DA.class);
+ @Test void getAllAnnotationInfo_notFound() {
+ var ai = cb_a1.getAllAnnotationInfo(DA.class);
check(null, ai == null ? null : ai.inner());
}
- @Test void findAnnotationInfo_constructor() {
- check("@CA(9)", cc_cc.findAnnotationInfo(CA.class).inner());
+ @Test void getAllAnnotationInfo_constructor() {
+ check("@CA(9)", cc_cc.getAllAnnotationInfo(CA.class).inner());
}
- @Test void findAnnotationInfo_notFound_constructor() {
- var ai = cc_cc.findAnnotationInfo(DA.class);
+ @Test void getAllAnnotationInfo_notFound_constructor() {
+ var ai = cc_cc.getAllAnnotationInfo(DA.class);
check(null, ai == null ? null : ai.inner());
}
- @Test void findAnnotationInfo_twice() {
- check("@CA(5)", cb_a1.findAnnotationInfo(CA.class).inner());
- check("@CA(5)", cb_a1.findAnnotationInfo(CA.class).inner());
+ @Test void getAllAnnotationInfo_twice() {
+ check("@CA(5)", cb_a1.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(5)", cb_a1.getAllAnnotationInfo(CA.class).inner());
}
- @Test void findAnnotationInfo_twice_constructor() {
- check("@CA(9)", cc_cc.findAnnotationInfo(CA.class).inner());
- check("@CA(9)", cc_cc.findAnnotationInfo(CA.class).inner());
+ @Test void getAllAnnotationInfo_twice_constructor() {
+ check("@CA(9)", cc_cc.getAllAnnotationInfo(CA.class).inner());
+ check("@CA(9)", cc_cc.getAllAnnotationInfo(CA.class).inner());
}
@Test void hasAnnotation() {
@@ -315,13 +315,13 @@ class ParamInfoTest extends TestBase {
check("", annotations(db_a1, CA.class));
}
- @Test void findAnnotationInfo_inherited() {
- check("@DA(0)", db_a1.findAnnotationInfo(DA.class).inner());
- check("@DA(5)", dc_a1.findAnnotationInfo(DA.class).inner());
+ @Test void getAllAnnotationInfo_inherited() {
+ check("@DA(0)", db_a1.getAllAnnotationInfo(DA.class).inner());
+ check("@DA(5)", dc_a1.getAllAnnotationInfo(DA.class).inner());
}
- @Test void findAnnotationInfo_inherited_notFound() {
- var ai = db_a1.findAnnotationInfo(CA.class);
+ @Test void getAllAnnotationInfo_inherited_notFound() {
+ var ai = db_a1.getAllAnnotationInfo(CA.class);
check(null, ai == null ? null : ai.inner());
}