cn.kdyzm.util.convert.ConvertUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kdyzm-util Show documentation
Show all versions of kdyzm-util Show documentation
常用工具类整理,包含jackson、http请求、树构建工具、web工具类等
The newest version!
package cn.kdyzm.util.convert;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author kdyzm
* @date 2021/12/27
*/
public class ConvertUtil {
/**
* 转换List
*
* @param i 入参
* @param mapper 转换函数
* @param 入参泛型
* @param 出参泛型
* @return 返回值列表
*/
public static List transfer(List i, Function super T, ? extends R> mapper) {
if (CollectionUtils.isEmpty(i)) {
return new ArrayList<>();
}
return i.stream().map(mapper).collect(Collectors.toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy