JAVA8 利用stream流将一个对象集合转换成另一个对象集合
// 从数据库中查询出的对象集合List<OperationStation> operationStations = operationStationJoinMapper.selectJoinByExample(example);// 判端是否为空if (CollectionUtils.isNotEmpty(operationStations)) {// 进行拆解封装Lis...
·
// 从数据库中查询出的对象集合
List<OperationStation> operationStations = operationStationJoinMapper.selectJoinByExample(example);
// 判端是否为空
if (CollectionUtils.isNotEmpty(operationStations)) {
// 进行拆解封装
List<StationDictVO> stationDictVOS = operationStations.stream().map(operationStation -> {
StationDictVO stationDictVO = new StationDictVO();
stationDictVO.setStationId(operationStation.getStationId());
stationDictVO.setStationName(operationStation.getStationName());
return stationDictVO;
}).collect(Collectors.toList());
}
更多推荐
所有评论(0)