@@ -68,13 +68,13 @@ protected void deserializeCollection(GenerationContext context, CollectionShape
68
68
// Dispatch to the output value provider for any additional handling.
69
69
writer .write ("const contents: any = [];" );
70
70
writer .openBlock ("(output || []).map((entry: any) => {" , "});" , () -> {
71
- String dataSource = handleUnnamedTargetWrapping (context , target , "entry" );
71
+ String dataSource = getUnnamedTargetWrapper (context , target , "entry" );
72
72
writer .write ("contents.push($L);" , target .accept (getMemberVisitor (dataSource )));
73
73
});
74
74
writer .write ("return contents;" );
75
75
}
76
76
77
- private String handleUnnamedTargetWrapping (GenerationContext context , Shape target , String dataSource ) {
77
+ private String getUnnamedTargetWrapper (GenerationContext context , Shape target , String dataSource ) {
78
78
if (!deserializationReturnsArray (target )) {
79
79
return dataSource ;
80
80
}
@@ -85,8 +85,7 @@ private String handleUnnamedTargetWrapping(GenerationContext context, Shape targ
85
85
// return multiple entries but only has one.
86
86
// Update the target element if we target another level of collection.
87
87
String targetLocation = getUnnamedAggregateTargetLocation (context .getModel (), target );
88
- writer .write ("const wrappedItem = __getArrayIfSingleItem($1L[$2S]);" , dataSource , targetLocation );
89
- return "wrappedItem" ;
88
+ return String .format ("__getArrayIfSingleItem(%s[\" %s\" ])" , dataSource , targetLocation );
90
89
}
91
90
92
91
private boolean deserializationReturnsArray (Shape shape ) {
@@ -112,7 +111,7 @@ protected void deserializeMap(GenerationContext context, MapShape shape) {
112
111
writer .write ("const mapParams: any = {};" );
113
112
writer .openBlock ("output.forEach((pair: any) => {" , "});" , () -> {
114
113
// Dispatch to the output value provider for any additional handling.
115
- String dataSource = handleUnnamedTargetWrapping (context , target , "pair[\" " + valueLocation + "\" ]" );
114
+ String dataSource = getUnnamedTargetWrapper (context , target , "pair[\" " + valueLocation + "\" ]" );
116
115
writer .write ("mapParams[pair[$S]] = $L;" , keyLocation , target .accept (getMemberVisitor (dataSource )));
117
116
});
118
117
writer .write ("return mapParams;" );
@@ -212,12 +211,12 @@ void deserializeNamedMember(
212
211
.map (location -> location + " !== undefined" )
213
212
.collect (Collectors .joining (" && " ));
214
213
writer .openBlock ("if ($L) {" , "}" , validationStatement , () -> {
215
- String dataSource = handleNamedTargetWrapping (context , target , source );
214
+ String dataSource = getNamedTargetWrapper (context , target , source );
216
215
statementBodyGenerator .accept (dataSource , getMemberVisitor (dataSource ));
217
216
});
218
217
}
219
218
220
- private String handleNamedTargetWrapping (GenerationContext context , Shape target , String dataSource ) {
219
+ private String getNamedTargetWrapper (GenerationContext context , Shape target , String dataSource ) {
221
220
if (!deserializationReturnsArray (target )) {
222
221
return dataSource ;
223
222
}
@@ -226,8 +225,7 @@ private String handleNamedTargetWrapping(GenerationContext context, Shape target
226
225
writer .addImport ("getArrayIfSingleItem" , "__getArrayIfSingleItem" , "@aws-sdk/smithy-client" );
227
226
// The XML parser will set one K:V for a member that could
228
227
// return multiple entries but only has one.
229
- writer .write ("const wrappedItem = __getArrayIfSingleItem($1L)" , dataSource );
230
- return "wrappedItem" ;
228
+ return String .format ("__getArrayIfSingleItem(%s)" , dataSource );
231
229
}
232
230
233
231
private String getUnnamedAggregateTargetLocation (Model model , Shape shape ) {
0 commit comments