java.lang.Object | +--org.apache.commons.collections.collection.AbstractCollectionDecorator | +--org.apache.commons.collections.collection.PredicatedCollectionKnown Direct Subclasses:
The predicate to use |
PredicatedCollection(Collection coll, Predicate predicate) Constructor that wraps (not copies). |
boolean | add(Object object) Override to validate the object being added to ensure it matches the predicate. |
boolean | addAll(Collection coll) Override to validate the objects being added to ensure they match the predicate. |
static Collection | decorate(Collection coll, Predicate predicate) Factory method to create a predicated (validating) collection. |
void | validate(Object object) Validates the object being added to ensure it matches the predicate. |
protected final Predicate predicate
protected PredicatedCollection(Collection coll, Predicate predicate)
- if collection or predicate is null
- if the collection contains invalid elementspublic boolean add(Object object)
- if the add is invalidpublic boolean addAll(Collection coll)
- if the add is invalidpublic static Collection decorate(Collection coll, Predicate predicate)
- if collection or predicate is null
- if the collection contains invalid elementsprotected void validate(Object object)
- if the add is invalid
Collection
to validate that additions match a specified predicate. If an object cannot be added to the collection, an IllegalArgumentException is thrown.