public class BeanCopyUtil extends Object
| 构造器和说明 |
|---|
BeanCopyUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> void |
beanCopy(T source,
T target)
source中的非空属性复制到target中
public void copy(UserMsgSubscribeBean source) {
BeanCopyUtil.beanCopy(source, this);
}
Bean getIdDate = regulationDao.findOne(ParamBean.getId());//跟根据ID获取需要更新的数据的 原始数据
getIdDate.systemRuleBeanCopy(ParamBean);//将新数据中非空字段 克隆到原始数据中 实现更新
regulationDao.saveAndFlush(getIdDate);//保存克隆之后的数据 且 saveAndFlush立即生效
|
static <T> void |
beanCopyWithIngore(T source,
T target,
String... ignoreProperties)
source中的非空属性复制到target中,但是忽略指定的属性,也就是说有些属性是不可修改的(个人业务需要)
|
static String[] |
getNullAndIgnorePropertyNames(Object source,
String... ignoreProperties) |
static String[] |
getNullPropertyNames(Object source) |
static Set<String> |
getNullPropertyNameSet(Object source) |
static <T> T |
to(Class<T> tClass,
Object t)
复制bean
|
public static <T> void beanCopy(T source,
T target)
public void copy(UserMsgSubscribeBean source) {
BeanCopyUtil.beanCopy(source, this);
}
Bean getIdDate = regulationDao.findOne(ParamBean.getId());//跟根据ID获取需要更新的数据的 原始数据
getIdDate.systemRuleBeanCopy(ParamBean);//将新数据中非空字段 克隆到原始数据中 实现更新
regulationDao.saveAndFlush(getIdDate);//保存克隆之后的数据 且 saveAndFlush立即生效
public static <T> void beanCopyWithIngore(T source,
T target,
String... ignoreProperties)
public static String[] getNullAndIgnorePropertyNames(Object source, String... ignoreProperties)
Copyright © 2021 tan. All rights reserved.