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 . |
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
.Copyright © 2012. All Rights Reserved.