java.lang.Object |
↳ |
xades4j.utils.CollectionUtils |
Class Overview
Provides some utility methods over collections.
Summary
Nested Classes |
interface |
CollectionUtils.Predicate<T> |
|
interface |
CollectionUtils.Projector<T1, T2> |
|
Public Methods |
static
<T>
Collection<T>
|
cloneOrEmptyIfNull(Collection<T> c)
|
static
<TK, TV>
Map<TK, TV>
|
cloneOrEmptyIfNull(Map<TK, TV> m)
|
static
<TK, TV>
Map<TK, TV>
|
emptyIfNull(Map<TK, TV> m)
|
static
<T>
Collection<T>
|
emptyIfNull(Collection<T> c)
Get an empty collection if the given collection is null .
|
static
<T>
List<T>
|
filter(Collection<T> c, Predicate<T> p)
|
static
<T, T1 extends T>
List<T1>
|
filterByType(Collection<T> c, Class<T1> clazz)
|
static
<T>
Collection<T>
|
newIfNull(Collection<T> c, int size)
Get a collection with the specified initial size if the given collection is null .
|
static
<TK, TV>
Map<TK, TV>
|
newIfNull(Map<TK, TV> m, int size)
Same as newIfNull but for maps.
|
static
<T>
boolean
|
nullOrEmpty(Collection<T> c)
Indicates whether a collection is null or empty.
|
static
<TSrc, TDest>
List<TDest>
|
project(Collection<TSrc> c, Projector<TSrc, TDest> p)
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
Public Constructors
public
CollectionUtils
()
Public Methods
public
static
Collection<T>
cloneOrEmptyIfNull
(Collection<T> c)
public
static
Map<TK, TV>
cloneOrEmptyIfNull
(Map<TK, TV> m)
public
static
Map<TK, TV>
emptyIfNull
(Map<TK, TV> m)
public
static
Collection<T>
emptyIfNull
(Collection<T> c)
Get an empty collection if the given collection is null
.
The returned collection, if new, is immutable.
Parameters
c
| the collection to be tested |
Returns
- a new empty collection or
c
if it is not null
public
static
List<T>
filter
(Collection<T> c, Predicate<T> p)
public
static
List<T1>
filterByType
(Collection<T> c, Class<T1> clazz)
public
static
Collection<T>
newIfNull
(Collection<T> c, int size)
Get a collection with the specified initial size if the given collection is null
.
The returned collection, if new, will support the remove
operation.
Parameters
c
| the collection to be tested |
size
| the initial size of the returned collection, if new |
Returns
- a new collection or
c
if it is not null
public
static
Map<TK, TV>
newIfNull
(Map<TK, TV> m, int size)
Same as newIfNull
but for maps.
Parameters
m
| the map to be tested |
size
| the initial size of the returned map, if new |
Returns
- a new map or
m
if it is not null
public
static
boolean
nullOrEmpty
(Collection<T> c)
Indicates whether a collection is null
or empty.
Parameters
c
| the collection to be tested |
Returns
true
if the collection is null
or empty
public
static
List<TDest>
project
(Collection<TSrc> c, Projector<TSrc, TDest> p)