|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.springsource.util.common.CollectionUtils
public abstract class CollectionUtils
Miscellaneous collection utility methods.
Constructor Summary | |
---|---|
CollectionUtils()
|
Method Summary | ||
---|---|---|
static
|
arrayToList(T[] source)
Convert the supplied array into a List. |
|
static boolean |
contains(java.util.Enumeration<?> enumeration,
java.lang.Object element)
Check whether the given Enumeration contains the given element. |
|
static boolean |
contains(java.util.Iterator<?> iterator,
java.lang.Object element)
Check whether the given Iterator contains the given element. |
|
static boolean |
containsAny(java.util.Collection<?> source,
java.util.Collection<?> candidates)
Return true if any element in 'candidates ' is
contained in 'source '; otherwise returns false . |
|
static boolean |
containsInstance(java.util.Collection<?> collection,
java.lang.Object element)
Check whether the given Collection contains the given element instance. |
|
static java.lang.Object |
findFirstMatch(java.util.Collection<?> source,
java.util.Collection<?> candidates)
Return the first element in ' candidates ' that is contained in
'source '. |
|
static java.lang.Object |
findValueOfType(java.util.Collection<?> collection,
java.lang.Class<?> type)
Find a single value of the given type in the given Collection. |
|
static java.lang.Object |
findValueOfType(java.util.Collection<?> collection,
java.lang.Class<?>[] types)
Find a single 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 boolean |
hasUniqueObject(java.util.Collection<?> collection)
Determine whether the given Collection only contains a single unique object. |
|
static boolean |
isEmpty(java.util.Collection<?> collection)
Return true if the supplied Collection is null
or empty. |
|
static boolean |
isEmpty(java.util.Map<?,?> map)
Return true if the supplied Map is null
or empty. |
|
static
|
mergeArrayIntoCollection(T[] array,
java.util.Collection<T> collection)
Merge the given array into the given Collection. |
|
static void |
mergePropertiesIntoMap(java.util.Properties props,
java.util.Map<? super java.lang.String,? super java.lang.String> map)
Merge the given Properties instance into the given Map, copying all properties (key-value pairs) over. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CollectionUtils()
Method Detail |
---|
public static boolean isEmpty(java.util.Collection<?> collection)
true
if the supplied Collection is null
or empty. Otherwise, return false
.
collection
- the Collection to check
public static boolean isEmpty(java.util.Map<?,?> map)
true
if the supplied Map is null
or empty. Otherwise, return false
.
map
- the Map to check
public static <T> java.util.List<T> arrayToList(T[] source)
A null
source value will be converted to an
empty List.
T
- the type of elements of the listsource
- the array
ObjectUtils.toObjectArray(Object)
public static <T> void mergeArrayIntoCollection(T[] array, java.util.Collection<T> collection)
T
- type of elements of arrayarray
- the array to merge (may be null
)collection
- the target Collection to merge the array intopublic static void mergePropertiesIntoMap(java.util.Properties props, java.util.Map<? super java.lang.String,? super java.lang.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 boolean contains(java.util.Iterator<?> iterator, java.lang.Object element)
iterator
- the Iterator to checkelement
- the element to look for
true
if found, false
elsepublic static boolean contains(java.util.Enumeration<?> enumeration, java.lang.Object element)
enumeration
- the Enumeration to checkelement
- the element to look for
true
if found, false
elsepublic static boolean containsInstance(java.util.Collection<?> collection, java.lang.Object element)
Enforces the given instance to be present, rather than returning
true
for an equal element as well.
collection
- the Collection to checkelement
- the element to look for
true
if found, false
elsepublic static boolean containsAny(java.util.Collection<?> source, java.util.Collection<?> candidates)
true
if any element in 'candidates
' is
contained in 'source
'; otherwise returns false
.
source
- the source Collectioncandidates
- the candidates to search for
public static java.lang.Object findFirstMatch(java.util.Collection<?> source, java.util.Collection<?> candidates)
candidates
' that is contained in
'source
'. If no element in 'candidates
' is present in
'source
' returns null
. Iteration order is
Collection
implementation specific.
source
- the source Collectioncandidates
- the candidates to search for
null
if not foundpublic static java.lang.Object findValueOfType(java.util.Collection<?> collection, java.lang.Class<?> type)
collection
- the Collection to searchtype
- the type to look for
null
if none or more than one such value foundpublic static java.lang.Object findValueOfType(java.util.Collection<?> collection, java.lang.Class<?>[] types)
collection
- the collection to searchtypes
- the types to look for, in prioritized order
null
if none or more than one such value foundpublic static boolean hasUniqueObject(java.util.Collection<?> collection)
collection
- the Collection to check
true
if the collection contains a single reference or
multiple references to the same instance, false
else
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |