类 CollectionUtil


  • public class CollectionUtil
    extends org.springframework.util.CollectionUtils
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static <K,​V>
      V
      computeIfAbsent​(Map<K,​V> map, K key, Function<K,​V> mappingFunction)  
      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
      • 从类继承的方法 org.springframework.util.CollectionUtils

        arrayToList, contains, contains, containsAny, containsInstance, findCommonElementType, findFirstMatch, findValueOfType, findValueOfType, firstElement, firstElement, hasUniqueObject, isEmpty, isEmpty, lastElement, lastElement, mergeArrayIntoCollection, mergePropertiesIntoMap, newHashMap, newLinkedHashMap, toArray, toIterator, toMultiValueMap, unmodifiableMultiValueMap
    • 构造器详细资料

      • CollectionUtil

        public CollectionUtil()
    • 方法详细资料

      • isNotEmpty

        public static boolean isNotEmpty​(@Nullable
                                         Collection<?> collection)
        Return true if the supplied Collection is not null or empty. Otherwise, return false.
        参数:
        collection - the Collection to check
        返回:
        whether the given Collection is not empty
      • isNotEmpty

        public static boolean isNotEmpty​(@Nullable
                                         Map<?,​?> map)
        Return true if the supplied Map is not null or empty. Otherwise, return false.
        参数:
        map - the Map to check
        返回:
        whether the given Map is not empty
      • contains

        public static <T> boolean contains​(@Nullable
                                           T[] array,
                                           T element)
        Check whether the given Array contains the given element.
        类型参数:
        T - The generic tag
        参数:
        array - the Array to check
        element - the element to look for
        返回:
        true if found, false else
      • concat

        public static String[] concat​(String[] one,
                                      String[] other)
        Concatenates 2 arrays
        参数:
        one - 数组1
        other - 数组2
        返回:
        新数组
      • concat

        public static <T> T[] concat​(T[] one,
                                     T[] other,
                                     Class<T> clazz)
        Concatenates 2 arrays
        参数:
        one - 数组1
        other - 数组2
        clazz - 数组类
        返回:
        新数组
      • ofImmutableSet

        @SafeVarargs
        public static <E> Set<E> ofImmutableSet​(E... es)
        不可变 Set
        类型参数:
        E - 泛型
        参数:
        es - 对象
        返回:
        集合
      • ofImmutableList

        @SafeVarargs
        public static <E> List<E> ofImmutableList​(E... es)
        不可变 List
        类型参数:
        E - 泛型
        参数:
        es - 对象
        返回:
        集合
      • toList

        public static <E> List<E> toList​(Iterable<E> elements)
        Iterable 转换为List集合
        类型参数:
        E - 泛型
        参数:
        elements - Iterable
        返回:
        集合
      • toMap

        public static <K,​V> Map<K,​V> toMap​(Object... keysValues)
        将key value 数组转为 map
        类型参数:
        K - key
        V - value
        参数:
        keysValues - key value 数组
        返回:
        map 集合
      • computeIfAbsent

        public static <K,​V> V computeIfAbsent​(Map<K,​V> map,
                                                    K key,
                                                    Function<K,​V> mappingFunction)
      • partition

        public static <T> List<List<T>> partition​(List<T> list,
                                                  int size)
        list 分片
        类型参数:
        T - 泛型
        参数:
        list - List
        size - 分片大小
        返回:
        List 分片