[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

@@ -53,13 +53,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 + "'");
}
}
@@ -91,13 +91,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

@@ -47,13 +47,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

@@ -54,13 +54,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 + "'");
}
}
@@ -94,13 +94,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 + "'");
}
}
@@ -132,13 +132,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 + "'");
}
}
@@ -170,13 +170,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

@@ -57,13 +57,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

@@ -66,13 +66,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

@@ -47,13 +47,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

@@ -72,13 +72,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 + "'");
}
}