62,616
社区成员
发帖
与我相关
我的任务
分享
public <T> T copyAttribute(T t1, T t2) throws IllegalArgumentException, IllegalAccessException {
Class classz = t1.getClass();
Field[] fieldArr = classz.getDeclaredFields();
for(Field f : fieldArr){
Object value = f.get(t2);
if(value != null){
f.set(t1, value);
}
}
return t1;
}