| | |
| | | if (CollUtil.isEmpty(collection)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 |
| | | return collection.stream().filter(function).collect(Collectors.toList()); |
| | | } |
| | | |
| | |
| | | * @return 拼接后的list |
| | | */ |
| | | public static <E> String join(Collection<E> collection, Function<E, String> function) { |
| | | return join(collection, function, ","); |
| | | return join(collection, function, StringUtils.SEPARATOR); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (CollUtil.isEmpty(collection)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 |
| | | return collection.stream().sorted(comparing).collect(Collectors.toList()); |
| | | } |
| | | |
| | |
| | | .stream() |
| | | .map(function) |
| | | .filter(Objects::nonNull) |
| | | // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |