public abstract class CollectionUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static Function |
TO_STRING_TRANSFORMER |
| Constructor and Description |
|---|
CollectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.Set |
asSet(java.lang.Class clazz,
java.lang.Object[] objects)
This utility method converts a vararg of Objects into a Set
|
static Filter |
containsFilter(java.util.Collection values) |
static java.util.List |
filter(java.util.Collection values,
Function filter)
Returns a filtered
List of values. |
static java.util.Map |
filterKeys(java.util.Map map,
Function filter)
This method can be used to filter a Map.
|
static java.lang.Object |
findFirst(java.util.Collection values,
Function acceptor)
Finds the first value for which
acceptor returns true. |
static java.util.List |
flatten(java.util.Collection values) |
static boolean |
isEmpty(java.util.Collection items) |
static java.util.List |
nullSafeAppend(java.util.List first,
java.util.List second)
This method joins two lists returning the a single list consisting of the first followed by the second.
|
static java.util.List |
nullSafeAppend(java.util.List first,
java.util.List second,
boolean emptyResultIsNull)
This method joins two lists returning the a single list consisting of the first followed by the second.
|
static java.util.Map |
nullSafeMerge(java.util.Map first,
java.util.Map second)
This method merges two maps returning the union of both maps.
|
static java.util.Map |
nullSafeMerge(java.util.Map first,
java.util.Map second,
boolean emptyResultIsNull)
This method merges two maps returning the union of both maps.
|
static java.util.Set |
nullSafeMerge(java.util.Set first,
java.util.Set second)
This method merges two sets returning the union of both sets.
|
static java.util.Set |
nullSafeMerge(java.util.Set first,
java.util.Set second,
boolean emptyResultIsNull)
This method merges two sets returning the union of both sets.
|
static java.util.List |
toListOfStrings(java.util.Collection values) |
static java.util.List |
transform(java.util.Collection values,
Function transformer)
Converts a
Collection of values of type F to a Serializable List of values of type T. |
static java.util.List |
transform(Function transformer,
java.lang.Object[] values)
Converts a
Collection of values of type F to a Serializable List of values of type T. |
static java.util.Map |
transform(java.util.Map map,
Function transformer) |
static java.util.List |
transformFlat(java.util.Collection values,
Function transformer) |
static java.util.Map |
transformToMap(java.util.Collection values,
Function transformer) |
static java.util.Set |
unmodifiableSet(java.util.Collection values)
Returns an immutable Serializable Set containing the values.
|
static java.util.Set |
unmodifiableSet(java.lang.Object[] values)
Returns an immutable Serializable Set containing the values.
|
public static final Function TO_STRING_TRANSFORMER
public static boolean isEmpty(java.util.Collection items)
public static java.util.Set nullSafeMerge(java.util.Set first,
java.util.Set second)
first - first set. can be null.second - second set. can be null.public static java.util.Set nullSafeMerge(java.util.Set first,
java.util.Set second,
boolean emptyResultIsNull)
first - first set. can be null.second - second set. can be null.if - the result is empty, should we return null?public static java.util.Map nullSafeMerge(java.util.Map first,
java.util.Map second)
first - first map. can be null.second - second map. can be null.public static java.util.Map nullSafeMerge(java.util.Map first,
java.util.Map second,
boolean emptyResultIsNull)
first - first map. can be null.second - second map. can be null.if - the result is empty, should we return null?public static java.util.List nullSafeAppend(java.util.List first,
java.util.List second)
first - first list. can be null.second - second list. can be null.public static java.util.List nullSafeAppend(java.util.List first,
java.util.List second,
boolean emptyResultIsNull)
first - first list. can be null.second - second list. can be null.emptyResultIsNull - if the result is empty, should we return null?public static java.util.List transform(java.util.Collection values,
Function transformer)
Collection of values of type F to a Serializable List of values of type T.
Filters out all values converted to null.values - the values to convert.transformer - Used to convert values.public static java.util.List transform(Function transformer, java.lang.Object[] values)
Collection of values of type F to a Serializable List of values of type T.
Filters out all values converted to null.values - the values to convert.transformer - Used to convert values.public static java.util.List toListOfStrings(java.util.Collection values)
public static java.util.Set asSet(java.lang.Class clazz,
java.lang.Object[] objects)
clazz - the Set type to return.objects - the objects to be added to the setjava.lang.ClassCastException - if any of the supplied objects are not of type T.public static java.util.List filter(java.util.Collection values,
Function filter)
List of values. Only values for which filter.apply(T) returns true are included in the List or returned values.values - the Collection to be filtered.filter - the Function used to filter the Collection.List of values.public static java.util.List flatten(java.util.Collection values)
public static java.util.List transformFlat(java.util.Collection values,
Function transformer)
public static java.lang.Object findFirst(java.util.Collection values,
Function acceptor)
acceptor returns true.values - acceptor - null.public static java.util.Set unmodifiableSet(java.lang.Object[] values)
values - public static java.util.Set unmodifiableSet(java.util.Collection values)
values - public static java.util.Map transformToMap(java.util.Collection values,
Function transformer)
entries - function - public static java.util.Map filterKeys(java.util.Map map,
Function filter)
filter function
returns true, will be included in the resultant Map, else they will not.map - the map whose entries are to be filtered.filter - the filter function which is applied to the key.public static java.util.Map transform(java.util.Map map,
Function transformer)
public static Filter containsFilter(java.util.Collection values)
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.