public class CollectionUtil
extends java.lang.Object
数组操作工具类
限定符和类型 | 类和说明 |
---|---|
static interface |
CollectionUtil.FilterSafeMapIteratee<T,P>
被迭代的转换器接口,跟MapIteratee的区别是convert方法不抛出异常
|
static interface |
CollectionUtil.MapIteratee<T,P>
被迭代的转换器接口
|
static interface |
CollectionUtil.SafeMapIteratee<T,P>
被迭代的转换器接口,跟MapIteratee的区别是convert方法不抛出异常
|
构造器和说明 |
---|
CollectionUtil() |
限定符和类型 | 方法和说明 |
---|---|
static <K,V> void |
addToListMap(K key,
V value,
java.util.Map<K,java.util.List<V>> targetMap)
将键值对添加到map中
|
static <K,V> void |
addToSetMap(K key,
java.util.Set<V> value,
java.util.Map<K,java.util.Set<V>> targetMap)
将键值对添加到map中
|
static <K,V> void |
addToSetMap(K key,
V value,
java.util.Map<K,java.util.Set<V>> targetMap)
将键值对添加到map中
|
static <K,V> void |
addToSetMapAll(java.util.Map<K,java.util.Set<V>> targetMap,
java.util.Map<K,java.util.Set<V>> sourceMap)
合并两个值为set的map
|
static <K,V> java.util.Map<K,V> |
convertToMap(java.util.Collection<V> list,
CollectionUtil.SafeMapIteratee<V,K> iteratee)
数组转map
|
static <K,V> java.util.Map<K,java.util.List<V>> |
convertToMapWithMultiValue(java.util.Collection<V> list,
CollectionUtil.SafeMapIteratee<V,K> iteratee)
数组转map,map的value是数组类型,适用于一对多的映射
|
static <T> java.util.List<T> |
getIntersection(java.util.List<T> array1,
java.util.List<T> array2)
取两个List的交集(null对象特殊处理,不参与交集运算)
|
static <K,V> java.util.Map<K,V> |
getIntersection(java.util.Map<K,V> map1,
java.util.Map<K,V> map2)
取两个map关于key的交集
|
static <T> java.util.Set<T> |
getIntersection(java.util.Set<T> set1,
java.util.Set<T> set2)
取两个set的交集
|
static <T> boolean |
isSetEquals(java.util.Set<T> set1,
java.util.Set<T> set2) |
static <T,P> java.util.List<P> |
map(java.util.Collection<T> tList,
CollectionUtil.MapIteratee<T,P> iteratee)
map操作
|
static <T,P> java.util.Set<P> |
mapToSet(java.util.Collection<T> list,
CollectionUtil.FilterSafeMapIteratee<T,P> iteratee)
list转set
|
static <T,P> java.util.Set<P> |
mapToSet(java.util.Collection<T> tList,
CollectionUtil.MapIteratee<T,P> iteratee)
map操作
|
static <T,P> java.util.Set<P> |
mapToSet(java.util.Collection<T> list,
CollectionUtil.SafeMapIteratee<T,P> iteratee)
list转set
|
public static <T,P> java.util.List<P> map(java.util.Collection<T> tList, CollectionUtil.MapIteratee<T,P> iteratee) throws java.lang.Exception
T
- 转换前列表项类型P
- 转换后列表项类型tList
- 转换前列表iteratee
- 转换器java.lang.Exception
public static <T,P> java.util.Set<P> mapToSet(java.util.Collection<T> tList, CollectionUtil.MapIteratee<T,P> iteratee) throws java.lang.Exception
T
- 转换前列表项类型P
- 转换后列表项类型tList
- 转换前列表iteratee
- 转换器java.lang.Exception
public static <T,P> java.util.Set<P> mapToSet(java.util.Collection<T> list, CollectionUtil.SafeMapIteratee<T,P> iteratee)
T
- 数组项类型P
- set项类型list
- 数组iteratee
- 提取set项的转换器public static <T,P> java.util.Set<P> mapToSet(java.util.Collection<T> list, CollectionUtil.FilterSafeMapIteratee<T,P> iteratee)
T
- 数组项类型P
- set项类型list
- 数组iteratee
- 带过滤的提取set项的转换器public static <K,V> java.util.Map<K,V> convertToMap(java.util.Collection<V> list, CollectionUtil.SafeMapIteratee<V,K> iteratee)
K
- key类型V
- value类型list
- 数组iteratee
- 提取key的转换器java.lang.Exception
public static <K,V> java.util.Map<K,java.util.List<V>> convertToMapWithMultiValue(java.util.Collection<V> list, CollectionUtil.SafeMapIteratee<V,K> iteratee)
K
- key类型V
- value类型list
- 数组iteratee
- 提取key的转换器java.lang.Exception
public static <K,V> java.util.Map<K,V> getIntersection(java.util.Map<K,V> map1, java.util.Map<K,V> map2)
K
- keyV
- valuemap1
- map1map2
- map2public static <T> java.util.Set<T> getIntersection(java.util.Set<T> set1, java.util.Set<T> set2)
T
- 类型set1
- set1set2
- set2public static <T> java.util.List<T> getIntersection(java.util.List<T> array1, java.util.List<T> array2) throws java.lang.Exception
T
- 类型array1
- array1array2
- array1java.lang.Exception
public static <K,V> void addToSetMap(K key, V value, java.util.Map<K,java.util.Set<V>> targetMap)
K
- 键类型V
- 值类型key
- 键value
- 值targetMap
- 目标mappublic static <K,V> void addToSetMap(K key, java.util.Set<V> value, java.util.Map<K,java.util.Set<V>> targetMap)
K
- 键类型V
- 值类型key
- 键value
- 值targetMap
- 目标mappublic static <K,V> void addToSetMapAll(java.util.Map<K,java.util.Set<V>> targetMap, java.util.Map<K,java.util.Set<V>> sourceMap)
K
- 键类型V
- 值类型targetMap
- 目标mapsourceMap
- 源mappublic static <K,V> void addToListMap(K key, V value, java.util.Map<K,java.util.List<V>> targetMap)
K
- 键类型V
- 值类型key
- 键value
- 值targetMap
- 目标mappublic static <T> boolean isSetEquals(java.util.Set<T> set1, java.util.Set<T> set2)