@Override
public Product updateProduct(Product oldProduct, Product product) throws DAOException {
ObjectUtil.copy(oldProduct, product, Lists.newArrayList("id","deleteFlag","status"));
productDao.update(oldProduct);
return oldProduct;
}
public static Object copy(Object obj1, Object obj2, List<String> ignoreFs) {
Class<?> type = obj1.getClass();
Class<?> type2 = obj2.getClass();
List<Field> fields = new ArrayList();
Class clazz;
Field[] getMethod;
for(clazz = obj1.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
getMethod = clazz.getDeclaredFields();
int var8 = getMethod.length;
for(int var9 = 0; var9 < var8; ++var9) {
Field f = getMethod[var9];
fields.add(f);
}
}
clazz = null;
getMethod = null;
Method setMethod = null;
Object value = null;
for(int i = 0; i < fields.size(); ++i) {
try {
String fname = ((Field)fields.get(i)).getName();
if (ignoreFs == null || !ignoreFs.contains(fname)) {
Method getMethod = type2.getMethod("get" + fname.substring(0, 1).toUpperCase() + fname.substring(1));
if (getMethod != null) {
value = getMethod.invoke(obj2);
}
if (value != null) {
setMethod = type.getMethod("set" + fname.substring(0, 1).toUpperCase() + fname.substring(1), ((Field)fields.get(i)).getType());
setMethod.invoke(obj1, value);
}
}
} catch (NoSuchMethodException var12) {
;
} catch (IllegalAccessException | InvocationTargetException | SecurityException var13) {
logger.warn(var13.getLocalizedMessage());
} catch (IllegalArgumentException var14) {
logger.warn(var14.getLocalizedMessage());
}
}
return obj1;
}