类 CollectionUtils


  • public class CollectionUtils
    extends Object
    Miscellaneous collection utility methods. Mainly for internal use within the framework.
    从以下版本开始:
    2.0.7
    作者:
    william.liangf
    • 方法详细资料

      • sort

        public static <T> List<T> sort​(List<T> list)
      • mapEquals

        public static boolean mapEquals​(Map<?,​?> map1,
                                        Map<?,​?> map2)
      • toMap

        public static <K,​V> Map<K,​V> toMap​(Object... pairs)
      • isEmpty

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

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

        public static boolean isEmptyMap​(Map map)
        Return true if the supplied Map is null or empty. Otherwise, return false.
        参数:
        map - the Map to check
        返回:
        whether the given Map is empty
      • isNotEmptyMap

        public static boolean isNotEmptyMap​(Map map)
        Return true if the supplied Map is not null or not empty. Otherwise, return false.
        参数:
        map - the Map to check
        返回:
        whether the given Map is not empty
      • ofSet

        public static <T> Set<T> ofSet​(T... values)
        Convert to multiple values to be LinkedHashSet
        类型参数:
        T - the type of values
        参数:
        values - one or more values
        返回:
        read-only Set
      • size

        public static int size​(Collection<?> collection)
        Get the size of the specified Collection
        参数:
        collection - the specified Collection
        返回:
        must be positive number
        从以下版本开始:
        2.7.6
      • equals

        public static boolean equals​(Collection<?> one,
                                     Collection<?> another)
        Compares the specified collection with another, the main implementation references AbstractSet
        参数:
        one - Collection
        another - Collection
        返回:
        if equals, return true, or false
        从以下版本开始:
        2.7.6
      • addAll

        public static <T> int addAll​(Collection<T> collection,
                                     T... values)
        Add the multiple values into the specified collection
        类型参数:
        T - the type of values
        参数:
        collection - the specified collection
        values - the multiple values
        返回:
        the effected count after added
        从以下版本开始:
        2.7.6
      • first

        public static <T> T first​(Collection<T> values)
        Take the first element from the specified collection
        类型参数:
        T - the type of element of collection
        参数:
        values - the collection object
        返回:
        if found, return the first one, or null
        从以下版本开始:
        2.7.6