Skip to content

Commit

Permalink
Remove needless toString convert (#8093)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ committed Jun 18, 2021
1 parent fc1bdfa commit 3f1e3f4
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -382,8 +382,10 @@ private static Object realize0(Object pojo, Class<?> type, Type genericType, fin
// special logic for enum
if (type.isEnum()) {
Object name = ((Map<Object, Object>) pojo).get("name");
if (name != null) {
return Enum.valueOf((Class<Enum>) type, name.toString());
if (!(name instanceof String)) {
throw new IllegalArgumentException("`name` filed should be string!");
} else {
return Enum.valueOf((Class<Enum>) type, (String) name);
}
}
Map<Object, Object> map;
Expand Down Expand Up @@ -455,7 +457,7 @@ private static Object realize0(Object pojo, Class<?> type, Type genericType, fin
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Failed to set pojo " + dest.getClass().getSimpleName() + " property " + name
+ " value " + value + "(" + value.getClass() + "), cause: " + e.getMessage(), e);
+ " value " + value.getClass() + ", cause: " + e.getMessage(), e);
}
} else if (field != null) {
value = realize0(value, field.getType(), field.getGenericType(), history);
Expand Down

0 comments on commit 3f1e3f4

Please sign in to comment.