java.lang.Object
nl.basjes.parse.useragent.utils.springframework.util.CollectionUtils

public abstract class CollectionUtils extends Object
Miscellaneous collection utility methods. Mainly for internal use within the framework.
Since:
1.1.3
Author:
Juergen Hoeller, Rob Harrop, Arjen Poutsma
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    contains(Enumeration<?> enumeration, Object element)
    Check whether the given Enumeration contains the given element.
    static boolean
    contains(Iterator<?> iterator, Object element)
    Check whether the given Iterator contains the given element.
    static boolean
    isEmpty(Collection<?> collection)
    Return true if the supplied Collection is null or empty.
    static boolean
    isEmpty(Map<?,?> map)
    Return true if the supplied Map is null or empty.
    static <K, V> HashMap<K,V>
    newHashMap(int expectedSize)
    Instantiate a new {link HashMap} with an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • isEmpty

      public static boolean isEmpty(@Nullable Collection<?> collection)
      Return true if the supplied Collection is null or empty. Otherwise, return false.
      Parameters:
      collection - the Collection to check
      Returns:
      whether the given Collection is empty
    • isEmpty

      public static boolean isEmpty(@Nullable Map<?,?> map)
      Return true if the supplied Map is null or empty. Otherwise, return false.
      Parameters:
      map - the Map to check
      Returns:
      whether the given Map is empty
    • newHashMap

      public static <K, V> HashMap<K,V> newHashMap(int expectedSize)
      Instantiate a new {link HashMap} with an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.

      This differs from the regular {link HashMap} constructor which takes an initial capacity relative to a load factor but is effectively aligned with the JDK's {link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int)}.

      Parameters:
      expectedSize - the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed) see #newLinkedHashMap(int)
      Since:
      5.3
    • contains

      public static boolean contains(@Nullable Iterator<?> iterator, Object element)
      Check whether the given Iterator contains the given element.
      Parameters:
      iterator - the Iterator to check
      element - the element to look for
      Returns:
      true if found, false otherwise
    • contains

      public static boolean contains(@Nullable Enumeration<?> enumeration, Object element)
      Check whether the given Enumeration contains the given element.
      Parameters:
      enumeration - the Enumeration to check
      element - the element to look for
      Returns:
      true if found, false otherwise