[JAVA] Use specified data type in enum's fromValue instead of string (#2347)

* Use specified data type in enum's fromValue instead of string

* updated samples

* update samples

* remoe String.valueOf
This commit is contained in:
Lukáš Vasek
2019-03-27 15:10:02 +01:00
committed by William Cheng
parent 74fbd3454b
commit a079f70fb2
326 changed files with 1529 additions and 1529 deletions

View File

@@ -38,13 +38,13 @@ public class EnumArrays {
}
@JsonCreator
public static JustSymbolEnum fromValue(String text) {
public static JustSymbolEnum fromValue(String value) {
for (JustSymbolEnum b : JustSymbolEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
@@ -72,13 +72,13 @@ public class EnumArrays {
}
@JsonCreator
public static ArrayEnumEnum fromValue(String text) {
public static ArrayEnumEnum fromValue(String value) {
for (ArrayEnumEnum b : ArrayEnumEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

View File

@@ -32,13 +32,13 @@ public enum EnumClass {
}
@JsonCreator
public static EnumClass fromValue(String text) {
public static EnumClass fromValue(String value) {
for (EnumClass b : EnumClass.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

View File

@@ -39,13 +39,13 @@ public class EnumTest {
}
@JsonCreator
public static EnumStringEnum fromValue(String text) {
public static EnumStringEnum fromValue(String value) {
for (EnumStringEnum b : EnumStringEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
@@ -75,13 +75,13 @@ public class EnumTest {
}
@JsonCreator
public static EnumStringRequiredEnum fromValue(String text) {
public static EnumStringRequiredEnum fromValue(String value) {
for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
@@ -109,13 +109,13 @@ public class EnumTest {
}
@JsonCreator
public static EnumIntegerEnum fromValue(String text) {
public static EnumIntegerEnum fromValue(Integer value) {
for (EnumIntegerEnum b : EnumIntegerEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
@@ -143,13 +143,13 @@ public class EnumTest {
}
@JsonCreator
public static EnumNumberEnum fromValue(String text) {
public static EnumNumberEnum fromValue(Double value) {
for (EnumNumberEnum b : EnumNumberEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

View File

@@ -43,13 +43,13 @@ public class MapTest {
}
@JsonCreator
public static InnerEnum fromValue(String text) {
public static InnerEnum fromValue(String value) {
for (InnerEnum b : InnerEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

View File

@@ -51,13 +51,13 @@ public class Order {
}
@JsonCreator
public static StatusEnum fromValue(String text) {
public static StatusEnum fromValue(String value) {
for (StatusEnum b : StatusEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

View File

@@ -32,13 +32,13 @@ public enum OuterEnum {
}
@JsonCreator
public static OuterEnum fromValue(String text) {
public static OuterEnum fromValue(String value) {
for (OuterEnum b : OuterEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

View File

@@ -59,13 +59,13 @@ public class Pet {
}
@JsonCreator
public static StatusEnum fromValue(String text) {
public static StatusEnum fromValue(String value) {
for (StatusEnum b : StatusEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}