public class CommonConverterUtils {
public static <T,E> List<E> converts(List<T> req, Class<E> rspClass){
List<E> list = null;
if (CollectionUtils.isNotEmpty(req)) {
list = (List<E>)req.stream().map(v -> {
Object object = null;
try {
object = rspClass.newInstance();
} catch (Exception e) {
throw new RuntimeException();
}
BeanUtils.copyProperties(v, object);
return object;
}).collect(Collectors.toList());
}
return list;
}
}
java中List之间的赋值工具类
最新推荐文章于 2024-06-12 11:59:04 发布