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

Fix for regression in issue #6472 #6480

Merged
merged 1 commit into from
Oct 9, 2017
Merged
Show file tree
Hide file tree
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 @@ -639,7 +639,16 @@ public String toDefaultValue(Property p) {
return null;
}

return String.format(pattern, getTypeDeclaration(ap.getItems()));
String typeDeclaration = getTypeDeclaration(ap.getItems());
Object java8obj = additionalProperties.get("java8");
if (java8obj != null) {
Boolean java8 = Boolean.valueOf(java8obj.toString());
if (java8 != null && java8) {
typeDeclaration = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JFCote What about returning earlier here with return String.format(pattern, "")?

For the return below (line 651), we keep the original one return String.format(pattern, getTypeDeclaration(ap.getItems())); Would that work for both Play and RestEasy generator?

cc @daveish

Copy link
Contributor Author

@JFCote JFCote Sep 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wing328 I can change it if you want, I learn the old school way of not having too much return in a function (even if that was only required in the old days). Let me know if you want me to change it.

As for the line 651, it's the exact same return as before. It's just that I have declared typeDeclaration on line 642. We change it to "" only if java8 is set to true.

}
}

return String.format(pattern, typeDeclaration);
} else if (p instanceof MapProperty) {
final MapProperty ap = (MapProperty) p;
final String pattern;
Expand All @@ -652,7 +661,16 @@ public String toDefaultValue(Property p) {
return null;
}

return String.format(pattern, String.format("String, %s", getTypeDeclaration(ap.getAdditionalProperties())));
String typeDeclaration = String.format("String, %s", getTypeDeclaration(ap.getAdditionalProperties()));
Object java8obj = additionalProperties.get("java8");
if (java8obj != null) {
Boolean java8 = Boolean.valueOf(java8obj.toString());
if (java8 != null && java8) {
typeDeclaration = "";
}
}

return String.format(pattern, typeDeclaration);
} else if (p instanceof IntegerProperty) {
IntegerProperty dp = (IntegerProperty) p;
if (dp.getDefault() != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#isBoolean}}Boolean.valueOf({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isUuid}}UUID.fromString({{/isUuid}}{{#isDateTime}}OffsetDateTime.parse({{/isDateTime}}
{{#isBoolean}}Boolean.valueOf({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isUuid}}UUID.fromString({{/isUuid}}{{#isDateTime}}OffsetDateTime.parse({{/isDateTime}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#isBoolean}}){{/isBoolean}}{{#isInteger}}){{/isInteger}}{{#isDouble}}){{/isDouble}}{{#isLong}}){{/isLong}}{{#isFloat}}){{/isFloat}}{{#isUuid}}){{/isUuid}}{{#isDateTime}}){{/isDateTime}}
{{#isBoolean}}){{/isBoolean}}{{#isInteger}}){{/isInteger}}{{#isDouble}}){{/isDouble}}{{#isLong}}){{/isLong}}{{#isFloat}}){{/isFloat}}{{#isUuid}}){{/isUuid}}{{#isDateTime}}){{/isDateTime}}
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
Expand Down