Class CollUtil
java.lang.Object
com.sure.tool.collection.CollUtil
集合工具类,参考 Hutool 的
CollUtil 设计。
English: Collection helpers for creating, filtering, joining and comparing lists, sets and maps.
- Since:
- 0.1.0
- Author:
- suretool
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Collection<T> addAll(Collection<T> target, Collection<T> source) 将 source 全部追加到 target 并返回 target。static <T> booleanaddAllDistinct(Collection<T> target, Iterable<T> source) 原地去重合并:将 source 中 target 尚不存在的元素追加到 target 末尾(保 source 顺序)。cartesianProduct(Collection<? extends Collection<? extends T>> collections) 任意维度笛卡尔积(对齐 GuavaSets.cartesianProduct)。chunk(Collection<T> collection, int size) 将集合按指定大小分片。static booleancontains(Collection<?> collection, Object value) 集合是否包含指定元素。static booleancontainsAll(Collection<?> collection, Collection<?> target) 是否包含另一集合全部元素。static <T> booleancontainsAll(Collection<T> collection, T... values) 是否包含全部指定元素。static booleancontainsAny(Collection<?> collection, Object... values) 集合是否包含任一指定元素。static booleancontainsAny(Collection<?> c1, Collection<?> c2) 两个集合是否存在交集。countMap(Collection<T> collection) 统计元素出现频次。static <T> List<T> disjunction(Collection<T> c1, Collection<T> c2) 差集(属于 c1 但不属于 c2)。static <T> List<T> distinct(Collection<T> collection) 去重(保持原有顺序)。static <T> List<T> emptyIfNull(Collection<T> collection) 空集合返回空列表。static <T> List<T> filter(Collection<T> collection, Predicate<T> predicate) 过滤集合(返回新列表)。static <T> List<T> flatMap(Collection<? extends Collection<? extends T>> nested) 展平一层嵌套集合。static <T> List<T> flatten(Collection<? extends Collection<T>> nested) 两级扁平化:将「集合的集合」展开为单层列表,内层 null 集合跳过。static <T> intfrequency(Collection<T> collection, T value) 统计元素在集合中出现的次数(基于Objects.equals(Object, Object))。static <T> Tget(Collection<T> collection, int index) 获取指定索引的元素(负数从末尾倒数)。static <T> Tget(Collection<T> collection, int index, T defaultValue) 获取集合中指定索引的元素,越界或空集合时返回默认值。static <T> TgetFirst(Collection<T> collection) 获取第一个元素。static <T> TgetLast(Collection<T> collection) 获取最后一个元素。groupBy(Collection<T> collection, Function<T, ?>... keyMappers) 多键链式分组(对齐 GuavaMultimaps.index)。groupBy(Collection<T> collection, Function<T, K1> key1Mapper, Function<T, K2> key2Mapper) 双键嵌套分组(对齐 GuavaMultimaps.index多层语义)。groupBy2(Collection<T> collection, Function<T, K1> keyMapper1, Function<T, K2> keyMapper2) 按两级键进行嵌套分组:先按 keyMapper1 分组,组内再按 keyMapper2 分组(均保序)。groupByKey(Collection<T> collection, Function<T, K> keyMapper) 按 key 分组。static <T> int在列表中查找元素下标。static <T> List<T> intersection(Collection<T> c1, Collection<T> c2) 交集(去重)。static booleanisAllEmpty(Collection<?>... collections) 判断多个集合是否全部为空(null 或空集合视为空)。static booleanisAllNotNull(Collection<?>... collections) 判断多个集合是否全部非空(非 null 且非空集合)。static booleanIterable 是否为空。static boolean数组是否为空。static booleanisEmpty(Collection<?> collection) 集合是否为空。static booleanisEmpty(Enumeration<?> enumeration) 枚举是否为空。static boolean迭代器是否为空。static booleanMap 是否为空。static booleanisNotEmpty(Collection<?> collection) 集合是否非空。static booleanisNotEmpty(Map<?, ?> map) Map 是否非空。static Stringjoin(Collection<?> collection, CharSequence delimiter) 拼接集合元素。static <T> intlastIndexOf(List<T> list, Object value) 在列表中查找元素最后出现的下标。static <T,K> Map <K, T> listToMap(Collection<T> list, Function<T, K> keyFunction) List 转 Map(key 由函数提取,重复 key 后值覆盖)。static <T,R> List <R> map(Collection<T> collection, Function<T, R> mapper) 映射集合元素(返回新列表)。static <T extends Comparable<? super T>>
Tmax(Collection<T> collection) 最大值(Comparable 集合,null 安全)。static <T, R extends Comparable<R>>
TmaxBy(Collection<T> collection, Function<T, R> keyMapper) 按提取函数取最大值。static <T> TmaxCount(Collection<T> collection) 返回集合中出现次数最多的元素(众数);并列时取先出现的元素。static <T extends Comparable<? super T>>
Tmin(Collection<T> collection) 最小值(Comparable 集合,null 安全)。static <T, R extends Comparable<R>>
TminBy(Collection<T> collection, Function<T, R> keyMapper) 按提取函数取最小值。static <T> List<T> newArrayList(T... values) 创建 ArrayList。static <T> Set<T> newConcurrentHashSet(T... values) 创建线程安全的 Set(基于 ConcurrentHashMap),并填充元素。static <T> HashSet<T> newHashSet(T... values) 创建 HashSet。static <T> LinkedHashSet<T> newLinkedHashSet(T... values) 创建 LinkedHashSet。static <T> TreeSet<T> newTreeSet(Comparator<? super T> comparator, T... values) 创建带比较器的有序 Set(TreeSet),并填充元素。static <T> List<T> 分页(页码从 1 开始),越界时返回空列表。pairwise(Collection<T> collection) 相邻配对:返回相邻元素的二元组列表,长度为 size-1;少于 2 个元素时返回空列表。static <T> Partition<T> partitionBy(Collection<T> collection, Predicate<T> predicate) 按谓词将集合分为「匹配」与「不匹配」两部分(均保序),等价于一次性完成 filter 与其补集。static <T> TrandomItem(Collection<T> collection) 从集合中随机取一个元素。static <T> List<T> randomItems(Collection<T> collection, int count) 从集合中随机取指定数量的元素(不重复)。static <T> booleanremoveAll(Collection<T> target, Iterable<T> source) 原地差集:从 target 中移除 source 出现的全部元素(重复元素全部移除,语义对齐subtract(Collection, Collection))。static <T> Collection<T> removeAny(Collection<T> collection, T... values) 移除集合中的指定元素。static <T> Collection<T> removeEmpty(Collection<T> collection) 移除集合中的 null 与空元素(空字符串/空集合/空 Map)。static <T> List<T> removeNull(Collection<T> coll) 移除集合中的 null 元素,返回新列表。static <T> booleanretainAll(Collection<T> target, Iterable<T> source) 原地交集:仅保留 target 中同时存在于 source 的元素(保 target 原有顺序)。static <T> List<T> 反转列表(原地反转)。static <T> List<T> 旋转列表元素(正数为右旋,负数为左旋)。static <T> List<T> 就地洗牌(Fisher-Yates),返回原列表以便链式调用。static intsize(Collection<?> collection) 集合大小。static <T> List<T> sort(Collection<T> collection, Comparator<T> comparator) 排序(返回新列表)。static <T> List<T> sortByProperty(Collection<T> collection, String property) 按属性升序排序。static <T> List<T> sortByProperty(Collection<T> collection, String property, boolean isAscending) static <T> List<T> sortByPropertyDesc(Collection<T> collection, String property) 按属性降序排序。按固定大小切分为多组。static <T> List<T> 截取列表子区间(负数索引从末尾倒数)。static <T> List<T> subtract(Collection<T> c1, Collection<T> c2) 单向差集:返回 c1 中存在但 c2 中不存在的元素。static intsum(Collection<Integer> coll) int 集合求和。static doublesumDouble(Collection<Double> coll) double 集合求和。static longsumLong(Collection<Long> coll) long 集合求和。static <T> List<T> 交换列表中两个位置的元素。static <T> List<T> takeWhile(Collection<T> collection, Predicate<T> predicate) 从头取满足谓词的元素前缀,遇到第一个不满足的元素即停止(Stream.takeWhile 的集合版)。static <T> T[]集合转数组。static <T> List<T> toImmutable(Collection<T> collection) 返回集合的不可变副本。static <T> List<T> 集合转 List(安全拷贝)。static <T> List<T> toList(Enumeration<T> enumeration) 枚举转 List。static <T> List<T> 迭代器转 List。static <T,K, V> Map <K, V> toMap(Collection<T> collection, Function<T, K> keyMapper, Function<T, V> valueMapper) 列表转映射。static <T> List<T> union(Collection<T> c1, Collection<T> c2) 并集(去重)。static <T> List<T> xor(Collection<T> c1, Collection<T> c2) 对称差集(属于 c1 或 c2 但不同时属于两者)。static <K,V> Map <K, V> zip(Collection<K> keys, Collection<V> values) 将两个集合按顺序配对为 Map。
-
Method Details
-
isEmpty
集合是否为空。- Parameters:
collection- 集合- Returns:
- 是否为空
-
isNotEmpty
集合是否非空。- Parameters:
collection- 集合- Returns:
- 是否非空
-
isEmpty
-
isNotEmpty
-
isEmpty
迭代器是否为空。- Parameters:
iterator- 迭代器- Returns:
- 是否为空
-
isEmpty
枚举是否为空。- Parameters:
enumeration- 枚举- Returns:
- 是否为空
-
isEmpty
-
newArrayList
创建 ArrayList。- Type Parameters:
T- 元素类型- Parameters:
values- 元素- Returns:
- ArrayList
-
newHashSet
创建 HashSet。- Type Parameters:
T- 元素类型- Parameters:
values- 元素- Returns:
- HashSet
-
newLinkedHashSet
创建 LinkedHashSet。- Type Parameters:
T- 元素类型- Parameters:
values- 元素- Returns:
- LinkedHashSet
-
contains
集合是否包含指定元素。- Parameters:
collection- 集合value- 元素- Returns:
- 是否包含
-
containsAny
集合是否包含任一指定元素。- Parameters:
collection- 集合values- 元素数组- Returns:
- 是否包含任一元素
-
union
并集(去重)。- Type Parameters:
T- 元素类型- Parameters:
c1- 集合 1c2- 集合 2- Returns:
- 并集
-
intersection
交集(去重)。- Type Parameters:
T- 元素类型- Parameters:
c1- 集合 1c2- 集合 2- Returns:
- 交集
-
disjunction
差集(属于 c1 但不属于 c2)。- Type Parameters:
T- 元素类型- Parameters:
c1- 集合 1c2- 集合 2- Returns:
- 差集
-
xor
对称差集(属于 c1 或 c2 但不同时属于两者)。- Type Parameters:
T- 元素类型- Parameters:
c1- 集合 1c2- 集合 2- Returns:
- 对称差集
-
join
拼接集合元素。- Parameters:
collection- 集合delimiter- 分隔符- Returns:
- 拼接结果
-
toList
-
toList
-
toList
枚举转 List。- Type Parameters:
T- 元素类型- Parameters:
enumeration- 枚举- Returns:
- List
-
get
获取指定索引的元素(负数从末尾倒数)。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合index- 索引- Returns:
- 元素,越界返回
null
-
get
获取集合中指定索引的元素,越界或空集合时返回默认值。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合index- 索引(支持负索引,-1 表示倒数第一个)defaultValue- 默认值- Returns:
- 元素或默认值
-
getFirst
获取第一个元素。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合- Returns:
- 第一个元素
-
getLast
获取最后一个元素。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合- Returns:
- 最后一个元素
-
filter
过滤集合(返回新列表)。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合predicate- 过滤条件- Returns:
- 过滤后的列表
-
map
映射集合元素(返回新列表)。- Type Parameters:
T- 源元素类型R- 目标元素类型- Parameters:
collection- 集合mapper- 映射函数- Returns:
- 映射后的列表
-
groupByKey
按 key 分组。- Type Parameters:
T- 元素类型K- key 类型- Parameters:
collection- 集合keyMapper- key 提取函数- Returns:
- 分组 Map
-
distinct
去重(保持原有顺序)。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合- Returns:
- 去重后的列表
-
sort
排序(返回新列表)。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合comparator- 比较器- Returns:
- 排序后的列表
-
size
集合大小。- Parameters:
collection- 集合- Returns:
- 大小,空集合返回 0
-
sub
-
reverse
-
emptyIfNull
空集合返回空列表。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合- Returns:
- 非空返回原列表,否则返回空列表
-
isEmpty
Iterable 是否为空。- Parameters:
iterable- 可迭代对象- Returns:
- 是否为空
-
page
-
shuffle
-
countMap
统计元素出现频次。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合- Returns:
- 元素到频次的映射
-
subtract
单向差集:返回 c1 中存在但 c2 中不存在的元素。- Type Parameters:
T- 元素类型- Parameters:
c1- 左集合c2- 右集合- Returns:
- c1 - c2 的结果列表
-
toMap
public static <T,K, Map<K,V> V> toMap(Collection<T> collection, Function<T, K> keyMapper, Function<T, V> valueMapper) 列表转映射。- Type Parameters:
T- 元素类型K- key 类型V- value 类型- Parameters:
collection- 集合keyMapper- key 提取函数valueMapper- value 提取函数- Returns:
- 映射(重复 key 时后者覆盖前者)
-
addAll
将 source 全部追加到 target 并返回 target。- Type Parameters:
T- 元素类型- Parameters:
target- 目标集合source- 源集合- Returns:
- target
-
containsAll
是否包含全部指定元素。- Parameters:
collection- 集合values- 要检查的元素- Returns:
- 是否全部包含
-
containsAll
是否包含另一集合全部元素。- Parameters:
collection- 集合target- 目标集合- Returns:
- 是否全部包含
-
sortByProperty
按属性升序排序。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合property- 属性名- Returns:
- 排序后的列表
-
sortByProperty
public static <T> List<T> sortByProperty(Collection<T> collection, String property, boolean isAscending) -
split
-
sum
-
sumLong
-
sumDouble
double 集合求和。- Parameters:
coll- 集合- Returns:
- 和
-
min
最小值(Comparable 集合,null 安全)。- Type Parameters:
T- 元素类型(Comparable)- Parameters:
collection- 集合- Returns:
- 最小值;空集合返回 null
-
max
最大值(Comparable 集合,null 安全)。- Type Parameters:
T- 元素类型(Comparable)- Parameters:
collection- 集合- Returns:
- 最大值;空集合返回 null
-
listToMap
List 转 Map(key 由函数提取,重复 key 后值覆盖)。- Type Parameters:
T- 元素类型K- 键类型- Parameters:
list- 列表keyFunction- 键提取函数- Returns:
- Map
-
minBy
public static <T, R extends Comparable<R>> T minBy(Collection<T> collection, Function<T, R> keyMapper) 按提取函数取最小值。- Type Parameters:
T- 元素类型R- 键类型- Parameters:
collection- 集合keyMapper- 提取函数- Returns:
- 最小元素;空集合返回 null
-
maxBy
public static <T, R extends Comparable<R>> T maxBy(Collection<T> collection, Function<T, R> keyMapper) 按提取函数取最大值。- Type Parameters:
T- 元素类型R- 键类型- Parameters:
collection- 集合keyMapper- 提取函数- Returns:
- 最大元素;空集合返回 null
-
zip
将两个集合按顺序配对为 Map。- Type Parameters:
K- 键类型V- 值类型- Parameters:
keys- 键集合values- 值集合- Returns:
- 配对后的 Map(LinkedHashMap,取较短长度)
-
removeNull
移除集合中的 null 元素,返回新列表。- Type Parameters:
T- 元素类型- Parameters:
coll- 集合- Returns:
- 不含 null 的新列表
-
sortByPropertyDesc
按属性降序排序。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合property- 属性名- Returns:
- 排序后的列表
-
indexOf
-
lastIndexOf
-
chunk
将集合按指定大小分片。- Type Parameters:
T- 元素类型- Parameters:
collection- 输入集合,可为空size- 每片大小,必须大于 0- Returns:
- 分片列表;输入为空时返回空列表
- Throws:
IllegalArgumentException- size 不大于 0- Since:
- 1.1.0
-
randomItem
从集合中随机取一个元素。- Type Parameters:
T- 元素类型- Parameters:
collection- 输入集合,不允许为空- Returns:
- 随机元素
- Throws:
IllegalArgumentException- 集合为空- Since:
- 1.1.0
-
randomItems
从集合中随机取指定数量的元素(不重复)。- Type Parameters:
T- 元素类型- Parameters:
collection- 输入集合,可为空count- 取样数量- Returns:
- 随机取样列表;count 不大于 0 时返回空列表
- Since:
- 1.1.0
-
toImmutable
返回集合的不可变副本。- Type Parameters:
T- 元素类型- Parameters:
collection- 输入集合,可为空- Returns:
- 不可变列表;输入为空时返回空列表
- Since:
- 1.1.0
-
frequency
统计元素在集合中出现的次数(基于Objects.equals(Object, Object))。- Type Parameters:
T- 元素类型- Parameters:
collection- 输入集合,可为空value- 目标元素- Returns:
- 出现次数
- Since:
- 1.1.0
-
rotate
-
removeEmpty
移除集合中的 null 与空元素(空字符串/空集合/空 Map)。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合- Returns:
- 过滤后的集合(原地移除)
-
removeAny
移除集合中的指定元素。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合values- 要移除的元素- Returns:
- 过滤后的集合(原地移除)
-
isAllEmpty
判断多个集合是否全部为空(null 或空集合视为空)。- Parameters:
collections- 集合数组- Returns:
- 全部为空返回
true
-
isAllNotNull
判断多个集合是否全部非空(非 null 且非空集合)。- Parameters:
collections- 集合数组- Returns:
- 全部非空返回
true
-
newTreeSet
创建带比较器的有序 Set(TreeSet),并填充元素。- Type Parameters:
T- 元素类型- Parameters:
comparator- 比较器(可空,空则自然序)values- 元素- Returns:
- TreeSet
- Since:
- 1.10.0
-
newConcurrentHashSet
创建线程安全的 Set(基于 ConcurrentHashMap),并填充元素。- Type Parameters:
T- 元素类型- Parameters:
values- 元素- Returns:
- 并发 Set
- Since:
- 1.10.0
-
flatMap
展平一层嵌套集合。- Type Parameters:
T- 元素类型- Parameters:
nested- 嵌套集合(内层可为空)- Returns:
- 展平后的列表
- Since:
- 1.10.0
-
swap
交换列表中两个位置的元素。- Type Parameters:
T- 元素类型- Parameters:
list- 列表index1- 位置一index2- 位置二- Returns:
- 本列表,支持链式调用
- Throws:
IndexOutOfBoundsException- 下标越界- Since:
- 1.10.0
-
toArray
-
maxCount
返回集合中出现次数最多的元素(众数);并列时取先出现的元素。- Type Parameters:
T- 元素类型- Parameters:
collection- 集合- Returns:
- 众数元素;集合为空返回
null - Since:
- 1.10.0
-
containsAny
两个集合是否存在交集。- Parameters:
c1- 集合一c2- 集合二- Returns:
- 存在交集返回
true - Since:
- 1.10.0
-
partitionBy
按谓词将集合分为「匹配」与「不匹配」两部分(均保序),等价于一次性完成 filter 与其补集。- Type Parameters:
T- 元素类型- Parameters:
collection- 待分集合(null 按空集合处理)predicate- 匹配谓词(null 时抛NullPointerException)- Returns:
- 二分结果
Partition - Since:
- 1.15.0
-
groupBy2
public static <T,K1, Map<K1, Map<K2,K2> List<T>>> groupBy2(Collection<T> collection, Function<T, K1> keyMapper1, Function<T, K2> keyMapper2) 按两级键进行嵌套分组:先按 keyMapper1 分组,组内再按 keyMapper2 分组(均保序)。- Type Parameters:
T- 元素类型K1- 一级键类型K2- 二级键类型- Parameters:
collection- 待分组集合(null 按空集合处理)keyMapper1- 一级键映射(null 时抛NullPointerException)keyMapper2- 二级键映射(null 时抛NullPointerException)- Returns:
- 两级嵌套分组(LinkedHashMap 保序)
- Since:
- 1.15.0
-
addAllDistinct
原地去重合并:将 source 中 target 尚不存在的元素追加到 target 末尾(保 source 顺序)。- Type Parameters:
T- 元素类型- Parameters:
target- 目标集合(null 时不操作,返回false)source- 来源可迭代对象(null 时不操作,返回false)- Returns:
- 发生变更(有新增元素)返回
true - Since:
- 1.15.0
-
removeAll
原地差集:从 target 中移除 source 出现的全部元素(重复元素全部移除,语义对齐subtract(Collection, Collection))。 source 与 target 为同一对象时同样安全(内部先复制)。- Type Parameters:
T- 元素类型- Parameters:
target- 目标集合(null 时不操作,返回false)source- 待移除元素来源(null 时不操作,返回false)- Returns:
- 发生变更(有元素被移除)返回
true - Since:
- 1.15.0
-
retainAll
原地交集:仅保留 target 中同时存在于 source 的元素(保 target 原有顺序)。- Type Parameters:
T- 元素类型- Parameters:
target- 目标集合(null 时不操作,返回false)source- 保留元素来源(null 时不操作,返回false)- Returns:
- 发生变更(有元素被移除)返回
true - Since:
- 1.15.0
-
flatten
两级扁平化:将「集合的集合」展开为单层列表,内层 null 集合跳过。- Type Parameters:
T- 元素类型- Parameters:
nested- 嵌套集合(null 按空集合处理)- Returns:
- 扁平化后的列表(保外层与内层顺序)
- Since:
- 1.15.0
-
pairwise
相邻配对:返回相邻元素的二元组列表,长度为 size-1;少于 2 个元素时返回空列表。- Type Parameters:
T- 元素类型- Parameters:
collection- 待配对集合(null 按空集合处理)- Returns:
- 相邻二元组列表(每对为不可变
List) - Since:
- 1.15.0
-
takeWhile
从头取满足谓词的元素前缀,遇到第一个不满足的元素即停止(Stream.takeWhile 的集合版)。- Type Parameters:
T- 元素类型- Parameters:
collection- 待取集合(null 按空集合处理)predicate- 满足条件(null 时抛NullPointerException)- Returns:
- 满足谓词的前缀列表(保序)
- Since:
- 1.15.0
-
groupBy
public static <T,K1, Map<K1, Map<K2,K2> List<T>>> groupBy(Collection<T> collection, Function<T, K1> key1Mapper, Function<T, K2> key2Mapper) 双键嵌套分组(对齐 GuavaMultimaps.index多层语义)。按两个键依次分组为
Map<K1, Map<K2, List<T>>>,内层保序 (LinkedHashMap / ArrayList)。- Type Parameters:
T- 元素类型K1- 第一级键类型K2- 第二级键类型- Parameters:
collection- 待分组集合,可为nullkey1Mapper- 第一级键提取key2Mapper- 第二级键提取- Returns:
- 嵌套分组 Map;
null输入返回空 Map - Since:
- 1.19.0
-
groupBy
@SafeVarargs public static <T> Map<Object,Object> groupBy(Collection<T> collection, Function<T, ?>... keyMappers) 多键链式分组(对齐 GuavaMultimaps.index)。按 N 个键依次嵌套分组,最内层为
List<T>;键提取器数组为空或null时按单键分组。- Type Parameters:
T- 元素类型- Parameters:
collection- 待分组集合,可为nullkeyMappers- 键提取器(可多个,变参)- Returns:
- 嵌套分组 Map;
null输入返回空 Map - Since:
- 1.19.0
-
cartesianProduct
public static <T> List<List<T>> cartesianProduct(Collection<? extends Collection<? extends T>> collections) 任意维度笛卡尔积(对齐 GuavaSets.cartesianProduct)。输入为集合的集合,每个内层集合为一个维度;任一维度为空时结果为空。
- Type Parameters:
T- 元素类型- Parameters:
collections- 维度集合(外层为维度,内层为取值),可为null- Returns:
- 笛卡尔积列表;
null返回空列表 - Since:
- 1.19.0
-