Skip to content

Commit 065a98c

Browse files
author
Sergio Bilello
committed
fix enum type generators template
s f5aa34d revert version change s b2fdf56 wrap any value to a String on the JsonAdapter wrap any value to a String on the JsonAdapter
1 parent 2d83daa commit 065a98c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/resources/handlebars/Java/modelEnum.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum
4444
{{#jackson}}
4545
@JsonCreator
4646
{{/jackson}}
47-
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
47+
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} input) {
4848
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
49-
if (String.valueOf(b.value).equals(text)) {
49+
if (b.value.equals(input)) {
5050
return b;
5151
}
5252
}
@@ -57,7 +57,7 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum
5757
public static class Adapter extends TypeAdapter<{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}> {
5858
@Override
5959
public void write(final JsonWriter jsonWriter, final {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} enumeration) throws IOException {
60-
jsonWriter.value(enumeration.getValue());
60+
jsonWriter.value(String.valueOf(enumeration.getValue()));
6161
}
6262

6363
@Override

src/main/resources/handlebars/Java/modelInnerEnum.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
{{#jackson}}
2929
@JsonCreator
3030
{{/jackson}}
31-
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
31+
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{datatype}}} input) {
3232
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
33-
if (String.valueOf(b.value).equals(text)) {
33+
if (b.value.equals(input)) {
3434
return b;
3535
}
3636
}
@@ -40,7 +40,7 @@
4040
public static class Adapter extends TypeAdapter<{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}> {
4141
@Override
4242
public void write(final JsonWriter jsonWriter, final {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} enumeration) throws IOException {
43-
jsonWriter.value(enumeration.getValue());
43+
jsonWriter.value(String.valueOf(enumeration.getValue()));
4444
}
4545

4646
@Override

0 commit comments

Comments
 (0)