public class CollectionUtils extends Object
| 构造器和说明 |
|---|
CollectionUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> Enumeration<T> |
asEnumeration(Iterator<T> iterator)
转换为 Enumeration
|
static <T> Enumeration<T> |
asEnumeration(List<T> list)
转换为 Enumeration
|
static <T> List<T> |
asList(Enumeration<T> enumeration) |
static <T> List<T> |
asList(Iterator<T> iterator) |
static <T> List<T> |
asList(T... arrays) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2,
K key3,
V val3) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2,
K key3,
V val3,
K key4,
V val4) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2,
K key3,
V val3,
K key4,
V val4,
K key5,
V val5) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2,
K key3,
V val3,
K key4,
V val4,
K key5,
V val5,
K key6,
V val6) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2,
K key3,
V val3,
K key4,
V val4,
K key5,
V val5,
K key6,
V val6,
K key7,
V val7) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2,
K key3,
V val3,
K key4,
V val4,
K key5,
V val5,
K key6,
V val6,
K key7,
V val7,
K key8,
V val8) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2,
K key3,
V val3,
K key4,
V val4,
K key5,
V val5,
K key6,
V val6,
K key7,
V val7,
K key8,
V val8,
K key9,
V val9) |
static <K,V> Map<K,V> |
asMap(K key1,
V val1,
K key2,
V val2,
K key3,
V val3,
K key4,
V val4,
K key5,
V val5,
K key6,
V val6,
K key7,
V val7,
K key8,
V val8,
K key9,
V val9,
K key0,
V val0) |
static <T> BufferedIterator<T> |
bufferedIterator(Iterator<T> oriIterator,
int bufferedSize) |
static boolean |
containsAny(Collection<?> coll1,
Collection<?> coll2)
Returns
true iff at least one element is in both collections. |
static <T,O> Iterator<O> |
convertIterator(Iterator<T> oriIterator,
Function<T,O> converter)
迭代器类型转换
|
static boolean |
isEmpty(Collection<?> tables) |
static boolean |
isEmpty(Map<?,?> maps) |
static boolean |
isEmpty(Object[] args) |
static boolean |
isNotEmpty(Collection<?> tables) |
static boolean |
isNotEmpty(Map<?,?> maps) |
static <T> Enumeration<T> |
mergeEnumeration(Enumeration<T> enum1,
Enumeration<T> enum2)
合并两个迭代器
|
static <T> Iterator<T> |
mergeIterator(Iterator<T> iterator1,
Iterator<T> iterator2)
合并两个迭代器
|
static int |
size(Collection<?> list) |
static int |
size(Map<?,?> map) |
static <T> List<List<T>> |
splitList(List<T> sourceList,
int groupSize)
切分list
|
static List<Map<String,Object>> |
toTree(List<Map<String,Object>> dataList,
String children,
String pathCode)
将 dataList 转换成 Tree 结构。
|
static List<Map<String,Object>> |
toTree(List<Map<String,Object>> dataList,
String children,
String treeID,
String parent)
将 dataList 转换成 Tree 结构。
|
static <T> List<T> |
toTree(List<T> dataList,
SFunction<T> children,
SFunction<T> pathCode)
将 dataList 转换成 Tree 结构。
|
static <T> List<T> |
toTree(List<T> dataList,
SFunction<T> children,
SFunction<T> treeID,
SFunction<T> parent)
将 dataList 转换成 Tree 结构。
|
public static boolean isNotEmpty(Collection<?> tables)
public static boolean isEmpty(Collection<?> tables)
public static boolean isNotEmpty(Map<?,?> maps)
public static boolean isEmpty(Map<?,?> maps)
public static int size(Collection<?> list)
public static int size(Map<?,?> map)
public static <T> List<List<T>> splitList(List<T> sourceList, int groupSize)
sourceList - groupSize - 每组定长public static <T> BufferedIterator<T> bufferedIterator(Iterator<T> oriIterator, int bufferedSize)
public static <T,O> Iterator<O> convertIterator(Iterator<T> oriIterator, Function<T,O> converter)
public static <T> Enumeration<T> asEnumeration(List<T> list)
public static <T> Enumeration<T> asEnumeration(Iterator<T> iterator)
public static <T> List<T> asList(Enumeration<T> enumeration)
public static <T> List<T> asList(T... arrays)
public static <K,V> Map<K,V> asMap(K key1, V val1)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2, K key3, V val3)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2, K key3, V val3, K key4, V val4)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2, K key3, V val3, K key4, V val4, K key5, V val5)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2, K key3, V val3, K key4, V val4, K key5, V val5, K key6, V val6)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2, K key3, V val3, K key4, V val4, K key5, V val5, K key6, V val6, K key7, V val7)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2, K key3, V val3, K key4, V val4, K key5, V val5, K key6, V val6, K key7, V val7, K key8, V val8)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2, K key3, V val3, K key4, V val4, K key5, V val5, K key6, V val6, K key7, V val7, K key8, V val8, K key9, V val9)
public static <K,V> Map<K,V> asMap(K key1, V val1, K key2, V val2, K key3, V val3, K key4, V val4, K key5, V val5, K key6, V val6, K key7, V val7, K key8, V val8, K key9, V val9, K key0, V val0)
public static <T> Enumeration<T> mergeEnumeration(Enumeration<T> enum1, Enumeration<T> enum2)
public static <T> Iterator<T> mergeIterator(Iterator<T> iterator1, Iterator<T> iterator2)
public static boolean isEmpty(Object[] args)
public static boolean containsAny(Collection<?> coll1, Collection<?> coll2)
true iff at least one element is in both collections.
In other words, this method returns true iff the
intersection of coll1 and coll2 is not empty.
coll1 - the first collection, must not be nullcoll2 - the first collection, must not be nulltrue iff the intersection of the collections is non-emptypublic static <T> List<T> toTree(List<T> dataList, SFunction<T> children, SFunction<T> treeID, SFunction<T> parent)
| ID | PID | NAME | ... | | 1 | NULL | TreeNode 1 | ... | | 2 | 1 | TreeNode 2 | ... | | 3 | 2 | TreeNode 3 | ... | | 4 | 1 | TreeNode 4 | ... | | 5 | NULL | TreeNode 5 | ... |
treeID - Tree 的 ID 属性parent - Tree 结构中父节点属性children - Tree 子节点列表public static List<Map<String,Object>> toTree(List<Map<String,Object>> dataList, String children, String treeID, String parent)
| ID | PID | NAME | ... | | 1 | NULL | TreeNode 1 | ... | | 2 | 1 | TreeNode 2 | ... | | 3 | 2 | TreeNode 3 | ... | | 4 | 1 | TreeNode 4 | ... | | 5 | NULL | TreeNode 5 | ... |
treeID - Tree 的 ID 属性parent - Tree 结构中父节点属性children - Tree 子节点列表public static <T> List<T> toTree(List<T> dataList, SFunction<T> children, SFunction<T> pathCode)
| ID | PATH | NAME | ... | | 1 | NULL | TreeNode 1 | ... | | 2 | /a | TreeNode 2 | ... | | 3 | /a/b | TreeNode 3 | ... | | 4 | /b | TreeNode 4 | ... | | 5 | /b/c | TreeNode 5 | ... |
pathCode - Tree 的 PATH 属性children - Tree 子节点列表public static List<Map<String,Object>> toTree(List<Map<String,Object>> dataList, String children, String pathCode)
| ID | PATH | NAME | ... | | 1 | NULL | TreeNode 1 | ... | | 2 | /a | TreeNode 2 | ... | | 3 | /a/b | TreeNode 3 | ... | | 4 | /b | TreeNode 4 | ... | | 5 | /b/c | TreeNode 5 | ... |
pathCode - Tree 的 PATH 属性children - Tree 子节点列表Copyright © 2022–2023. All rights reserved.