java.lang.Object | +--org.apache.commons.collections.BagUtils
static Bag | An empty unmodifiable bag. |
static Bag | An empty unmodifiable sorted bag. |
BagUtils() Instantiation of BagUtils is not intended or required. |
static Bag | predicatedBag(Bag bag, Predicate predicate) Returns a predicated bag backed by the given bag. |
static SortedBag | predicatedSortedBag(SortedBag bag, Predicate predicate) Returns a predicated sorted bag backed by the given sorted bag. |
static Bag | synchronizedBag(Bag bag) Returns a synchronized (thread-safe) bag backed by the given bag. |
static SortedBag | synchronizedSortedBag(SortedBag bag) Returns a synchronized (thread-safe) sorted bag backed by the given sorted bag. |
static Bag | transformedBag(Bag bag, Transformer transformer) Returns a transformed bag backed by the given bag. |
static SortedBag | transformedSortedBag(SortedBag bag, Transformer transformer) Returns a transformed sorted bag backed by the given bag. |
static Bag | Returns a typed bag backed by the given bag. |
static SortedBag | typedSortedBag(SortedBag bag, Class type) Returns a typed sorted bag backed by the given bag. |
static Bag | unmodifiableBag(Bag bag) Returns an unmodifiable view of the given bag. |
static SortedBag | unmodifiableSortedBag(SortedBag bag) Returns an unmodifiable view of the given sorted bag. |
public static final Bag EMPTY_BAG
public static final Bag EMPTY_SORTED_BAG
public BagUtils()
public static Bag predicatedBag(Bag bag, Predicate predicate)
- if the Bag or Predicate is nullpublic static SortedBag predicatedSortedBag(SortedBag bag, Predicate predicate)
- if the SortedBag or Predicate is nullpublic static Bag synchronizedBag(Bag bag)
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.
- if the Bag is nullpublic static SortedBag synchronizedSortedBag(SortedBag bag)
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.
- if the SortedBag is nullpublic static Bag transformedBag(Bag bag, Transformer transformer)
- if the Bag or Transformer is nullpublic static SortedBag transformedSortedBag(SortedBag bag, Transformer transformer)
- if the Bag or Transformer is nullpublic static Bag typedBag(Bag bag, Class type)
public static SortedBag typedSortedBag(SortedBag bag, Class type)
public static Bag unmodifiableBag(Bag bag)
- if the Bag is nullpublic static SortedBag unmodifiableSortedBag(SortedBag bag)
- if the SortedBag is null