Is there a java collection class that provides a filter method? I'm a little new to java so navigating all the collection classes and all the subtle ways they intertwine with interfaces is a little confusing. What I would like is a collection class that does the following:
FilterableCollection<SomeClass> collection = new FilterableCollection<SomeClass>();
// add some elements to the collection
// filter the collection and only keep certain elements
FilterableCollection<SomeClass> filtered_collection = collection.filter(
new Filter<SomeClass>() {
@Override
public boolean test(SomeClass obj) {
// determine whether obj passes the test or not
}
}
);