|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectxades4j.utils.CollectionUtils
public class CollectionUtils
Provides some utility methods over collections.
| Nested Class Summary | |
|---|---|
static interface |
CollectionUtils.Predicate<T>
|
static interface |
CollectionUtils.Projector<T1,T2>
|
| Constructor Summary | |
|---|---|
CollectionUtils()
|
|
| Method Summary | ||
|---|---|---|
static
|
cloneOrEmptyIfNull(Collection<T> c)
|
|
static
|
cloneOrEmptyIfNull(Map<TK,TV> m)
|
|
static
|
emptyIfNull(Collection<T> c)
Get an empty collection if the given collection is null. |
|
static
|
emptyIfNull(Map<TK,TV> m)
|
|
static
|
filter(Collection<T> c,
CollectionUtils.Predicate<T> p)
|
|
static
|
newIfNull(Collection<T> c,
int size)
Get a collection with the specified initial size if the given collection is null. |
|
static
|
newIfNull(Map<TK,TV> m,
int size)
Same as newIfNull but for maps. |
|
static
|
nullOrEmpty(Collection<T> c)
Indicates whether a collection is null or empty. |
|
static
|
project(Collection<TSrc> c,
CollectionUtils.Projector<TSrc,TDest> p)
|
|
| 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 <T> Collection<T> newIfNull(Collection<T> c,
int size)
null.
The returned collection, if new, will support the remove operation.
c - the collection to be testedsize - the initial size of the returned collection, if new
c if it is not null
public static <TK,TV> Map<TK,TV> newIfNull(Map<TK,TV> m,
int size)
newIfNull but for maps.
m - the map to be testedsize - the initial size of the returned map, if new
m if it is not nullpublic static <T> Collection<T> emptyIfNull(Collection<T> c)
null.
The returned collection, if new, is immutable.
c - the collection to be tested
c if it is not nullpublic static <TK,TV> Map<TK,TV> emptyIfNull(Map<TK,TV> m)
public static <T> Collection<T> cloneOrEmptyIfNull(Collection<T> c)
public static <TK,TV> Map<TK,TV> cloneOrEmptyIfNull(Map<TK,TV> m)
public static <T> boolean nullOrEmpty(Collection<T> c)
null or empty.
c - the collection to be tested
true if the collection is null or empty
public static <T> List<T> filter(Collection<T> c,
CollectionUtils.Predicate<T> p)
public static <TSrc,TDest> Collection<TDest> project(Collection<TSrc> c,
CollectionUtils.Projector<TSrc,TDest> p)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||