SortedBag to validate that additions
match a specified predicate.
This bag exists to provide validation for the decorated bag.
It is normally created to decorate an empty bag.
If an object cannot be added to the bag, an IllegalArgumentException is thrown.
One usage would be to ensure that no null entries are added to the bag.
SortedBag bag = PredicatedSortedBag.predicatedSortedBag(new TreeBag(), 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 | PredicatedSortedBag(final SortedBag<E>
the bag to decorate, must not be null bag, 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 |
|---|---|
| public Comparator | comparator()
Implements org. |
| protected SortedBag | Returns: the decorated bagOverrides org. |
| public E | first()
Implements org. |
| public E | |
| public static < the type of the elements in the bag E> PredicatedSortedBag | Returns: a new predicated SortedBagthe bag to decorate, must not be null bag, final Predicate<? super E> the predicate to use for validation, must not be null predicate)Factory method to create a predicated (validating) bag. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| PredicatedSortedBag | back to summary |
|---|---|
| protected PredicatedSortedBag(final SortedBag<E> bag, final Predicate<? super E> predicate) Constructor that wraps (not copies). If there are any elements already in the bag being decorated, they are validated.
| |
| comparator | back to summary |
|---|---|
| public Comparator Implements org. Doc from org. Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
| |
| decorated | back to summary |
|---|---|
| protected SortedBag Overrides org. Gets the decorated sorted bag. | |
| first | back to summary |
|---|---|
| public E first() Implements org. Doc from org. Returns the first (lowest) member.
| |
| last | back to summary |
|---|---|
| public E last() Implements org. Doc from org. Returns the last (highest) member.
| |
| predicatedSortedBag | back to summary |
|---|---|
| public static <E> PredicatedSortedBag Factory method to create a predicated (validating) bag. If there are any elements already in the bag being decorated, they are validated.
| |