集合排序链接
集合排序链接
1.新建集合
java
List<String> result = Lists.newArrayList();
2.集合赋值
java
List<String> orderStatusList = Lists.newArrayList("60", "70", "90");
3.遍历集合
java
list.stream().map(CspTransferOrderInfo::getTransferOutOrderCode).filter(StringUtils::isNotBlank).collect(Collectors.toList());
4.集合逗号分割为字符串
java
StringUtils.join(transferOutOrderCodeList, "、")
java
String.join(",", cspShop.getWarehouseCodeList()
java
String equipmentNumberList = list.stream().map(CspWarehouseEquipment::getEquipmentNumber).collect(Collectors.joining(","));
5.Stirng 转 List
java
CommonUtils.stringChangeList(cspCustomerOrderInfo.getOutOrderCode())
6.集合分组
Map<String, List> listMap = customerInfoList
.stream()
.collect(Collectors.groupingBy(CscCustomerInfo::getPostCode));
7.集合分组+转map集合
java
List<InterfaceMappingConfigurationDetails> mappingDetailsList = iInterfaceMappingConfigurationDetailsService.selectInterfaceMappingConfigurationDetailsList(selectInterfaceMappingDetails);
Map<String, Map<String, String>> groupByMappingType = mappingDetailsList
.stream()
.collect(Collectors.groupingBy(
InterfaceMappingConfigurationDetails::getMappingType,
Collectors.toMap(InterfaceMappingConfigurationDetails::getOmsCode,
InterfaceMappingConfigurationDetails::getErpCode,(v1,v2)->v1)
)
);
8.List转List
java
/**
* 集合类型转换
*
* @param longList 参数
* @return 结果
*/
private static List<String> convertToStringList(List<Long> longList) {
List<String> stringList = new ArrayList<>();
for (Long num : longList) {
stringList.add(num.toString());
}
return stringList;
}
9.List转List
java
String destinationCode = '12,1233,4444,32222,';
List<Long> indexIds = Arrays.stream(destinationCode.split(",")).map(Long::parseLong).collect(Collectors.toList());