| | |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 |
| | | return collection.stream().sorted(comparing).collect(Collectors.toList()); |
| | | return collection.stream().filter(Objects::nonNull).sorted(comparing).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (CollUtil.isEmpty(collection)) { |
| | | return MapUtil.newHashMap(); |
| | | } |
| | | return collection.stream().collect(Collectors.toMap(key, Function.identity(), (l, r) -> l)); |
| | | return collection.stream().filter(Objects::nonNull).collect(Collectors.toMap(key, Function.identity(), (l, r) -> l)); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (CollUtil.isEmpty(collection)) { |
| | | return MapUtil.newHashMap(); |
| | | } |
| | | return collection.stream().collect(Collectors.toMap(key, value, (l, r) -> l)); |
| | | return collection.stream().filter(Objects::nonNull).collect(Collectors.toMap(key, value, (l, r) -> l)); |
| | | } |
| | | |
| | | /** |
| | |
| | | return MapUtil.newHashMap(); |
| | | } |
| | | return collection |
| | | .stream() |
| | | .stream().filter(Objects::nonNull) |
| | | .collect(Collectors.groupingBy(key, LinkedHashMap::new, Collectors.toList())); |
| | | } |
| | | |
| | |
| | | return MapUtil.newHashMap(); |
| | | } |
| | | return collection |
| | | .stream() |
| | | .stream().filter(Objects::nonNull) |
| | | .collect(Collectors.groupingBy(key1, LinkedHashMap::new, Collectors.groupingBy(key2, LinkedHashMap::new, Collectors.toList()))); |
| | | } |
| | | |
| | |
| | | return MapUtil.newHashMap(); |
| | | } |
| | | return collection |
| | | .stream() |
| | | .stream().filter(Objects::nonNull) |
| | | .collect(Collectors.groupingBy(key1, LinkedHashMap::new, Collectors.toMap(key2, Function.identity(), (l, r) -> l))); |
| | | } |
| | | |