|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
net.sf.molae.pipe.filter.FilteredCollection<E>
public final class FilteredCollection<E>
Implements a collection that contains all elements of a base collection that match a filter condition.
| Constructor Summary | |
|---|---|
FilteredCollection(Collection<E> base,
TypedPredicate<? super E> filter)
Constructs a filtered collection from the specified collection and filter. |
|
| Method Summary | |
|---|---|
boolean |
add(E o)
Ensures that this collection contains the specified element if the element matches the filter. |
protected void |
assertRange(E o)
Checks if the specified object fulfils the filter predicate of this class. |
boolean |
contains(Object o)
Returns true if the base collection contains the specified
element and the element matches the underlying filter. |
protected Collection<E> |
getBase()
Returns the underlying collection. |
protected TypedPredicate<Object> |
getFilter()
Returns the underlying filter. |
Iterator<E> |
iterator()
|
boolean |
remove(Object o)
Removes a single instance of the specified element from the base collection, if it is present and matches the underlying filter. |
int |
size()
|
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, clear, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public FilteredCollection(Collection<E> base,
TypedPredicate<? super E> filter)
base - the underlying collectionfilter - predicate that determines which objects belong to the
collection
NullPointerException - if the specified objects are
null.| Method Detail |
|---|
protected Collection<E> getBase()
protected TypedPredicate<Object> getFilter()
protected void assertRange(E o)
o - object to evaluate.
IllegalArgumentException - if the specified object does not
fulfil the filter predicate of this class.public int size()
size in interface Collection<E>size in class AbstractCollection<E>public boolean contains(Object o)
true if the base collection contains the specified
element and the element matches the underlying filter.
contains in interface Collection<E>contains in class AbstractCollection<E>o - element whose presence in this collection is to be tested.
true if the base collection contains the specified
element and the element matches the underlying filterpublic Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>public boolean add(E o)
add in interface Collection<E>add in class AbstractCollection<E>UnsupportedOperationException - depending on the base collection
ClassCastException - depending on the base collection
IllegalArgumentException - if the specified object does not
fulfil the filter predicate of this class or the base collection
does not accept the element.public boolean remove(Object o)
remove in interface Collection<E>remove in class AbstractCollection<E>UnsupportedOperationException - depending on the base collection
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||