mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix
This commit is contained in:
parent
37c2c07164
commit
7a1438fc02
@ -278,6 +278,7 @@ public class CollUtil {
|
|||||||
* @param coll2 集合2
|
* @param coll2 集合2
|
||||||
* @param otherColls 其它集合
|
* @param otherColls 其它集合
|
||||||
* @return 并集的集合,返回 {@link LinkedHashSet}
|
* @return 并集的集合,返回 {@link LinkedHashSet}
|
||||||
|
* @since 5.3.9
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public static <T> Set<T> intersectionDistinct(Collection<T> coll1, Collection<T> coll2, Collection<T>... otherColls) {
|
public static <T> Set<T> intersectionDistinct(Collection<T> coll1, Collection<T> coll2, Collection<T>... otherColls) {
|
||||||
@ -294,9 +295,11 @@ public class CollUtil {
|
|||||||
|
|
||||||
if (ArrayUtil.isNotEmpty(otherColls)) {
|
if (ArrayUtil.isNotEmpty(otherColls)) {
|
||||||
for (Collection<T> otherColl : otherColls) {
|
for (Collection<T> otherColl : otherColls) {
|
||||||
|
if(isNotEmpty(otherColl)){
|
||||||
result.retainAll(otherColl);
|
result.retainAll(otherColl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class CollUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void intersectionTest2() {
|
public void intersectionDistinctTest() {
|
||||||
ArrayList<String> list1 = CollUtil.newArrayList("a", "b", "b", "c", "d", "x");
|
ArrayList<String> list1 = CollUtil.newArrayList("a", "b", "b", "c", "d", "x");
|
||||||
ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d");
|
ArrayList<String> list2 = CollUtil.newArrayList("a", "b", "b", "b", "c", "d");
|
||||||
ArrayList<String> list3 = CollUtil.newArrayList();
|
ArrayList<String> list3 = CollUtil.newArrayList();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user