public class CollectionUtil
extends org.springframework.util.CollectionUtils
| Constructor and Description |
|---|
CollectionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> V |
computeIfAbsent(Map<K,V> map,
K key,
Function<K,V> mappingFunction)
A temporary workaround for Java 8 specific performance issue JDK-8161372 .
|
static String[] |
concat(String[] one,
String[] other)
Concatenates 2 arrays
|
static <T> T[] |
concat(T[] one,
T[] other,
Class<T> clazz)
Concatenates 2 arrays
|
static <T> boolean |
contains(T[] array,
T element)
Check whether the given Array contains the given element.
|
static boolean |
isNotEmpty(Collection<?> collection)
Return
true if the supplied Collection is not null or empty. |
static boolean |
isNotEmpty(Map<?,?> map)
Return
true if the supplied Map is not null or empty. |
static <E> List<E> |
ofImmutableList(E... es)
不可变 List
|
static <E> Set<E> |
ofImmutableSet(E... es)
不可变 Set
|
static <T> List<List<T>> |
partition(List<T> list,
int size)
list 分片
|
static <E> List<E> |
toList(Iterable<E> elements)
Iterable 转换为List集合
|
static <K,V> Map<K,V> |
toMap(Object... keysValues)
将key value 数组转为 map
|
arrayToList, contains, contains, containsAny, containsInstance, findCommonElementType, findFirstMatch, findValueOfType, findValueOfType, firstElement, firstElement, hasUniqueObject, isEmpty, isEmpty, lastElement, lastElement, mergeArrayIntoCollection, mergePropertiesIntoMap, newHashMap, newLinkedHashMap, toArray, toIterator, toMultiValueMap, unmodifiableMultiValueMappublic static boolean isNotEmpty(@Nullable
Collection<?> collection)
true if the supplied Collection is not null or empty.
Otherwise, return false.collection - the Collection to checkpublic static boolean isNotEmpty(@Nullable
Map<?,?> map)
true if the supplied Map is not null or empty.
Otherwise, return false.map - the Map to checkpublic static <T> boolean contains(@Nullable
T[] array,
T element)
T - The generic tagarray - the Array to checkelement - the element to look fortrue if found, false elsepublic static String[] concat(String[] one, String[] other)
one - 数组1other - 数组2public static <T> T[] concat(T[] one,
T[] other,
Class<T> clazz)
one - 数组1other - 数组2clazz - 数组类@SafeVarargs public static <E> Set<E> ofImmutableSet(E... es)
E - 泛型es - 对象@SafeVarargs public static <E> List<E> ofImmutableList(E... es)
E - 泛型es - 对象public static <E> List<E> toList(Iterable<E> elements)
E - 泛型elements - Iterablepublic static <K,V> Map<K,V> toMap(Object... keysValues)
K - keyV - valuekeysValues - key value 数组public static <K,V> V computeIfAbsent(Map<K,V> map, K key, Function<K,V> mappingFunction)
Copyright © 2024. All rights reserved.