Set to validate that all additions
match a specified predicate.
This set exists to provide validation for the decorated set. It is normally created to decorate an empty set. If an object cannot be added to the set, an IllegalArgumentException is thrown.
One usage would be to ensure that no null entries are added to the set.
Set set = PredicatedSet.decorate(new HashSet(), NotNullPredicate.INSTANCE);
This class is Serializable from Commons Collections 3.1.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| protected | PredicatedSet(final Set<E>
the set to decorate, must not be null set, final Predicate<? super E> the predicate to use for validation, must not be null predicate)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| protected Set | Returns: the decorated setOverrides org. |
| public boolean | equals(final Object
object to be compared for equality with this set object)Overrides java. Implements java. |
| public int | hashCode()
Overrides java. Implements java. |
| public static < the element type E> PredicatedSet | Returns: a decorated setthe set to decorate, must not be null set, final Predicate<? super E> the predicate to use for validation, must not be null predicate)Factory method to create a predicated (validating) set. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| PredicatedSet | back to summary |
|---|---|
| protected PredicatedSet(final Set<E> set, final Predicate<? super E> predicate) Constructor that wraps (not copies). If there are any elements already in the set being decorated, they are validated.
| |
| decorated | back to summary |
|---|---|
| protected Set Overrides org. Gets the set being decorated. | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object object) Overrides java. Implements java. Doc from java. Compares the specified object with this set for equality. Returns
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this set. The hash code of a set is
defined to be the sum of the hash codes of the elements in the set,
where the hash code of a
| |
| predicatedSet | back to summary |
|---|---|
| public static <E> PredicatedSet Factory method to create a predicated (validating) set. If there are any elements already in the set being decorated, they are validated.
| |