| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.util.CollectionUtils
public abstract class CollectionUtils
Miscellaneous collection utility methods. Mainly for internal use within the framework.
| Constructor Summary | |
|---|---|
| CollectionUtils() | |
| Method Summary | |
|---|---|
| static List | arrayToList(Object source)Convert the supplied array into a List. | 
| 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 | containsAny(Collection source,
            Collection candidates)Return trueif any element in 'candidates' is
 contained in 'source'; otherwise returnsfalse. | 
| static boolean | containsInstance(Collection collection,
                 Object element)Check whether the given Collection contains the given element instance. | 
| static Object | findFirstMatch(Collection source,
               Collection candidates)Return the first element in ' candidates' that is contained in
 'source'. | 
| static Object | findValueOfType(Collection collection,
                Class type)Find a value of the given type in the given Collection. | 
| static Object | findValueOfType(Collection collection,
                Class[] 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 boolean | hasUniqueObject(Collection collection)Determine whether the given Collection only contains a single unique object. | 
| static boolean | isEmpty(Collection collection)Return trueif the supplied Collection isnullor empty. | 
| static boolean | isEmpty(Map map)Return trueif the supplied Map isnullor empty. | 
| static void | mergePropertiesIntoMap(Properties props,
                       Map 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(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 check
public static boolean containsInstance(Collection collection,
                                       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 else
public static boolean contains(Iterator iterator,
                               Object element)
iterator - the Iterator to checkelement - the element to look for
true if found, false else
public static boolean contains(Enumeration enumeration,
                               Object element)
enumeration - the Enumeration to checkelement - the element to look for
true if found, false elsepublic static boolean hasUniqueObject(Collection collection)
collection - the Collection to check
true if the collection contains a single reference or
 multiple references to the same instance, false else
public static Object findValueOfType(Collection collection,
                                     Class type)
                              throws IllegalArgumentException
collection - the Collection to searchtype - the type to look for
null if none
IllegalArgumentException - if more than one value of the given type found
public static Object findValueOfType(Collection collection,
                                     Class[] types)
                              throws IllegalArgumentException
collection - the collection to searchtypes - the types to look for, in prioritized order
null if none
IllegalArgumentException - if more than one value of the given type foundpublic static List arrayToList(Object source)
source - the original array
public static void mergePropertiesIntoMap(Properties props,
                                          Map 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 into
public static boolean containsAny(Collection source,
                                  Collection candidates)
true if any element in 'candidates' is
 contained in 'source'; otherwise returns false.
public static Object findFirstMatch(Collection source,
                                    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.
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||