public abstract class CollectionUtils extends Object
| Constructor and Description |
|---|
CollectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Collection<T> |
cloneCollection(Collection<T> collection) |
static <T> List<T> |
cloneList(List<T> list) |
static <K,V> Map<K,V> |
cloneMap(Map<K,V> map) |
static <T> boolean |
contains(Enumeration<T> enumeration,
T element)
Check whether the given Enumeration contains the given element.
|
static <T> boolean |
contains(Iterator<T> iterator,
T element)
Check whether the given Iterator contains the given element.
|
static <T> boolean |
containsAny(Collection<T> source,
Collection<T> candidates)
Return
true if any element in 'candidates' is contained in
'source'; otherwise returns false. |
static <T> boolean |
equals(Collection<T> c1,
Collection<T> c2) |
static <T> T |
findFirstMatch(Collection<T> source,
Collection<T> candidates)
Return the first element in '
candidates' that is contained in
'source'. |
static <T> T |
findValueOfType(Collection<T> collection,
Class<? extends T> type)
Find a value of the given type in the given collection.
|
static <T> T |
findValueOfType(Collection<T> collection,
Class<? extends T>[] types)
Find a value of one of the given types in the given collection: searching the collection for
a value of the first type, then searching for a value of the second type, etc.
|
static <T> T |
first(Collection<T> collection) |
static <T> boolean |
hasUniqueObject(Collection<T> collection)
Determine whether the given collection only contains a single unique object.
|
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 void |
mergePropertiesIntoMap(Properties props,
Map<String,String> map)
Merge the given Properties instance into the given Map, copying all properties (key-value
pairs) over.
|
static <T> List<T> |
toList(T... items)
Converts the supplied array into a List.
|
public static boolean isEmpty(Collection<?> collection)
true if the supplied Collection is null or empty. Otherwise,
return false.collection - the Collection to checkpublic static boolean isEmpty(Map<?,?> map)
true if the supplied Map is null or empty. Otherwise, return
false.map - the Map to checkpublic static <T> boolean contains(Iterator<T> iterator, T element)
iterator - the Iterator to checkelement - the element to look fortrue if found, false elsepublic static <T> boolean contains(Enumeration<T> enumeration, T element)
enumeration - the Enumeration to checkelement - the element to look fortrue if found, false elsepublic static <T> boolean hasUniqueObject(Collection<T> collection)
collection - the collection to checktrue if the collection contains a single reference or multiple
references to the same instance, false elsepublic static <T> T findValueOfType(Collection<T> collection, Class<? extends T> type) throws IllegalArgumentException
collection - the collection to searchtype - the type to look fornull if noneIllegalArgumentException - if more than one value of the given type foundpublic static <T> T findValueOfType(Collection<T> collection, Class<? extends T>[] types)
collection - the collection to searchtypes - the types to look for, in prioritized ordernull if noneIllegalArgumentException - if more than one value of the given type foundpublic static <T> List<T> toList(T... items)
source - the original arraypublic static void mergePropertiesIntoMap(Properties props, Map<String,String> map)
Uses Properties.propertyNames() to even catch default properties
linked into the original Properties instance.
props - the Properties instance to merge (may be null)map - the target Map to merge the properties intopublic static <T> boolean containsAny(Collection<T> source, Collection<T> candidates)
true if any element in 'candidates' is contained in
'source'; otherwise returns false.public static <T> T findFirstMatch(Collection<T> source, Collection<T> candidates)
candidates' that is contained in
'source'. If no element in 'candidates' is present in
'source' returns null. Iteration order is Collection
implementation specific.public static <T> boolean equals(Collection<T> c1, Collection<T> c2)
public static <T> Collection<T> cloneCollection(Collection<T> collection)
public static <T> T first(Collection<T> collection)
Copyright © GigaSpaces.