Skip to content

Commit

Permalink
Replaced ArrayList and HashMap pattern with generic one
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin1912 committed Jan 12, 2020
1 parent b680d7c commit aacb4f3
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,8 @@ public String getAlias(String name) {
public String toDefaultValue(Schema p) {
p = ModelUtils.getReferencedSchema(this.openAPI, p);
if (ModelUtils.isArraySchema(p)) {
final String pattern;
if (fullJavaUtil) {
pattern = "new java.util.ArrayList<%s>()";
} else {
pattern = "new ArrayList<%s>()";
}

final String pattern = "new " + instantiationTypes().get("array") + "<%s>()";

Schema<?> items = getSchemaItems((ArraySchema) p);

Expand All @@ -779,12 +775,9 @@ public String toDefaultValue(Schema p) {

return String.format(Locale.ROOT, pattern, typeDeclaration);
} else if (ModelUtils.isMapSchema(p)) {
final String pattern;
if (fullJavaUtil) {
pattern = "new java.util.HashMap<%s>()";
} else {
pattern = "new HashMap<%s>()";
}

final String pattern = "new " + instantiationTypes().get("map") + "<%s>()";

if (ModelUtils.getAdditionalProperties(p) == null) {
return null;
}
Expand Down

0 comments on commit aacb4f3

Please sign in to comment.