Class CollectionUtils
java.lang.Object
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
Collection工具类
- Since:
- 2016-09-19
- Author:
- Caratacus
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> V computeIfAbsent(Map<K, V> concurrentHashMap, K key, Function<? super K, ? extends V> mappingFunction) 用来过渡下Jdk1.8下ConcurrentHashMap的性能bug JDK-8161372static <K,V> List <V> getCollection(Map<K, V> map, Iterable<K> keys) 批量取出Map中的值static <K,V> List <V> getCollection(Map<K, V> map, Iterable<K> keys, Comparator<V> comparator) 批量取出Map中的值static booleanisEmpty(Collection<?> coll) 校验集合是否为空static boolean判断Map是否为空static booleanisNotEmpty(Collection<?> coll) 校验集合是否不为空static booleanisNotEmpty(Map<?, ?> map) 判断Map是否不为空static <K,V> HashMap <K, V> 创建默认HashMapstatic <K,V> HashMap <K, V> newHashMapWithExpectedSize(int expectedSize) 根据预期大小创建HashMap.split(Collection<T> entityList, int batchSize) 切割集合为多个集合static <T> List<T> toList(T... t) 构建List
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
isEmpty
校验集合是否为空- Parameters:
coll- 入参- Returns:
- boolean
-
isNotEmpty
校验集合是否不为空- Parameters:
coll- 入参- Returns:
- boolean
-
isEmpty
判断Map是否为空- Parameters:
map- 入参- Returns:
- boolean
-
isNotEmpty
判断Map是否不为空- Parameters:
map- 入参- Returns:
- boolean
-
newHashMap
创建默认HashMap- Type Parameters:
K- KV- V- Returns:
- HashMap
- Since:
- 3.4.0
- See Also:
-
newHashMapWithExpectedSize
根据预期大小创建HashMap.- Type Parameters:
K- KV- V- Parameters:
expectedSize- 预期大小- Returns:
- HashMap
- Since:
- 3.4.0
- See Also:
-
computeIfAbsent
public static <K,V> V computeIfAbsent(Map<K, V> concurrentHashMap, K key, Function<? super K, ? extends V> mappingFunction) 用来过渡下Jdk1.8下ConcurrentHashMap的性能bug JDK-8161372A temporary workaround for Java 8 ConcurrentHashMap#computeIfAbsent specific performance issue: JDK-8161372.
- Type Parameters:
K- kV- v- Parameters:
concurrentHashMap- ConcurrentHashMap 没限制类型了,非ConcurrentHashMap就别调用这方法了key- keymappingFunction- function- Returns:
- V
- Since:
- 3.4.0
- See Also:
-
getCollection
批量取出Map中的值- Type Parameters:
K- key的泛型V- value的泛型- Parameters:
map- mapkeys- 键的集合- Returns:
- value的泛型的集合
-
getCollection
public static <K,V> List<V> getCollection(Map<K, V> map, Iterable<K> keys, Comparator<V> comparator) 批量取出Map中的值- Type Parameters:
K- key的泛型V- value的泛型- Parameters:
map- mapkeys- 键的集合comparator- 排序器- Returns:
- value的泛型的集合
-
toList
构建List- Since:
- 3.5.4
-
split
切割集合为多个集合- Type Parameters:
T- 数据类型- Parameters:
entityList- 数据集合batchSize- 每批集合的大小- Returns:
- 切割后的多个集合
-