Package games.stendhal.common.filter
Class CollectionFilter<T>
java.lang.Object
games.stendhal.common.filter.CollectionFilter<T>
- Type Parameters:
T
- generic type of collection elements
Title: CollectionFilter.
Description:
- Version:
- 1.0
- Author:
- David Rappoport
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFilterCriteria(FilterCriteria<T> filterCriteria)
Adds a FilterCriteria to be used by the filter.void
filter(Collection<T> collection)
Starts the filtering process.Collection<? extends T>
filterCopy(Collection<? extends T> inputCollection)
This method does the same as the filter method.
-
Constructor Details
-
CollectionFilter
public CollectionFilter()
-
-
Method Details
-
addFilterCriteria
Adds a FilterCriteria to be used by the filter.- Parameters:
filterCriteria
- criteria for the filter
-
filter
Starts the filtering process. For each object in the collection, all FilterCriteria are called. Only if the object passes all FilterCriteria it remains in the collection. Otherwise, it is removed.- Parameters:
collection
- collection to filter
-
filterCopy
This method does the same as the filter method. However, a copy of the original collection is created and filtered. The original collection remains unchanged and the copy is returned. Only use this method for collection classes that define a default constructor- Parameters:
inputCollection
- collection to copy- Returns:
- a filtered copy of the input collection
-