org.fest.util
Class TypeFilter<T>

java.lang.Object
  extended by 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 Object
implements CollectionFilter<T>

Understands filtering elements of a collection by their data type.

Author:
Yvonne Wang

Method Summary
static
<T> TypeFilter<T>
byType(Class<T> type)
          Creates a new TypeFilter.
 List<T> filter(Collection<?> target)
          Filters the given collection by the type specified in this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

byType

public static <T> TypeFilter<T> byType(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 List<T> filter(Collection<?> target)
Filters the given collection by the type specified in this filter.

Specified by:
filter in interface CollectionFilter<T>
Parameters:
target - the collection to filter.
Returns:
a list containing the filtered elements.
Throws:
IllegalArgumentException - if the given collection is null.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.