@@ -269,32 +269,33 @@ private void useCreatorsForInterfaceSubtypes( @Nonnull final CodegenModel m )
269
269
return ;
270
270
}
271
271
boolean useCreators = false ;
272
+ final var LIST_TYPE_PREFIX = "List<" ;
272
273
for ( final Set <String > candidates : List .of (m .anyOf , m .oneOf ) ) {
273
274
int nonPrimitives = 0 ;
274
- final var candidatesSingle = new HashSet <String >();
275
- final var candidatesMultiple1D = new HashSet <String >();
276
- final var candidatesMultipleND = new HashSet <Map <String , String >>();
275
+ final var singleTypes = new HashSet <String >();
276
+ final var arrayTypes1D = new HashSet <String >();
277
+ final var arrayTypesND = new HashSet <Map <String , String >>();
277
278
278
279
for ( final String candidate : candidates ) {
279
- if ( candidate .startsWith ("List<" ) ) {
280
+ if ( candidate .startsWith (LIST_TYPE_PREFIX ) ) {
280
281
int depth = 0 ;
281
282
String sub = candidate ;
282
- while ( sub .startsWith ("List<" ) ) {
283
+ while ( sub .startsWith (LIST_TYPE_PREFIX ) ) {
283
284
sub = sub .substring (5 , sub .length () - 1 );
284
285
depth ++;
285
286
}
286
287
287
288
final String innerType = sub ;
288
289
if ( depth == 1 ) {
289
- candidatesMultiple1D .add (innerType );
290
+ arrayTypes1D .add (innerType );
290
291
} else {
291
- candidatesMultipleND
292
+ arrayTypesND
292
293
.add (Map .of ("innerType" , innerType , "depth" , String .valueOf (depth ), "fullType" , candidate ));
293
294
}
294
295
295
296
useCreators = true ;
296
297
} else {
297
- candidatesSingle .add (candidate );
298
+ singleTypes .add (candidate );
298
299
useCreators |= PRIMITIVES .contains (candidate );
299
300
if ( !PRIMITIVES .contains (candidate ) ) {
300
301
nonPrimitives ++;
@@ -307,7 +308,7 @@ private void useCreatorsForInterfaceSubtypes( @Nonnull final CodegenModel m )
307
308
"Generating interface with mixed multiple non-primitive and primitive sub-types: {}. Deserialization may not work." ;
308
309
log .warn (msg , m .name );
309
310
}
310
- final var numArrayTypes = candidatesSingle .size () + candidatesMultipleND .size ();
311
+ final var numArrayTypes = singleTypes .size () + arrayTypesND .size ();
311
312
if ( numArrayTypes > 1 ) {
312
313
final var msg =
313
314
"Field can be oneOf %d array types. Deserialization may not work as expected."
@@ -320,11 +321,11 @@ private void useCreatorsForInterfaceSubtypes( @Nonnull final CodegenModel m )
320
321
Map
321
322
.of (
322
323
"single" ,
323
- candidatesSingle ,
324
+ singleTypes ,
324
325
"multiple1D" ,
325
- candidatesMultiple1D ,
326
+ arrayTypes1D ,
326
327
"multipleND" ,
327
- candidatesMultipleND );
328
+ arrayTypesND );
328
329
m .vendorExtensions .put ("x-monads" , monads );
329
330
m .vendorExtensions .put ("x-is-one-of-interface" , true ); // enforce template usage
330
331
}
0 commit comments