Commit a67f26cd by s_guodong

解决int.toString问题

parent cc45ff1a
......@@ -387,8 +387,8 @@ public class MdaDriver {
try {
if (from == null || fromObj == null || to == null || toObj == null)
return;
Class<?> fromClass = from.getType();
Class<?> toClass = to.getType();
Class<?> fromClass = getFieldType(from);
Class<?> toClass = getFieldType(to);
from.setAccessible(true);
to.setAccessible(true);
if (List.class.isAssignableFrom(fromClass)
......@@ -432,11 +432,9 @@ public class MdaDriver {
return;
}
//类型不相等
if (!to.getType().equals(from.getType())) {
if (!toClass.equals(fromClass)) {
return;
}
to.set(toObj, from.get(fromObj));
} catch (Exception e) {
e.printStackTrace();
......@@ -674,5 +672,19 @@ public class MdaDriver {
}
return errorsMap;
}
private static Class getFieldType(Field field) {
Class<?> type = field.getType();
if (type.isAssignableFrom(int.class)) {
return Integer.class;
}
if (type.isAssignableFrom(double.class)) {
return Double.class;
}
return type;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment