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 f89857e1e4 Utility class modernization
f89857e1e4 is described below
commit f89857e1e42d0bc2d8a844ccfa53629f5a93af99
Author: James Bognar <[email protected]>
AuthorDate: Fri Nov 7 18:30:57 2025 -0500
Utility class modernization
---
.../juneau/common/reflect/ParameterInfo.java | 71 ----------------------
.../juneau/http/annotation/FormDataAnnotation.java | 6 +-
.../juneau/http/annotation/HeaderAnnotation.java | 6 +-
.../juneau/http/annotation/PathAnnotation.java | 6 +-
.../http/annotation/PathRemainderAnnotation.java | 2 +-
.../juneau/http/annotation/QueryAnnotation.java | 6 +-
.../juneau/httppart/bean/ResponseBeanMeta.java | 4 +-
.../org/apache/juneau/rest/arg/AttributeArg.java | 5 +-
.../org/apache/juneau/rest/arg/HasFormDataArg.java | 3 +-
.../org/apache/juneau/rest/arg/HasQueryArg.java | 3 +-
.../rest/swagger/BasicSwaggerProviderSession.java | 34 +++++------
.../juneau/common/reflect/ParamInfoTest.java | 2 +-
.../org/apache/juneau/reflect/ParamInfoTest.java | 2 +-
13 files changed, 41 insertions(+), 109 deletions(-)
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 a253c49150..caacb793bd 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
@@ -116,77 +116,6 @@ public class ParameterInfo extends ElementInfo implements
Annotatable {
return getParameterType().isInstance(value);
}
- /**
- * Performs an action on all matching annotations on this 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 type to look for.
- * @param type The annotation type to look for.
- * @param filter A predicate to apply to the entries to determine if
action should be performed. Can be <jk>null</jk>.
- * @param action An action to perform on the entry.
- * @return This object.
- */
- public <A extends Annotation> ParameterInfo forEachAnnotation(Class<A>
type, Predicate<A> filter, Consumer<A> action) {
- // Inline implementation using reflection directly instead of
delegating to AnnotationProvider.DEFAULT
- if (!nn(type))
- return this;
-
- if (executable.isConstructor()) {
- // For constructors: search parameter type hierarchy
and parameter annotations
- var ci =
executable.getParameter(index).getParameterType().unwrap(Value.class,
Optional.class);
- // Search class hierarchy using reflection (package ->
interfaces -> parents -> class)
- var packageAnn = ci.getPackageAnnotation(type);
- if (nn(packageAnn))
- consumeIf(filter, action, packageAnn);
- // Get annotations from interfaces (reverse order)
- var interfaces2 = ci.getInterfaces();
- for (int i = interfaces2.size() - 1; i >= 0; i--)
- for (var ann :
interfaces2.get(i).inner().getDeclaredAnnotationsByType(type))
- consumeIf(filter, action, ann);
- // Get annotations from parent classes (reverse order)
- var parents2 = ci.getParents();
- for (int i = parents2.size() - 1; i >= 0; i--)
- for (var ann :
parents2.get(i).inner().getDeclaredAnnotationsByType(type))
- consumeIf(filter, action, ann);
- // Get annotations directly from parameter
- var annotationInfos = getAnnotationInfos();
- for (var ai : annotationInfos)
- if (type.isInstance(ai.inner()))
- consumeIf(filter, action,
type.cast(ai.inner()));
- } else {
- // For methods: search parameter type hierarchy and
matching parent methods
- var mi = (MethodInfo)executable;
- var ci =
executable.getParameter(index).getParameterType().unwrap(Value.class,
Optional.class);
- // Search class hierarchy using reflection (package ->
interfaces -> parents -> class)
- var packageAnn = ci.getPackageAnnotation(type);
- if (nn(packageAnn))
- consumeIf(filter, action, packageAnn);
- // Get annotations from interfaces (reverse order)
- var interfaces2 = ci.getInterfaces();
- for (int i = interfaces2.size() - 1; i >= 0; i--)
- for (var ann :
interfaces2.get(i).inner().getDeclaredAnnotationsByType(type))
- consumeIf(filter, action, ann);
- // Get annotations from parent classes (reverse order)
- var parents2 = ci.getParents();
- for (int i = parents2.size() - 1; i >= 0; i--)
- for (var ann :
parents2.get(i).inner().getDeclaredAnnotationsByType(type))
- consumeIf(filter, action, ann);
- // Get annotations from matching parent
methods' parameters
- rstream(mi.getMatchingMethods()).forEach(x -> {
-
x.getParameter(index).getAnnotationInfos().stream()
- .filter(ai ->
type.isInstance(ai.inner()))
- .map(ai ->
type.cast(ai.inner()))
- .forEach(ann ->
consumeIf(filter, action, ann));
- });
- }
- return this;
- }
-
/**
* Returns a stream of annotation infos of the specified type declared
on this parameter.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
index 9e72a58cb7..e9cdad549c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
@@ -274,7 +274,7 @@ public class FormDataAnnotation {
*/
public static Value<String> findDef(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(FormData.class, x -> isNotEmpty(x.def()),
x -> n.set(x.def()));
+
rstream(pi.getAllAnnotationInfos(FormData.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.def())).forEach(x -> n.set(x.def()));
return n;
}
@@ -289,8 +289,8 @@ public class FormDataAnnotation {
*/
public static Value<String> findName(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(FormData.class, x ->
isNotEmpty(x.value()), x -> n.set(x.value()));
- pi.forEachAnnotation(FormData.class, x -> isNotEmpty(x.name()),
x -> n.set(x.name()));
+
rstream(pi.getAllAnnotationInfos(FormData.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.value())).forEach(x -> n.set(x.value()));
+
rstream(pi.getAllAnnotationInfos(FormData.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.name())).forEach(x -> n.set(x.name()));
return n;
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
index 24711c5493..4b16cf2de8 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
@@ -274,7 +274,7 @@ public class HeaderAnnotation {
*/
public static Value<String> findDef(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(Header.class, x -> isNotEmpty(x.def()), x
-> n.set(x.def()));
+
rstream(pi.getAllAnnotationInfos(Header.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.def())).forEach(x -> n.set(x.def()));
return n;
}
@@ -289,8 +289,8 @@ public class HeaderAnnotation {
*/
public static Value<String> findName(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(Header.class, x -> isNotEmpty(x.value()),
x -> n.set(x.value()));
- pi.forEachAnnotation(Header.class, x -> isNotEmpty(x.name()), x
-> n.set(x.name()));
+
rstream(pi.getAllAnnotationInfos(Header.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.value())).forEach(x -> n.set(x.value()));
+
rstream(pi.getAllAnnotationInfos(Header.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.name())).forEach(x -> n.set(x.name()));
return n;
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
index 0589b8a065..31d37024e2 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
@@ -274,7 +274,7 @@ public class PathAnnotation {
*/
public static Value<String> findDef(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(Path.class, x -> isNotEmpty(x.def()), x ->
n.set(x.def()));
+
rstream(pi.getAllAnnotationInfos(Path.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.def())).forEach(x -> n.set(x.def()));
return n;
}
@@ -289,8 +289,8 @@ public class PathAnnotation {
*/
public static Value<String> findName(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(Path.class, x -> isNotEmpty(x.value()), x
-> n.set(x.value()));
- pi.forEachAnnotation(Path.class, x -> isNotEmpty(x.name()), x
-> n.set(x.name()));
+
rstream(pi.getAllAnnotationInfos(Path.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.value())).forEach(x -> n.set(x.value()));
+
rstream(pi.getAllAnnotationInfos(Path.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.name())).forEach(x -> n.set(x.name()));
return n;
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainderAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainderAnnotation.java
index 4eeed77cf8..b248a71f04 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainderAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainderAnnotation.java
@@ -263,7 +263,7 @@ public class PathRemainderAnnotation {
*/
public static Value<String> findDef(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(PathRemainder.class, x ->
isNotEmpty(x.def()), x -> n.set(x.def()));
+
rstream(pi.getAllAnnotationInfos(PathRemainder.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.def())).forEach(x -> n.set(x.def()));
return n;
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
index f45f5b3549..099f970aa1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
@@ -274,7 +274,7 @@ public class QueryAnnotation {
*/
public static Value<String> findDef(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(Query.class, x -> isNotEmpty(x.def()), x
-> n.set(x.def()));
+
rstream(pi.getAllAnnotationInfos(Query.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.def())).forEach(x -> n.set(x.def()));
return n;
}
@@ -286,8 +286,8 @@ public class QueryAnnotation {
*/
public static Value<String> findName(ParameterInfo pi) {
Value<String> n = Value.empty();
- pi.forEachAnnotation(Query.class, x -> isNotEmpty(x.value()), x
-> n.set(x.value()));
- pi.forEachAnnotation(Query.class, x -> isNotEmpty(x.name()), x
-> n.set(x.name()));
+
rstream(pi.getAllAnnotationInfos(Query.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.value())).forEach(x -> n.set(x.value()));
+
rstream(pi.getAllAnnotationInfos(Query.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.name())).forEach(x -> n.set(x.name()));
return n;
}
}
\ No newline at end of file
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 d68094b10e..6eeff5579a 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
@@ -142,8 +142,8 @@ public class ResponseBeanMeta {
return null;
var b = new Builder(annotations);
b.apply(mpi.getParameterType().unwrap(Value.class,
Optional.class).innerType());
- mpi.forEachAnnotation(Response.class, x -> true, x ->
b.apply(x));
- mpi.forEachAnnotation(StatusCode.class, x -> true, x ->
b.apply(x));
+
rstream(mpi.getAllAnnotationInfos(Response.class)).map(AnnotationInfo::inner).forEach(x
-> b.apply(x));
+
rstream(mpi.getAllAnnotationInfos(StatusCode.class)).map(AnnotationInfo::inner).forEach(x
-> b.apply(x));
return b.build();
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/AttributeArg.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/AttributeArg.java
index 56da6fc42b..8010fb1ad0 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/AttributeArg.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/AttributeArg.java
@@ -16,6 +16,7 @@
*/
package org.apache.juneau.rest.arg;
+import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
import org.apache.juneau.common.collections.*;
@@ -76,8 +77,8 @@ public class AttributeArg implements RestOpArg {
private static String getName(ParameterInfo paramInfo) {
Value<String> n = Value.empty();
- paramInfo.forEachAnnotation(Attr.class, x ->
isNotEmpty(x.name()), x -> n.set(x.name()));
- paramInfo.forEachAnnotation(Attr.class, x ->
isNotEmpty(x.value()), x -> n.set(x.value()));
+
rstream(paramInfo.getAllAnnotationInfos(Attr.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.name())).forEach(x -> n.set(x.name()));
+
rstream(paramInfo.getAllAnnotationInfos(Attr.class)).map(AnnotationInfo::inner).filter(x
-> isNotEmpty(x.value())).forEach(x -> n.set(x.value()));
if (n.isEmpty())
throw new ArgException(paramInfo, "@Attr used without
name or value");
return n.get();
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 3fc345fb7d..250dd4e82b 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
@@ -16,6 +16,7 @@
*/
package org.apache.juneau.rest.arg;
+import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.StringUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
@@ -81,7 +82,7 @@ public class HasFormDataArg implements RestOpArg {
*/
protected HasFormDataArg(ParameterInfo pi) {
Value<String> _name = Value.empty();
- pi.forEachAnnotation(HasFormData.class,
HasFormDataArg::hasName, x -> _name.set(getName(x)));
+
rstream(pi.getAllAnnotationInfos(HasFormData.class)).map(AnnotationInfo::inner).filter(HasFormDataArg::hasName).forEach(x
-> _name.set(getName(x)));
this.name = _name.orElseThrow(() -> new ArgException(pi,
"@HasFormData used without name or value"));
this.type = pi.getParameterType().innerType();
}
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 4c27c00a0c..e4da6125c5 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
@@ -16,6 +16,7 @@
*/
package org.apache.juneau.rest.arg;
+import static org.apache.juneau.common.utils.CollectionUtils.*;
import static org.apache.juneau.common.utils.StringUtils.*;
import static org.apache.juneau.common.utils.Utils.*;
@@ -81,7 +82,7 @@ public class HasQueryArg implements RestOpArg {
*/
protected HasQueryArg(ParameterInfo pi) {
Value<String> _name = Value.empty();
- pi.forEachAnnotation(HasQuery.class, HasQueryArg::hasName, x ->
_name.set(getName(x)));
+
rstream(pi.getAllAnnotationInfos(HasQuery.class)).map(AnnotationInfo::inner).filter(HasQueryArg::hasName).forEach(x
-> _name.set(getName(x)));
this.name = _name.orElseThrow(() -> new ArgException(pi,
"@HasQuery used without name or value"));
this.type = pi.getParameterType().innerType();
}
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 354a566085..1acfa0000c 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
@@ -385,8 +385,8 @@ public class BasicSwaggerProviderSession {
if (mpi.hasAnnotation(Content.class) ||
pt.hasAnnotation(Content.class)) {
JsonMap param = paramMap.getMap(BODY +
".body", true).append("in", BODY);
JsonMap schema =
getSchema(param.getMap("schema"), type, bs);
- mpi.forEachAnnotation(Schema.class, x
-> true, x -> merge(schema, x));
- mpi.forEachAnnotation(Content.class, x
-> true, x -> merge(schema, x.schema()));
+
rstream(mpi.getAllAnnotationInfos(Schema.class)).map(AnnotationInfo::inner).forEach(x
-> merge(schema, x));
+
rstream(mpi.getAllAnnotationInfos(Content.class)).map(AnnotationInfo::inner).forEach(x
-> merge(schema, x.schema()));
pushupSchemaFields(BODY, param, schema);
param.appendIf(nem, "schema", schema);
param.putIfAbsent("required", true);
@@ -395,32 +395,32 @@ public class BasicSwaggerProviderSession {
} else if (mpi.hasAnnotation(Query.class) ||
pt.hasAnnotation(Query.class)) {
String name =
QueryAnnotation.findName(mpi).orElse(null);
JsonMap param = paramMap.getMap(QUERY +
"." + name, true).append("name", name).append("in", QUERY);
- mpi.forEachAnnotation(Schema.class, x
-> true, x -> merge(param, x));
- mpi.forEachAnnotation(Query.class, x ->
true, x -> merge(param, x.schema()));
+
rstream(mpi.getAllAnnotationInfos(Schema.class)).map(AnnotationInfo::inner).forEach(x
-> merge(param, x));
+
rstream(mpi.getAllAnnotationInfos(Query.class)).map(AnnotationInfo::inner).forEach(x
-> merge(param, x.schema()));
pushupSchemaFields(QUERY, param,
getSchema(param.getMap("schema"), type, bs));
addParamExample(sm, param, QUERY, type);
} else if (mpi.hasAnnotation(FormData.class) ||
pt.hasAnnotation(FormData.class)) {
String name =
FormDataAnnotation.findName(mpi).orElse(null);
JsonMap param =
paramMap.getMap(FORM_DATA + "." + name, true).append("name", name).append("in",
FORM_DATA);
- mpi.forEachAnnotation(Schema.class, x
-> true, x -> merge(param, x));
- mpi.forEachAnnotation(FormData.class, x
-> true, x -> merge(param, x.schema()));
+
rstream(mpi.getAllAnnotationInfos(Schema.class)).map(AnnotationInfo::inner).forEach(x
-> merge(param, x));
+
rstream(mpi.getAllAnnotationInfos(FormData.class)).map(AnnotationInfo::inner).forEach(x
-> merge(param, x.schema()));
pushupSchemaFields(FORM_DATA, param,
getSchema(param.getMap("schema"), type, bs));
addParamExample(sm, param, FORM_DATA,
type);
} else if (mpi.hasAnnotation(Header.class) ||
pt.hasAnnotation(Header.class)) {
String name =
HeaderAnnotation.findName(mpi).orElse(null);
JsonMap param = paramMap.getMap(HEADER
+ "." + name, true).append("name", name).append("in", HEADER);
- mpi.forEachAnnotation(Schema.class, x
-> true, x -> merge(param, x));
- mpi.forEachAnnotation(Header.class, x
-> true, x -> merge(param, x.schema()));
+
rstream(mpi.getAllAnnotationInfos(Schema.class)).map(AnnotationInfo::inner).forEach(x
-> merge(param, x));
+
rstream(mpi.getAllAnnotationInfos(Header.class)).map(AnnotationInfo::inner).forEach(x
-> merge(param, x.schema()));
pushupSchemaFields(HEADER, param,
getSchema(param.getMap("schema"), type, bs));
addParamExample(sm, param, HEADER,
type);
} else if (mpi.hasAnnotation(Path.class) ||
pt.hasAnnotation(Path.class)) {
String name =
PathAnnotation.findName(mpi).orElse(null);
JsonMap param = paramMap.getMap(PATH +
"." + name, true).append("name", name).append("in", PATH);
- mpi.forEachAnnotation(Schema.class, x
-> true, x -> merge(param, x));
- mpi.forEachAnnotation(Path.class, x ->
true, x -> merge(param, x.schema()));
+
rstream(mpi.getAllAnnotationInfos(Schema.class)).map(AnnotationInfo::inner).forEach(x
-> merge(param, x));
+
rstream(mpi.getAllAnnotationInfos(Path.class)).map(AnnotationInfo::inner).forEach(x
-> merge(param, x.schema()));
pushupSchemaFields(PATH, param,
getSchema(param.getMap("schema"), type, bs));
addParamExample(sm, param, PATH, type);
param.putIfAbsent("required", true);
@@ -521,10 +521,10 @@ public class BasicSwaggerProviderSession {
if (pt.is(Value.class) &&
(mpi.hasAnnotation(Header.class) || pt.hasAnnotation(Header.class))) {
List<Header> la = list();
- mpi.forEachAnnotation(Header.class, x
-> true, x -> la.add(x));
+
rstream(mpi.getAllAnnotationInfos(Header.class)).map(AnnotationInfo::inner).forEach(x
-> la.add(x));
rstream(pt.getAnnotationInfos()).map(x
->
x.cast(Header.class)).filter(Objects::nonNull).map(AnnotationInfo::inner).forEach(x
-> la.add(x));
List<StatusCode> la2 = list();
- mpi.forEachAnnotation(StatusCode.class,
x -> true, x -> la2.add(x));
+
rstream(mpi.getAllAnnotationInfos(StatusCode.class)).map(AnnotationInfo::inner).forEach(x
-> la2.add(x));
rstream(pt.getAnnotationInfos()).map(x
->
x.cast(StatusCode.class)).filter(Objects::nonNull).map(AnnotationInfo::inner).forEach(x
-> la2.add(x));
Set<Integer> codes = getCodes(la2, 200);
String name =
HeaderAnnotation.findName(mpi).orElse(null);
@@ -533,19 +533,19 @@ public class BasicSwaggerProviderSession {
if (! isMulti(a)) {
for (var code : codes) {
JsonMap header
= responses.getMap(String.valueOf(code), true).getMap("headers",
true).getMap(name, true);
-
mpi.forEachAnnotation(Schema.class, x -> true, x -> merge(header, x));
+
rstream(mpi.getAllAnnotationInfos(Schema.class)).map(AnnotationInfo::inner).forEach(x
-> merge(header, x));
merge(header,
a.schema());
pushupSchemaFields(RESPONSE_HEADER, header, getSchema(header, type, bs));
}
}
}
-
+
} else if (mpi.hasAnnotation(Response.class) ||
pt.hasAnnotation(Response.class)) {
List<Response> la = list();
- mpi.forEachAnnotation(Response.class, x
-> true, x -> la.add(x));
+
rstream(mpi.getAllAnnotationInfos(Response.class)).map(AnnotationInfo::inner).forEach(x
-> la.add(x));
rstream(pt.getAnnotationInfos()).map(x
->
x.cast(Response.class)).filter(Objects::nonNull).map(AnnotationInfo::inner).forEach(x
-> la.add(x));
List<StatusCode> la2 = list();
- mpi.forEachAnnotation(StatusCode.class,
x -> true, x -> la2.add(x));
+
rstream(mpi.getAllAnnotationInfos(StatusCode.class)).map(AnnotationInfo::inner).forEach(x
-> la2.add(x));
rstream(pt.getAnnotationInfos()).map(x
->
x.cast(StatusCode.class)).filter(Objects::nonNull).map(AnnotationInfo::inner).forEach(x
-> la2.add(x));
Set<Integer> codes = getCodes(la2, 200);
Type type =
Value.unwrap(mpi.getParameterType().innerType());
@@ -554,7 +554,7 @@ public class BasicSwaggerProviderSession {
JsonMap om =
responses.getMap(String.valueOf(code), true);
merge(om, a);
JsonMap schema =
getSchema(om.getMap("schema"), type, bs);
-
mpi.forEachAnnotation(Schema.class, x -> true, x -> merge(schema, x));
+
rstream(mpi.getAllAnnotationInfos(Schema.class)).map(AnnotationInfo::inner).forEach(x
-> merge(schema, x));
la.forEach(x ->
merge(schema, x.schema()));
pushupSchemaFields(RESPONSE, om, schema);
om.appendIf(nem,
"schema", schema);
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 c0fd4e45a1..c12d1fb597 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
@@ -819,7 +819,7 @@ class ParamInfoTest extends TestBase {
private static <T extends Annotation> List<T> annotations(ParameterInfo
pi, Class<T> a) {
List<T> l = list();
- pi.forEachAnnotation(a, x -> true, l::add);
+
rstream(pi.getAllAnnotationInfos(a)).map(AnnotationInfo::inner).forEach(l::add);
return l;
}
}
\ No newline at end of file
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 9f88db14e8..e0ec44aefd 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
@@ -358,7 +358,7 @@ class ParamInfoTest extends TestBase {
private static <T extends Annotation> List<T> annotations(ParameterInfo
pi, Class<T> a) {
List<T> l = list();
- pi.forEachAnnotation(a, x -> true, l::add);
+
rstream(pi.getAllAnnotationInfos(a)).map(AnnotationInfo::inner).forEach(l::add);
return l;
}
}
\ No newline at end of file