2026-07-01 6b5f7c66fc40d7f6099d561e31a34fbd50dd20d3
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java
@@ -124,6 +124,22 @@
        return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toSet());
    }
    public static <T, U> Set<U> convertLinkedSet(Collection<T> from, Function<T, U> func) {
        if (CollUtil.isEmpty(from)) {
            return new LinkedHashSet<>();
        }
        return from.stream().map(func).filter(Objects::nonNull)
                .collect(Collectors.toCollection(LinkedHashSet::new));
    }
    public static <T, U> Set<U> convertLinkedSet(Collection<T> from, Function<T, U> func, Predicate<T> filter) {
        if (CollUtil.isEmpty(from)) {
            return new LinkedHashSet<>();
        }
        return from.stream().filter(filter).map(func).filter(Objects::nonNull)
                .collect(Collectors.toCollection(LinkedHashSet::new));
    }
    public static <T, K> Map<K, T> convertMapByFilter(Collection<T> from, Predicate<T> filter, Function<T, K> keyFunc) {
        if (CollUtil.isEmpty(from)) {
            return new HashMap<>();
@@ -372,4 +388,14 @@
        return false;
    }
    /**
     * 把单元素 head 与集合 tail 合并成新 List(head 在前,tail 顺序保留)
     */
    public static <T> List<T> of(T head, Collection<T> tail) {
        List<T> list = new ArrayList<>();
        list.add(head);
        CollUtil.addAll(list, tail);
        return list;
    }
}