Java工具类1-BeanMap使用
spring-core
org.springframework.cglib.beans.BeanMap
default 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"); }}
本文来自博客园,作者:life_start,转载请注明原文链接:https://www.cnblogs.com/yangh2016/p/18348793