Package org.fest.util
Class TypeFilter<T>
- java.lang.Object
-
- org.fest.util.TypeFilter<T>
-
- Type Parameters:
T
- the generic type of the objects returned by the filter.
- All Implemented Interfaces:
CollectionFilter<T>
public class TypeFilter<T> extends java.lang.Object implements CollectionFilter<T>
Filters elements of a collection by their data type.- Author:
- Yvonne Wang
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> TypeFilter<T>
byType(java.lang.Class<T> type)
Creates a new
.TypeFilter
java.util.List<T>
filter(java.util.Collection<?> target)
Filters the given collection by the type specified in this filter.
-
-
-
Method Detail
-
byType
public static <T> TypeFilter<T> byType(java.lang.Class<T> type)
Creates a new
.TypeFilter
- Type Parameters:
T
- the generic type of the target type.- Parameters:
type
- the target type for this filter.- Returns:
- the created filter.
-
filter
public java.util.List<T> filter(java.util.Collection<?> target)
Filters the given collection by the type specified in this filter.- Specified by:
filter
in interfaceCollectionFilter<T>
- Parameters:
target
- the collection to filter.- Returns:
- a list containing the filtered elements.
- Throws:
java.lang.IllegalArgumentException
- if the given collection isnull
.
-
-