List转为Map(值唯一)
Map<Long, MyDto> myDtoMap = new HashMap();
if(!CollectionUtils.isEmpty(myDtoList)){
merchantDTOMap = myDtoList.stream().collect(Collectors.toMap(MerchantDTO::getOrderId, Function.identity(), (key1, key2) -> key2));
}
List转为Map(group by)
Map<Long, List<MyInfo>> map = myInfoList.stream().collect(Collectors.groupingBy(MyInfo::getUserId));
List抽取某一列信息
List<String> nameList = ringList.stream().map(Ring::getTitle).collect(Collectors.toList());
List排序
private void sortWordDtosByBizLine(List<MyDto> myDtos){
if(CollectionUtils.isEmpty(myDtos)){
return;
}
myDtos.sort(Comparator.comparing(MyDto::getLine)
.thenComparing(Comparator.comparing(MyDto::getFirstLetter)));
}
inMyDocDtos.sort(Comparator.comparing(MyDocDto::getLen).reversed());
resultDtos.sort(Comparator.comparing(MyDocDto::getDs)
.thenComparing(Comparator.comparing(MyDocDto::getValue).reversed()));
List<FileDto> fileDtoList = attachmentDtoList.stream().filter(
attachment -> StringUtils.equals(attachment.getType(), WoodAttachmentTypeEnum.FILE.getType())).collect(
Collectors.toList());