[bug][Java] Honor instantiationMap for default values for array, map, set (#4982)

Co-authored-by: Jim Schubert <james.schubert@gmail.com>
This commit is contained in:
Marvin1912 2020-09-25 05:25:13 +02:00 committed by GitHub
parent 9778d970ac
commit 5f3d974a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -807,17 +807,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
if (ModelUtils.isArraySchema(schema)) {
final String pattern;
if (ModelUtils.isSet(schema)) {
if (fullJavaUtil) {
pattern = "new java.util.LinkedHashSet<%s>()";
} else {
pattern = "new LinkedHashSet<%s>()";
}
String mapInstantiationType = instantiationTypes().getOrDefault("set", "LinkedHashSet");
pattern = "new " + mapInstantiationType + "<%s>()";
} else {
if (fullJavaUtil) {
pattern = "new java.util.ArrayList<%s>()";
} else {
pattern = "new ArrayList<%s>()";
}
String arrInstantiationType = instantiationTypes().getOrDefault("array", "ArrayList");
pattern = "new " + arrInstantiationType + "<%s>()";
}
Schema<?> items = getSchemaItems((ArraySchema) schema);
@ -840,12 +834,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
return null;
}
final String pattern;
if (fullJavaUtil) {
pattern = "new java.util.HashMap<%s>()";
} else {
pattern = "new HashMap<%s>()";
}
String mapInstantiationType = instantiationTypes().getOrDefault("map", "HashMap");
final String pattern = "new " + mapInstantiationType + "<%s>()";
if (getAdditionalProperties(schema) == null) {
return null;
}