Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove needless toString convert #8092

Merged
merged 1 commit into from Jun 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -197,7 +197,7 @@ private static Object generalize(Object pojo, Map<Object, Object> history) {
if (history.containsKey(pojo)) {
Object pojoGeneralizedValue = history.get(pojo);
if (pojoGeneralizedValue instanceof Map
&& ((Map) pojoGeneralizedValue).containsKey(field.getName())) {
&& ((Map) pojoGeneralizedValue).containsKey(field.getName())) {
continue;
}
}
Expand Down Expand Up @@ -321,9 +321,9 @@ private static Object realize0(Object pojo, Class<?> type, Type genericType, fin
}

if (ReflectUtils.isPrimitives(pojo.getClass())
&& !(type != null && type.isArray()
&& type.getComponentType().isEnum()
&& pojo.getClass() == String[].class)) {
&& !(type != null && type.isArray()
&& type.getComponentType().isEnum()
&& pojo.getClass() == String[].class)) {
return CompatibleTypeUtils.compatibleTypeConvert(pojo, type);
}

Expand Down Expand Up @@ -412,7 +412,11 @@ private static Object realize0(Object pojo, Class<?> type, Type genericType, fin
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);
}
}
}

Expand All @@ -422,8 +426,8 @@ private static Object realize0(Object pojo, Class<?> type, Type genericType, fin
Type mapKeyType = getKeyTypeForMap(map.getClass());
Type typeKeyType = getGenericClassByIndex(genericType, 0);
boolean typeMismatch = mapKeyType instanceof Class
&& typeKeyType instanceof Class
&& !typeKeyType.getTypeName().equals(mapKeyType.getTypeName());
&& typeKeyType instanceof Class
&& !typeKeyType.getTypeName().equals(mapKeyType.getTypeName());
if (typeMismatch) {
result = createMap(new HashMap(0));
} else {
Expand Down Expand Up @@ -477,7 +481,7 @@ private static Object realize0(Object pojo, Class<?> type, Type genericType, fin
method.invoke(dest, value);
} catch (Exception e) {
String exceptionDescription = "Failed to set pojo " + dest.getClass().getSimpleName() + " property " + name
+ " value " + value + "(" + value.getClass() + "), cause: " + e.getMessage();
+ " value " + value.getClass() + ", cause: " + e.getMessage();
logger.error(exceptionDescription, e);
throw new RuntimeException(exceptionDescription, e);
}
Expand Down Expand Up @@ -658,8 +662,8 @@ private static Field getField(Class<?> cls, String fieldName) {

public static boolean isPojo(Class<?> cls) {
return !ReflectUtils.isPrimitives(cls)
&& !Collection.class.isAssignableFrom(cls)
&& !Map.class.isAssignableFrom(cls);
&& !Collection.class.isAssignableFrom(cls)
&& !Map.class.isAssignableFrom(cls);
}

/**
Expand Down