*/
//针对所用对象
private static Object combineSydwCore(Object sourceBean, Object targetBean) {
Class sourceBeanClass = sourceBean.getClass();
Class targetBeanClass = targetBean.getClass();
Field[] sourceFields = sourceBeanClass.getDeclaredFields();
Field[] targetFields = sourceBeanClass.getDeclaredFields();
for (int i = 0; i < sourceFields.length; i++) {
Field sourceField = sourceFields[i];
Field targetField = targetFields[i];
sourceField.setAccessible(true);
targetField.setAccessible(true);
try {
if (!(sourceField.get(sourceBean) == null)) {
targetField.set(targetBean, sourceField.get(sourceBean));
}
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
return targetBean;
}
//针对单一对象,返回类型是对于实体类
/*
以第一个实体类为主,如果第一个的实体类某个字段为空,则会吧第二个实体类的值取过来进行赋值,
如果不为空的则不作改变
*/
private static Student combineSydwCore(Student sourceBean, Student targetBean) {
Class sourceBeanClass = sourceBean.getClass();
Class targetBeanClass = targetBean.getClass();
Field[] sourceFields = sourceBeanClass.getDeclaredFields();
Field[] targetFields = targetBeanClass.getDeclaredFields();
for (int i = 0; i < sourceFields.length; i++) {
Field sourceField = sourceFields[i];
if (Modifier.isStatic(sourceField.getModifiers())) {
continue;
}
Field targetField = targetFields[i];
if (Modifier.isStatic(targetField.getModifiers())) {
continue;
}
sourceField.setAccessible(true);
targetField.setAccessible(true);
try {
if (!(sourceField.get(sourceBean) == null) && !“serialVersionUID”.equals(sourceField.getName().toString())) {
targetField.set(targetBean, sourceField.get(sourceBean));
}
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
return targetBean;
}
3.测试
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V:vip1024b 备注Java获取(资料价值较高,非无偿)
面试准备+复习分享:
为了应付面试也刷了很多的面试题与资料,现在就分享给有需要的读者朋友,资料我只截取出来一部分哦
**
[外链图片转存中…(img-PapUaHEt-1711551767312)]
面试准备+复习分享:
为了应付面试也刷了很多的面试题与资料,现在就分享给有需要的读者朋友,资料我只截取出来一部分哦
[外链图片转存中…(img-Vb1X8Tu8-1711551767313)]