Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -807,17 +807,11 @@ public String toDefaultValue(Schema schema) {
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);
Expand All @@ -840,12 +834,10 @@ public String toDefaultValue(Schema schema) {
}
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;
}
Expand Down