当前位置:网站首页>Usage of BeanUtils property replication
Usage of BeanUtils property replication
2022-06-29 18:26:00 【thoughtCodes】
1. For types of Boolean/Short/Integer/Float/Double Properties of , It will translate into 0:
demand 1: If B A field in has a value ( Not for null), This field is not copied ; That is to say B When there is no value in this field , To copy , Suitable for B Supplementary value .
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.PropertyUtils;
public class CopyWhenNullBeanUtilsBean extends BeanUtilsBean{
@Override
public void copyProperty(Object bean, String name, Object value)
throws IllegalAccessException, InvocationTargetException {
try {
Object destValue = PropertyUtils.getSimpleProperty(bean, name);
if (destValue == null) {
super.copyProperty(bean, name, value);
}
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
}
import org.apache.commons.beanutils.BeanUtilsBean;
public class CopyFromNotNullBeanUtilsBean extends BeanUtilsBean {
@Override
public void copyProperty(Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException {
if (value == null) {
return;
}
super.copyProperty(bean, name, value);
}
}
Special Usage :
边栏推荐
- MySQL - clear data in the table
- 优雅书写Controller(参数验证+统一异常处理)
- Servlet学生管理系统(萌新练手版)
- SD6.22集训总结
- Spingmvc requests and responses
- Software testing - you may not understand the basic theoretical knowledge
- Adobe Premiere foundation - opacity (mixed mode) (XII)
- Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
- Markdown common fonts
- WBF:检测任务NMS后虑框新方式?
猜你喜欢

关于微服务

踩坑记:JSON.parse和JSON.stringify

Adobe Premiere基础-批量素材导入序列-变速和倒放(回忆)-连续动作镜头切换-字幕要求(十三)

Servlet学生管理系统(萌新练手版)

Niuke Xiaobai monthly race 52 E group logarithmic sum (inclusion exclusion theorem + dichotomy)

The soft youth under the blessing of devcloud makes education "smart" in the cloud

Adobe Premiere foundation - cool text flash (14)

Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)

Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)

通过 hosts文件配置本地域名
随机推荐
软件测试——基础理论知识你都不一定看得懂
Jar包后台启动并输出日志
Record that the server has been invaded by viruses: the SSH password has been changed, the login fails, the malicious program runs full of CPU, the jar package fails to start automatically, and you ha
MySql存储过程循环的使用分析详解
Adobe Premiere foundation - cool text flash (14)
JDBC Codes connexes
codeforces每日5题(均1700)-第二天
Anaconda安装并配置jupyter notebook远程
POJ 1975 (transitive closure)
【目标跟踪】|stark配置 win otb
shell教程之循环语句for,while,until用法
3H proficient in opencv (VI) - image stacking
Adobe Premiere Foundation - réglage du son (correction du volume, réduction du bruit, tonalité téléphonique, changement de hauteur, égaliseur de paramètres) (XVIII)
Adobe Premiere基础-不透明度(蒙版)(十一)
Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
Adobe Premiere基础-素材嵌套(制作抖音结尾头像动画)(九)
数据分析基础--预测模型
If the evaluation conclusion of waiting insurance is poor, does it mean that waiting insurance has been done in vain?
SD6.23集训总结
Us judge ruled that the former security director of Uber accused of covering up hacking must face fraud charges