hutool-extra ftp 支持上传文件或目录

This commit is contained in:
Looly
2022-09-26 22:18:45 +08:00
parent d30e8ab55b
commit bef38c365b
4 changed files with 55 additions and 64 deletions

View File

@@ -208,7 +208,7 @@ public class CollUtil {
@SafeVarargs
public static <T> List<T> unionAll(Collection<T> coll1, Collection<T> coll2, Collection<T>... otherColls) {
if (CollUtil.isEmpty(coll1) && CollUtil.isEmpty(coll2) && ArrayUtil.isEmpty(otherColls)) {
return Collections.emptyList();
return new ArrayList<>(0);
}
// 计算元素总数
@@ -216,13 +216,13 @@ public class CollUtil {
totalSize += size(coll1);
totalSize += size(coll2);
if (otherColls != null) {
for (Collection<T> otherColl : otherColls) {
for (final Collection<T> otherColl : otherColls) {
totalSize += size(otherColl);
}
}
// 根据size创建防止多次扩容
List<T> res = new ArrayList<>(totalSize);
final List<T> res = new ArrayList<>(totalSize);
if (coll1 != null) {
res.addAll(coll1);
}
@@ -233,7 +233,7 @@ public class CollUtil {
return res;
}
for (Collection<T> otherColl : otherColls) {
for (final Collection<T> otherColl : otherColls) {
if (otherColl != null) {
res.addAll(otherColl);
}

View File

@@ -941,6 +941,7 @@ public class CollUtilTest {
final List<String> list = CollUtil.unionAll(list1, list2, list3);
Assert.assertNotNull(list);
@SuppressWarnings("ConfusingArgumentToVarargsMethod")
final List<String> resList2 = CollUtil.unionAll(null, null, null);
Assert.assertNotNull(resList2);
}
@@ -972,6 +973,7 @@ public class CollUtilTest {
public void unionAllOtherIsNullTest() {
final List<Integer> list1 = CollectionUtil.newArrayList(1, 2, 2, 3, 3);
final List<Integer> list2 = CollectionUtil.newArrayList(1, 2, 3);
@SuppressWarnings("ConfusingArgumentToVarargsMethod")
final List<Integer> list = CollUtil.unionAll(list1, list2, null);
Assert.assertNotNull(list);
Assert.assertArrayEquals(