public class CollectionExtUtils extends CollectionUtils {
private static final Logger log = LoggerFactory.getLogger(CollectionExtUtils.class);
public static <T> List<T> convertTarget(List sourceList, Class<T> targetClass) {
ArrayList targetList = new ArrayList();
try {
Iterator values = sourceList.iterator();
while (values.hasNext()) {
Object source = values.next();
T target = targetClass.newInstance();
BeanUtils.copyProperties(source, target);
targetList.add(target);
}
} catch (Exception e) {
log.error(">>>>>>复制异常<<<<<<", e);
}
return targetList;
}
}
使用
CollectionExtUtils.convertTarget(sourceList, xxx.class)