Commit a67f26cd by s_guodong

解决int.toString问题

parent cc45ff1a
...@@ -387,8 +387,8 @@ public class MdaDriver { ...@@ -387,8 +387,8 @@ public class MdaDriver {
try { try {
if (from == null || fromObj == null || to == null || toObj == null) if (from == null || fromObj == null || to == null || toObj == null)
return; return;
Class<?> fromClass = from.getType(); Class<?> fromClass = getFieldType(from);
Class<?> toClass = to.getType(); Class<?> toClass = getFieldType(to);
from.setAccessible(true); from.setAccessible(true);
to.setAccessible(true); to.setAccessible(true);
if (List.class.isAssignableFrom(fromClass) if (List.class.isAssignableFrom(fromClass)
...@@ -432,11 +432,9 @@ public class MdaDriver { ...@@ -432,11 +432,9 @@ public class MdaDriver {
return; return;
} }
//类型不相等 //类型不相等
if (!to.getType().equals(from.getType())) { if (!toClass.equals(fromClass)) {
return; return;
} }
to.set(toObj, from.get(fromObj)); to.set(toObj, from.get(fromObj));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -674,5 +672,19 @@ public class MdaDriver { ...@@ -674,5 +672,19 @@ public class MdaDriver {
} }
return errorsMap; 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