Package games.stendhal.common.filter
Interface FilterCriteria<T>
- Type Parameters:
T
- type of the item to check.
- All Known Implementing Classes:
SokobanReload
public interface FilterCriteria<T>
Title: FilterCriteria
Description: A FilterCriteria is added to the CollectionFilter to filter all the objects in the collection.
- Version:
- 1.0
- Author:
- David Rappoport
-
Method Summary
-
Method Details
-
passes
Implement this method to return true, if a given object in the collection should pass this filter. Example: Class Car has an attribute color (String). You only want Cars whose color equals "red". 1) Write the FilterCriteria implementation: class RedColorFilterCriteria implements FilterCriteria{ public boolean passes(Object o){ return ((Car)o).getColor().equals("red"); } } 2) Then add this FilterCriteria to a CollectionFilter: CollectionFilter filter = new CollectionFilter(); filter.addFilterCriteria(new ColorFilterCriteria()); 3) Now filter: filter.filter(carCollection);- Parameters:
o
- object- Returns:
- true, if a given object in the collection passes this filter.
-