Skip to content

Commit 64e9322

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

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

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

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
package io.avaje.http.generator.core;
22

3-
import static io.avaje.http.generator.core.ParamType.RESPONSE_HANDLER;
3+
import io.avaje.http.api.*;
4+
import io.avaje.http.generator.core.openapi.MethodDocBuilder;
5+
import io.avaje.http.generator.core.openapi.MethodParamDocBuilder;
46

57
import javax.lang.model.element.Element;
8+
import javax.lang.model.element.TypeElement;
69
import javax.validation.Valid;
710

8-
import io.avaje.http.api.BeanParam;
9-
import io.avaje.http.api.Cookie;
10-
import io.avaje.http.api.Default;
11-
import io.avaje.http.api.Form;
12-
import io.avaje.http.api.FormParam;
13-
import io.avaje.http.api.Header;
14-
import io.avaje.http.api.QueryParam;
15-
import io.avaje.http.generator.core.openapi.MethodDocBuilder;
16-
import io.avaje.http.generator.core.openapi.MethodParamDocBuilder;
11+
import static io.avaje.http.generator.core.ParamType.RESPONSE_HANDLER;
1712

1813
public class ElementReader {
1914

@@ -206,7 +201,8 @@ void writeCtxGet(Append writer, PathSegments segments) {
206201
// no conversion for this parameter
207202
return;
208203
}
209-
if (paramType == ParamType.BODY && ctx.platform().isBodyMethodParam()) { // body passed as method parameter (Helidon)
204+
if (paramType == ParamType.BODY && ctx.platform().isBodyMethodParam()) {
205+
// body passed as method parameter (Helidon)
210206
return;
211207
}
212208
String shortType = shortType();
@@ -256,7 +252,7 @@ private boolean setValue(Append writer, PathSegments segments, String shortType)
256252
}
257253
}
258254

259-
final var asMethod = (typeHandler == null) ? null : typeHandler.toMethod();
255+
String asMethod = (typeHandler == null) ? null : typeHandler.toMethod();
260256
if (asMethod != null) {
261257
writer.append(asMethod);
262258
}
@@ -265,17 +261,19 @@ private boolean setValue(Append writer, PathSegments segments, String shortType)
265261
// this is a body (POST, PATCH)
266262
writer.append(ctx.platform().bodyAsClass(type));
267263

268-
}else if (hasParamDefault()) {
269-
ctx.platform().writeReadParameter(writer, paramType, paramName, paramDefault);
270264
} else {
271-
final var checkNull = notNullKotlin || (paramType == ParamType.FORMPARAM && typeHandler.isPrimitive());
272-
if (checkNull) {
273-
writer.append("checkNull(");
274-
}
275-
ctx.platform().writeReadParameter(writer, paramType, paramName);
276-
//writer.append("ctx.%s(\"%s\")", paramType, paramName);
277-
if (checkNull) {
278-
writer.append(", \"%s\")", paramName);
265+
if (hasParamDefault()) {
266+
ctx.platform().writeReadParameter(writer, paramType, paramName, paramDefault);
267+
} else {
268+
boolean checkNull = notNullKotlin || (paramType == ParamType.FORMPARAM && typeHandler.isPrimitive());
269+
if (checkNull) {
270+
writer.append("checkNull(");
271+
}
272+
ctx.platform().writeReadParameter(writer, paramType, paramName);
273+
//writer.append("ctx.%s(\"%s\")", paramType, paramName);
274+
if (checkNull) {
275+
writer.append(", \"%s\")", paramName);
276+
}
279277
}
280278
}
281279

0 commit comments

Comments
 (0)