From f1d49fb78f0aae9cad9c45909b21fdef560b29e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8A=93=E8=9B=99=E5=B8=88?= <770492966@qq.com> Date: Sat, 16 Jul 2022 13:44:49 +0800 Subject: [PATCH] =?UTF-8?q?StreamUtils=E4=BC=98=E5=8C=96=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=BF=94=E5=9B=9E=E7=94=B1HashMap=E6=97=A0?= =?UTF-8?q?=E5=BA=8F=E8=BD=AC=E4=B8=BALinkedHashMap=E6=9C=89=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/utils/StreamUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StreamUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StreamUtils.java index 0de2784a0..99d58979f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StreamUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StreamUtils.java @@ -124,8 +124,8 @@ public class StreamUtils { return MapUtil.newHashMap(); } return collection - .stream() - .collect(Collectors.groupingBy(key, Collectors.toList())); + .stream() + .collect(Collectors.groupingBy(key, LinkedHashMap::new, Collectors.toList())); } /** @@ -146,7 +146,8 @@ public class StreamUtils { } return collection .stream() - .collect(Collectors.groupingBy(key1, Collectors.groupingBy(key2, Collectors.toList()))); + .collect(Collectors.groupingBy(key1, LinkedHashMap::new, + Collectors.groupingBy(key2, LinkedHashMap::new, Collectors.toList()))); } /** @@ -167,7 +168,8 @@ public class StreamUtils { } return collection .stream() - .collect(Collectors.groupingBy(key1, Collectors.toMap(key2, Function.identity(), (l, r) -> l))); + .collect(Collectors.groupingBy(key1, LinkedHashMap::new, + Collectors.toMap(key2, Function.identity(), (l, r) -> l))); } /**