com.gitee.feizns.bean.BeanUtils Maven / Gradle / Ivy
package com.gitee.feizns.bean;
import com.gitee.feizns.StreamUtils;
import com.gitee.feizns.reflect.ConstructorUtils;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* java com.gitee.feizns.bean.
* @author feizns
* @since 2019/6/9 0009
*/
public abstract class BeanUtils {
/**
* 复制属性
* @param target
* @param source
* @param
* @return
*/
public static final T copyProperties(T target, Object... source) {
return copyProperties(target, StreamUtils::noChangeFun, source);
}
/**
* 复制属性
* @param target
* @param source
* @param
* @return
*/
public static final T copyProperties(T target, Function keyMap, Object... source) {
Map> map = PropertyUtils.writableProps(target)
.collect(Collectors.toMap(Property::name, item -> item, StreamUtils::leaveSecond, LinkedHashMap::new));
for (Object o : source) {
PropertyUtils.readableProps(o).forEach(prop -> {
String newKey = keyMap.apply(prop.name());
Property
© 2015 - 2025 Weber Informatics LLC | Privacy Policy