Skip to content

Commit 20267f4

Browse files
committed
Update ElementReader.java
1 parent b052639 commit 20267f4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

http-generator-core/src/main/java/io/avaje/http/generator/core/ElementReader.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ private void readAnnotations(Element element, ParamType defaultType) {
8181
}
8282
Form form = element.getAnnotation(Form.class);
8383
if (form != null) {
84-
paramType = ParamType.FORM;
84+
this.paramType = ParamType.FORM;
8585
return;
8686
}
87-
BeanParam beanParam = element.getAnnotation(BeanParam.class);
87+
BeanParam beanParam = element.getAnnotation(BeanParam.class);
8888
if (beanParam != null) {
8989
this.paramType = ParamType.BEANPARAM;
9090
return;
@@ -108,7 +108,7 @@ private void readAnnotations(Element element, ParamType defaultType) {
108108
this.paramDefault = null;
109109
return;
110110
}
111-
final var headerParam = element.getAnnotation(Header.class);
111+
Header headerParam = element.getAnnotation(Header.class);
112112
if (headerParam != null) {
113113
this.paramName = nameFrom(headerParam.value(), Util.initcapSnake(snakeName));
114114
this.paramType = ParamType.HEADER;
@@ -164,7 +164,7 @@ private String shortType() {
164164

165165
void addImports(ControllerReader bean) {
166166
if (typeHandler != null) {
167-
final var importType = typeHandler.getImportType();
167+
String importType = typeHandler.getImportType();
168168
if (importType != null) {
169169
bean.addImportType(rawType);
170170
}
@@ -202,11 +202,14 @@ void writeValidate(Append writer) {
202202
}
203203

204204
void writeCtxGet(Append writer, PathSegments segments) {
205-
if (isPlatformContext() || (paramType == ParamType.BODY && ctx.platform().isBodyMethodParam())) {
206-
// body passed as method parameter (Helidon)
205+
if (isPlatformContext()) {
206+
// no conversion for this parameter
207+
return;
208+
}
209+
if (paramType == ParamType.BODY && ctx.platform().isBodyMethodParam()) { // body passed as method parameter (Helidon)
207210
return;
208211
}
209-
final var shortType = shortType();
212+
String shortType = shortType();
210213
writer.append("%s var %s = ", ctx.platform().indent(), varName);
211214
if (setValue(writer, segments, shortType)) {
212215
writer.append(";").eol();
@@ -236,11 +239,11 @@ private boolean setValue(Append writer, PathSegments segments, String shortType)
236239
return false;
237240
}
238241
if (impliedParamType) {
239-
final var segment = segments.segment(varName);
242+
PathSegments.Segment segment = segments.segment(varName);
240243
if (segment != null) {
241244
// path or matrix parameter
242-
final var requiredParam = segment.isRequired(varName);
243-
final var asMethod = (typeHandler == null) ? null : (requiredParam) ? typeHandler.asMethod() : typeHandler.toMethod();
245+
boolean requiredParam = segment.isRequired(varName);
246+
String asMethod = (typeHandler == null) ? null : (requiredParam) ? typeHandler.asMethod() : typeHandler.toMethod();
244247
if (asMethod != null) {
245248
writer.append(asMethod);
246249
}

0 commit comments

Comments
 (0)