Java工具类1-BeanMap使用

spring-core
org.springframework.cglib.beans.BeanMap

default <S extends V> S sourceToTarget(S sourceEntity, S targetEntity) {
if (null != sourceEntity && null != targetEntity) {
BeanMap targetBeanMap = BeanMap.create(targetEntity);
BeanMap sourceBeanMap = BeanMap.create(sourceEntity);
sourceBeanMap.forEach((key1, value) -> {
if (null != value) {
targetBeanMap.put(String.valueOf(key1), value);
}

});
return targetEntity;
} else {
throw new RuntimeException("sourceEntity or targetEntity is null");
}
}
posted @ 2024-08-08 13:56  life_start  阅读(15)  评论(0编辑  收藏  举报