public class CollectionUtils
extends java.lang.Object
Lightweight utility class for Collections.
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isNotEmpty(java.util.Collection<?> collection)
Utility method to check for a not empty
Collection including a null check. |
static <K,V> boolean |
isNotEmpty(java.util.Map<K,V> map)
Utility method to check for a not empty
Map including a null check. |
static <V> java.util.List<V> |
unmodifiableList(java.util.List<V> list)
Wraps a List with the
Collections.unmodifiableList, but only once. |
static <K,V> java.util.Map<K,V> |
unmodifiableMap(java.util.Map<K,V> map)
Wraps a Map with the
Collections.unmodifiableMap, but only once. |
public static boolean isNotEmpty(java.util.Collection<?> collection)
Collection including a null check.collection - Collection to test for non emptypublic static <K,V> boolean isNotEmpty(java.util.Map<K,V> map)
Map including a null check.K - Type of Key in MapV - Type of Value in Mapmap - Map to test for non emptypublic static <K,V> java.util.Map<K,V> unmodifiableMap(java.util.Map<K,V> map)
Collections.unmodifiableMap, but only once.
Checks the Map passed to ensure that it is not already a Collections.unmodifiableMap.
If the parameter is a null or empty, then it returns Collections.emptyMap.
K - Key typeV - Value typemap - Map to wrap with Collections.unmodifiableMappublic static <V> java.util.List<V> unmodifiableList(java.util.List<V> list)
Collections.unmodifiableList, but only once.
Checks the List passed to ensure that it is not already a Collections.unmodifiableLisy.
If the parameter is a null or empty, then it returns Collections.emptyList.
V - Value typelist - List to wrap with Collections.unmodifiableList