Skip to content

Commit f5cd81d

Browse files
Fix complex (non-scalar) input collections in Java
1 parent 2281c25 commit f5cd81d

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

packages/plugins/java/java/src/visitor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,15 @@ export class JavaResolversVisitor extends BaseVisitor<
237237
}
238238
return indentMultiline(
239239
`if (args.get("${arg.name.value}") != null) {
240-
this.${arg.name.value} = (${this.config.listType}<${typeToUse.baseType}>) args.get("${arg.name.value}");
240+
this.${arg.name.value} = new ArrayList<${typeToUse.baseType}>();
241+
for (var o : (${this.config.listType}) args.get("${arg.name.value}")) {
242+
if (o != null) {
243+
this.${arg.name.value}.add(new ${typeToUse.baseType}(o));
244+
}
245+
else {
246+
this.${arg.name.value}.add(null);
247+
}
248+
}
241249
}`,
242250
3,
243251
);

packages/plugins/java/java/tests/java.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,15 @@ describe('Java', () => {
158158
if (args != null) {
159159
this.f = (Iterable<String>) args.get("f");
160160
if (args.get("g") != null) {
161-
this.g = (Iterable<SearchUserInput>) args.get("g");
161+
this.g = new ArrayList<SearchUserInput>();
162+
for (var o : (Iterable) args.get("g")) {
163+
if (o != null) {
164+
this.g.add(new SearchUserInput(o));
165+
}
166+
else {
167+
this.g.add(null);
168+
}
169+
}
162170
}
163171
}
164172
}

0 commit comments

Comments
 (0)