Class CollectionUtils
java.lang.Object
nl.basjes.parse.useragent.utils.springframework.util.CollectionUtils
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontains(Enumeration<?> enumeration, Object element) Check whether the given Enumeration contains the given element.static booleanCheck whether the given Iterator contains the given element.static booleanisEmpty(Collection<?> collection) Returntrueif the supplied Collection isnullor empty.static booleanReturntrueif the supplied Map isnullor 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.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
isEmpty
Returntrueif the supplied Collection isnullor empty. Otherwise, returnfalse.- Parameters:
collection- the Collection to check- Returns:
- whether the given Collection is empty
-
isEmpty
Returntrueif the supplied Map isnullor empty. Otherwise, returnfalse.- Parameters:
map- the Map to check- Returns:
- whether the given Map is empty
-
newHashMap
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
Check whether the given Iterator contains the given element.- Parameters:
iterator- the Iterator to checkelement- the element to look for- Returns:
trueif found,falseotherwise
-
contains
Check whether the given Enumeration contains the given element.- Parameters:
enumeration- the Enumeration to checkelement- the element to look for- Returns:
trueif found,falseotherwise
-