疯狂的狮子Li
2023-07-10 ee8922729e5067cd726cc4ba5a8259730e1d6a18
!390 update stream流工具类其他方法过滤null值
Merge pull request !390 from Bleachtred/Feat_5.X_07
已修改1个文件
12 ■■■■ 文件已修改
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/StreamUtils.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/StreamUtils.java
@@ -72,7 +72,7 @@
            return CollUtil.newArrayList();
        }
        // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
        return collection.stream().sorted(comparing).collect(Collectors.toList());
        return collection.stream().filter(Objects::nonNull).sorted(comparing).collect(Collectors.toList());
    }
    /**
@@ -89,7 +89,7 @@
        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));
    }
    /**
@@ -108,7 +108,7 @@
        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));
    }
    /**
@@ -126,7 +126,7 @@
            return MapUtil.newHashMap();
        }
        return collection
            .stream()
            .stream().filter(Objects::nonNull)
            .collect(Collectors.groupingBy(key, LinkedHashMap::new, Collectors.toList()));
    }
@@ -147,7 +147,7 @@
            return MapUtil.newHashMap();
        }
        return collection
            .stream()
            .stream().filter(Objects::nonNull)
            .collect(Collectors.groupingBy(key1, LinkedHashMap::new, Collectors.groupingBy(key2, LinkedHashMap::new, Collectors.toList())));
    }
@@ -168,7 +168,7 @@
            return MapUtil.newHashMap();
        }
        return collection
            .stream()
            .stream().filter(Objects::nonNull)
            .collect(Collectors.groupingBy(key1, LinkedHashMap::new, Collectors.toMap(key2, Function.identity(), (l, r) -> l)));
    }