This commit is contained in:
Looly
2020-05-25 16:04:33 +08:00
parent b90602746d
commit 4451a8451d
4 changed files with 43 additions and 1 deletions

View File

@@ -2727,6 +2727,20 @@ public class CollUtil {
throw new IllegalArgumentException(StrUtil.format("[{}] is not support to get empty!", collectionClass));
}
/**
* 清除一个或多个集合内的元素每个集合调用clear()方法
*
* @param collections 一个或多个集合
* @since 5.3.6
*/
public static void clear(Collection<?>... collections) {
for (Collection<?> collection : collections) {
if (isNotEmpty(collection)) {
collection.clear();
}
}
}
// ---------------------------------------------------------------------------------------------- Interface start
/**

View File

@@ -1115,4 +1115,17 @@ public class MapUtil {
// 不支持空集合的集合类型
throw new IllegalArgumentException(StrUtil.format("[{}] is not support to get empty!", mapClass));
}
/**
* 清除一个或多个Map集合内的元素每个Map调用clear()方法
*
* @param maps 一个或多个Map
*/
public static void clear(Map<?, ?>... maps) {
for (Map<?, ?> map : maps) {
if (isNotEmpty(map)) {
map.clear();
}
}
}
}