Skip to content

Commit 2875ce6

Browse files
committed
Update ElementReader.java
1 parent b3eac31 commit 2875ce6

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public class ElementReader {
3838
private boolean isParamCollection;
3939
private boolean isParamMap;
4040
private final Set<String> imports = new HashSet<>();
41-
private BeanParamReader formBeanReader;
4241

4342
ElementReader(Element element, ParamType defaultType, boolean formMarker) {
4443
this(element, null, Util.typeDef(element.asType()), defaultType, formMarker);
@@ -76,8 +75,8 @@ public class ElementReader {
7675
useValidation = false;
7776
}
7877
if (ParamType.FORM == paramType || ParamType.BEANPARAM == paramType) {
79-
this.formBeanReader = getFormBeanReader(rawType, rawType, paramType);
80-
this.imports.addAll(formBeanReader.imports());
78+
this.imports.addAll(
79+
new BeanParamReader(typeElement(rawType), varName, shortType, paramType).imports());
8180
}
8281
}
8382

@@ -294,9 +293,21 @@ void setValue(Append writer) {
294293
}
295294

296295
private boolean setValue(Append writer, PathSegments segments, String shortType) {
297-
298-
if ((ParamType.FORM == paramType) || (ParamType.BEANPARAM == paramType)) {
299-
formBeanReader.write(writer);
296+
// if (formMarker && impliedParamType && typeHandler == null) {
297+
// if (ParamType.FORM != paramType) {
298+
// throw new IllegalStateException("Don't get here?");
299+
// }
300+
//// // @Form on method and this type is a "bean" so treat is as a form bean
301+
//// writeForm(writer, shortType, varName, ParamType.FORMPARAM);
302+
//// paramType = ParamType.FORM;
303+
//// return false;
304+
// }
305+
if (ParamType.FORM == paramType) {
306+
writeForm(writer, shortType, varName, ParamType.FORMPARAM);
307+
return false;
308+
}
309+
if (ParamType.BEANPARAM == paramType) {
310+
writeForm(writer, shortType, varName, ParamType.QUERYPARAM);
300311
return false;
301312
}
302313
if (impliedParamType) {
@@ -359,10 +370,10 @@ private boolean setValue(Append writer, PathSegments segments, String shortType)
359370
return true;
360371
}
361372

362-
private BeanParamReader getFormBeanReader(
363-
String shortType, String varName, ParamType defaultParamType) {
364-
final TypeElement formBeanType = typeElement(rawType);
365-
return new BeanParamReader(formBeanType, varName, shortType, defaultParamType);
373+
private void writeForm(Append writer, String shortType, String varName, ParamType defaultParamType) {
374+
TypeElement formBeanType = typeElement(rawType);
375+
BeanParamReader form = new BeanParamReader(formBeanType, varName, shortType, defaultParamType);
376+
form.write(writer);
366377
}
367378

368379
public ParamType paramType() {

0 commit comments

Comments
 (0)