| Modifier and Type | Field and Description |
|---|---|
| public static final Bag | EMPTY_BAG
An empty unmodifiable bag. |
| public static final Bag | EMPTY_SORTED_BAG
An empty unmodifiable sorted bag. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static < the element type E> Bag | Returns: a Bag that complies to the Collection contractthe bag to decorate, must not be null bag)Returns a bag that complies to the Collection contract, backed by the given bag. |
| public static < the element type E> Bag | |
| public static < the element type E> SortedBag | |
| public static < the element type E> Bag | Returns: a predicated bag backed by the given bagthe bag to predicate, must not be null bag, final Predicate<? super E> the predicate for the bag, must not be null predicate)Returns a predicated (validating) bag backed by the given bag. |
| public static < the element type E> SortedBag | Returns: a predicated bag backed by the given bagthe sorted bag to predicate, must not be null bag, final Predicate<? super E> the predicate for the bag, must not be null predicate)Returns a predicated (validating) sorted bag backed by the given sorted bag. |
| public static < the element type E> Bag | Returns: a synchronized bag backed by that bagthe bag to synchronize, must not be null bag)Returns a synchronized (thread-safe) bag backed by the given bag. |
| public static < the element type E> SortedBag | Returns: a synchronized bag backed by that bagthe bag to synchronize, must not be null bag)Returns a synchronized (thread-safe) sorted bag backed by the given sorted bag. |
| public static < the element type E> Bag | Returns: a transformed bag backed by the given bagthe bag to predicate, must not be null bag, final Transformer<? super E, ? extends E> the transformer for the bag, must not be null transformer)Returns a transformed bag backed by the given bag. |
| public static < the element type E> SortedBag | Returns: a transformed bag backed by the given bagthe bag to predicate, must not be null bag, final Transformer<? super E, ? extends E> the transformer for the bag, must not be null transformer)Returns a transformed sorted bag backed by the given bag. |
| public static < the element type E> Bag | Returns: an unmodifiable view of that bagthe bag whose unmodifiable view is to be returned, must not be null bag)Returns an unmodifiable view of the given bag. |
| public static < the element type E> SortedBag | Returns: an unmodifiable view of that bagthe bag whose unmodifiable view is to be returned, must not be null bag)Returns an unmodifiable view of the given sorted bag. |
| EMPTY_BAG | back to summary |
|---|---|
| public static final Bag<E> EMPTY_BAG An empty unmodifiable bag.
| |
| EMPTY_SORTED_BAG | back to summary |
|---|---|
| public static final Bag<E> EMPTY_SORTED_BAG An empty unmodifiable sorted bag.
| |
| BagUtils | back to summary |
|---|---|
| private BagUtils() Instantiation of BagUtils is not intended or required. | |
| collectionBag | back to summary |
|---|---|
| public static <E> Bag Returns a bag that complies to the Collection contract, backed by the given bag.
| |
| emptyBag | back to summary |
|---|---|
| public static <E> Bag Get an empty
| |
| emptySortedBag | back to summary |
|---|---|
| public static <E> SortedBag Get an empty
| |
| predicatedBag | back to summary |
|---|---|
| public static <E> Bag Returns a predicated (validating) bag backed by the given bag. Only objects that pass the test in the given predicate can be added to the bag. Trying to add an invalid object results in an IllegalArgumentException. It is important not to use the original bag after invoking this method, as it is a backdoor for adding invalid objects.
| |
| predicatedSortedBag | back to summary |
|---|---|
| public static <E> SortedBag Returns a predicated (validating) sorted bag backed by the given sorted bag. Only objects that pass the test in the given predicate can be added to the bag. Trying to add an invalid object results in an IllegalArgumentException. It is important not to use the original bag after invoking this method, as it is a backdoor for adding invalid objects.
| |
| synchronizedBag | back to summary |
|---|---|
| public static <E> Bag Returns a synchronized (thread-safe) bag backed by the given bag. In order to guarantee serial access, it is critical that all access to the backing bag is accomplished through the returned bag. It is imperative that the user manually synchronize on the returned bag when iterating over it:
Bag bag = BagUtils.synchronizedBag(new HashBag());
...
synchronized(bag) {
Iterator i = bag.iterator(); // Must be in synchronized block
while (i.hasNext())
foo(i.next());
}
}
Failure to follow this advice may result in non-deterministic behavior.
| |
| synchronizedSortedBag | back to summary |
|---|---|
| public static <E> SortedBag Returns a synchronized (thread-safe) sorted bag backed by the given sorted bag. In order to guarantee serial access, it is critical that all access to the backing bag is accomplished through the returned bag. It is imperative that the user manually synchronize on the returned bag when iterating over it:
SortedBag bag = BagUtils.synchronizedSortedBag(new TreeBag());
...
synchronized(bag) {
Iterator i = bag.iterator(); // Must be in synchronized block
while (i.hasNext())
foo(i.next());
}
}
Failure to follow this advice may result in non-deterministic behavior.
| |
| transformingBag | back to summary |
|---|---|
| public static <E> Bag Returns a transformed bag backed by the given bag. Each object is passed through the transformer as it is added to the Bag. It is important not to use the original bag after invoking this method, as it is a backdoor for adding untransformed objects.
Existing entries in the specified bag will not be transformed.
If you want that behaviour, see
| |
| transformingSortedBag | back to summary |
|---|---|
| public static <E> SortedBag Returns a transformed sorted bag backed by the given bag. Each object is passed through the transformer as it is added to the Bag. It is important not to use the original bag after invoking this method, as it is a backdoor for adding untransformed objects.
Existing entries in the specified bag will not be transformed.
If you want that behaviour, see
| |
| unmodifiableBag | back to summary |
|---|---|
| public static <E> Bag Returns an unmodifiable view of the given bag. Any modification attempts
to the returned bag will raise an
| |
| unmodifiableSortedBag | back to summary |
|---|---|
| public static <E> SortedBag Returns an unmodifiable view of the given sorted bag. Any modification
attempts to the returned bag will raise an
| |