public class CollectionUtil extends Object
| 构造器和说明 |
|---|
CollectionUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> List<T> |
asList(T... a)
将数组转换为List,如果数组为空则返回一个空list
|
static List<Map<String,Object>> |
filterEmpty(List<Map<String,Object>> list,
String... exceptKeys)
将List集合中的无效的map数据清空,被指定为排除的字段
即使map中这些指定字段有值,只要其他的key是无效的数据都会被被移除,但是0并不代表没有值
|
static <T> boolean |
isEmpty(Collection<T> collection)
checkEmpty:(检查集合是否为空,为空返回true)
|
static <T> boolean |
isNotEmpty(Collection<T> collection)
isNotEmpty:(检查集合是否为空,不为空返回true)
|
static <T> List<T> |
mergeAndSwap(List<T> result1,
List<T> result2)
较差合并两个list的各项值交叉合并,合并有先后顺序,对于集合数据不为空的情况,
result1的值第一个值放最前面
|
static <T> List<List<T>> |
partition(List<T> list,
int size)
partition list by size
|
static <T> List<T> |
slice(List<T> source,
int from,
int to)
slice list
|
static <T> Stream<T> |
slice(Stream<T> stream,
int startIndex,
int endIndex)
slice
|
public static <T> boolean isNotEmpty(Collection<T> collection)
T - type of paramcollection - collectionpublic static <T> boolean isEmpty(Collection<T> collection)
T - type of paramcollection - collectionpublic static <T> List<T> slice(List<T> source, int from, int to)
T - type of paramsource - data of listfrom - from index(included)to - to index(not included)public static <T> Stream<T> slice(Stream<T> stream, int startIndex, int endIndex)
T - type of paramstream - StreamstartIndex - (included)endIndex - (not included)public static <T> List<List<T>> partition(List<T> list, int size)
T - type of paramlist - List of datasize - page sizepublic static <T> List<T> asList(T... a)
T - type of parama - object arraypublic static <T> List<T> mergeAndSwap(List<T> result1, List<T> result2)
T - type of paramresult1 - first of listresult2 - second of listCopyright © 2021. All rights reserved.