⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.bag

Class PredicatedSortedBag

java.lang.Object
|
+--org.apache.commons.collections.collection.AbstractCollectionDecorator
   |
   +--org.apache.commons.collections.collection.PredicatedCollection
      |
      +--org.apache.commons.collections.bag.PredicatedBag
         |
         +--org.apache.commons.collections.bag.PredicatedSortedBag

All Implemented Interfaces:
Collection, Bag, SortedBag


public class PredicatedSortedBag
extends PredicatedBag
implements SortedBag

Decorates another SortedBag to validate that additions match a specified predicate.

If an object cannot be added to the list, an IllegalArgumentException is thrown.

Since:
Commons Collections 3.0
Authors:
Stephen Colebourne
Paul Jack

Constructor Summary

PredicatedSortedBag(SortedBag bag, Predicate predicate)

Constructor that wraps (not copies).

Method Summary

Comparator

comparator()

static SortedBag

decorate(SortedBag bag, Predicate predicate)

Factory method to create a predicated (validating) bag.

Object

first()

SortedBag

getSortedBag()

Gets the decorated sorted bag.

Object

last()

Constructor Details

PredicatedSortedBag

protected PredicatedSortedBag(SortedBag bag, Predicate predicate)

Constructor that wraps (not copies).

If there are any elements already in the bag being decorated, they are validated.

Parameters:
bag - the bag to decorate, must not be null
predicate - the predicate to use for validation, must not be null
Throws:
- if bag or predicate is null
- if the bag contains invalid elements

Method Details

comparator

public Comparator comparator()


decorate

public static SortedBag decorate(SortedBag bag, Predicate predicate)

Factory method to create a predicated (validating) bag.

If there are any elements already in the bag being decorated, they are validated.

Parameters:
bag - the bag to decorate, must not be null
predicate - the predicate to use for validation, must not be null
Throws:
- if bag or predicate is null
- if the bag contains invalid elements

first

public Object first()


getSortedBag

protected SortedBag getSortedBag()

Gets the decorated sorted bag.

Returns:
the decorated bag

last

public Object last()