public abstract class CollectionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
filterByType(Iterable<?> collection,
Class<T> expectedType)
Returns a list of objects of
expectedType contained in the given collection . |
static <T> T |
getAnnotation(Annotation[] annotations,
Class<T> annotationType)
Finds an annotation of given
annotationType from the given annotations . |
public static <T> List<T> filterByType(Iterable<?> collection, Class<T> expectedType)
expectedType
contained in the given collection
. Any
objects in the collection that are not assignable to the given expectedType
are filtered out.
The order of the items in the list is the same as the order they were provided by the collection. The given
collection
remains unchanged by this method.
If the given collection is null, en empty list is returned.T
- The type items in the returned List must be assignable to.collection
- An iterable (e.g. Collection) containing the unfiltered items.expectedType
- The type items in the returned List must be assignable to.expectedType
. May be empty, but never null
.public static <T> T getAnnotation(Annotation[] annotations, Class<T> annotationType)
annotationType
from the given annotations
. If
annotations
contains multiple annotations of the given type, the first one is returned. If none
is found, this method returns null
.T
- The type of annotation to search forannotations
- The annotations to search inannotationType
- The type of annotation to search fornull
if no such annotation is presentCopyright © 2010-2014. All Rights Reserved.