| java.lang.Object org.springframework.util.CollectionUtils
CollectionUtils | abstract public class CollectionUtils (Code) | | Miscellaneous collection utility methods.
Mainly for internal use within the framework.
author: Juergen Hoeller author: Rob Harrop since: 1.1.3 |
Method Summary | |
public static List | arrayToList(Object source) Convert the supplied array into a List. | public static boolean | contains(Iterator iterator, Object element) Check whether the given Iterator contains the given element. | public static boolean | contains(Enumeration enumeration, Object element) Check whether the given Enumeration contains the given element. | public static boolean | containsAny(Collection source, Collection candidates) Return true if any element in 'candidates ' is
contained in 'source '; otherwise returns false . | public static boolean | containsInstance(Collection collection, Object element) Check whether the given Collection contains the given element instance. | public static Object | findFirstMatch(Collection source, Collection candidates) Return the first element in 'candidates ' that is contained in
'source '. | public static Object | findValueOfType(Collection collection, Class type) Find a value of the given type in the given Collection. | public 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. | public static boolean | hasUniqueObject(Collection collection) Determine whether the given Collection only contains a single unique object. | public static boolean | isEmpty(Collection collection) Return true if the supplied Collection is null
or empty. | public static boolean | isEmpty(Map map) Return true if the supplied Map is null
or empty. | public static void | mergeArrayIntoCollection(Object array, Collection collection) Merge the given array into the given Collection. | public static void | mergePropertiesIntoMap(Properties props, Map map) Merge the given Properties instance into the given Map,
copying all properties (key-value pairs) over. |
arrayToList | public static List arrayToList(Object source)(Code) | | Convert the supplied array into a List. A primitive array gets
converted into a List of the appropriate wrapper type.
A null source value will be converted to an
empty List.
Parameters: source - the (potentially primitive) array the converted List result See Also: ObjectUtils.toObjectArray(Object) |
contains | public static boolean contains(Iterator iterator, Object element)(Code) | | Check whether the given Iterator contains the given element.
Parameters: iterator - the Iterator to check Parameters: element - the element to look for true if found, false else |
contains | public static boolean contains(Enumeration enumeration, Object element)(Code) | | Check whether the given Enumeration contains the given element.
Parameters: enumeration - the Enumeration to check Parameters: element - the element to look for true if found, false else |
containsAny | public static boolean containsAny(Collection source, Collection candidates)(Code) | | Return true if any element in 'candidates ' is
contained in 'source '; otherwise returns false .
Parameters: source - the source Collection Parameters: candidates - the candidates to search for whether any of the candidates has been found |
containsInstance | public static boolean containsInstance(Collection collection, Object element)(Code) | | Check whether the given Collection contains the given element instance.
Enforces the given instance to be present, rather than returning
true for an equal element as well.
Parameters: collection - the Collection to check Parameters: element - the element to look for true if found, false else |
findFirstMatch | public static Object findFirstMatch(Collection source, Collection candidates)(Code) | | Return the first element in 'candidates ' that is contained in
'source '. If no element in 'candidates ' is present in
'source ' returns null . Iteration order is
Collection implementation specific.
Parameters: source - the source Collection Parameters: candidates - the candidates to search for the first present object, or null if not found |
findValueOfType | public static Object findValueOfType(Collection collection, Class type) throws IllegalArgumentException(Code) | | Find a value of the given type in the given Collection.
Parameters: collection - the Collection to search Parameters: type - the type to look for a value of the given type found, or null if none throws: IllegalArgumentException - if more than one value of the given type found |
findValueOfType | public static Object findValueOfType(Collection collection, Class[] types) throws IllegalArgumentException(Code) | | 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.
Parameters: collection - the collection to search Parameters: types - the types to look for, in prioritized order a of one of the given types found, or null if none throws: IllegalArgumentException - if more than one value of the given type found |
hasUniqueObject | public static boolean hasUniqueObject(Collection collection)(Code) | | Determine whether the given Collection only contains a single unique object.
Parameters: collection - the Collection to check true if the collection contains a single reference ormultiple references to the same instance, false else |
isEmpty | public static boolean isEmpty(Collection collection)(Code) | | Return true if the supplied Collection is null
or empty. Otherwise, return false .
Parameters: collection - the Collection to check whether the given Collection is empty |
isEmpty | public static boolean isEmpty(Map map)(Code) | | Return true if the supplied Map is null
or empty. Otherwise, return false .
Parameters: map - the Map to check whether the given Map is empty |
mergeArrayIntoCollection | public static void mergeArrayIntoCollection(Object array, Collection collection)(Code) | | Merge the given array into the given Collection.
Parameters: array - the array to merge (may be null ) Parameters: collection - the target Collection to merge the array into |
mergePropertiesIntoMap | public static void mergePropertiesIntoMap(Properties props, Map map)(Code) | | Merge the given Properties instance into the given Map,
copying all properties (key-value pairs) over.
Uses Properties.propertyNames() to even catch
default properties linked into the original Properties instance.
Parameters: props - the Properties instance to merge (may be null ) Parameters: map - the target Map to merge the properties into |
|
|