Skip to content

Commit 587688c

Browse files
committed
refactoring
1 parent 5f3df0e commit 587688c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lambda-local/src/main/java/com/zaoo/lambda/rest/JsonRestParamDeserializer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public Object deserialize(String str, JavaType javaType) {
3434
return Boolean.parseBoolean(str);
3535
}
3636
if (Enum.class.isAssignableFrom(javaType.getRawClass())) {
37-
return Enum.valueOf((Class) javaType.getRawClass(), str);
37+
Class<?> rawClass = javaType.getRawClass();
38+
return toEnum(str, rawClass);
3839
}
3940

4041
try {
@@ -46,4 +47,8 @@ public Object deserialize(String str, JavaType javaType) {
4647

4748
throw new IllegalArgumentException("Unable to get RestParamDeserializer of this type:" + javaType);
4849
}
50+
51+
private Enum toEnum(String str, Class rawClass) {
52+
return Enum.valueOf(rawClass, str);
53+
}
4954
}

0 commit comments

Comments
 (0)