public static void copyProperties(Object fromObj, Object toObj, boolean ignoreNull) throws BeanCopyException {
if (fromObj == null) {
return;
}
Class<? extends Object> fromClass = fromObj.getClass();
Class<? extends Object> toClass = toObj.getClass();
boolean isStrict = (fromClass == toClass);
try {
BeanInfo fromBean = Introspector.getBeanInfo(fromClass);
BeanInfo toBean = Introspector.getBeanInfo(toClass);
final PropertyDescriptor[] toPds = toBean.getPropertyDescriptors();
final PropertyDescriptor[] fromPds = fromBean.getPropertyDescriptors();
for (PropertyDescriptor toPd : toPds) {
PropertyDescriptor fromPd = getPropertyDescriptor(fromPds, toPd, isStrict);
if (fromPd != null && fromPd.getDisplayName().equals(toPd.getDisplayName())) {
Method writeMethod = toPd.getWriteMethod();
Method readMethod = fromPd.getReadMethod();
if (writeMethod != null && readMethod != null) {
Object param = readMethod.invoke(fromObj, (Object[]) null);
if (ignoreNull && param == null) {
continue;
}
writeMethod.invoke(toObj, param);
}
}
}
} catch (Exception e) {
throw new BeanCopyException(e);
}
}public static void copyProperties(Object fromObj,