1 16 package org.apache.commons.collections; 17 18 import org.apache.commons.collections.bag.HashBag; 19 import org.apache.commons.collections.bag.PredicatedBag; 20 import org.apache.commons.collections.bag.PredicatedSortedBag; 21 import org.apache.commons.collections.bag.SynchronizedBag; 22 import org.apache.commons.collections.bag.SynchronizedSortedBag; 23 import org.apache.commons.collections.bag.TransformedBag; 24 import org.apache.commons.collections.bag.TransformedSortedBag; 25 import org.apache.commons.collections.bag.TreeBag; 26 import org.apache.commons.collections.bag.TypedBag; 27 import org.apache.commons.collections.bag.TypedSortedBag; 28 import org.apache.commons.collections.bag.UnmodifiableBag; 29 import org.apache.commons.collections.bag.UnmodifiableSortedBag; 30 31 43 public class BagUtils { 44 45 48 public static final Bag EMPTY_BAG = UnmodifiableBag.decorate(new HashBag()); 49 50 53 public static final Bag EMPTY_SORTED_BAG = UnmodifiableSortedBag.decorate(new TreeBag()); 54 55 59 public BagUtils() { 60 } 61 62 89 public static Bag synchronizedBag(Bag bag) { 90 return SynchronizedBag.decorate(bag); 91 } 92 93 102 public static Bag unmodifiableBag(Bag bag) { 103 return UnmodifiableBag.decorate(bag); 104 } 105 106 119 public static Bag predicatedBag(Bag bag, Predicate predicate) { 120 return PredicatedBag.decorate(bag, predicate); 121 } 122 123 132 public static Bag typedBag(Bag bag, Class type) { 133 return TypedBag.decorate(bag, type); 134 } 135 136 148 public static Bag transformedBag(Bag bag, Transformer transformer) { 149 return TransformedBag.decorate(bag, transformer); 150 } 151 152 180 public static SortedBag synchronizedSortedBag(SortedBag bag) { 181 return SynchronizedSortedBag.decorate(bag); 182 } 183 184 193 public static SortedBag unmodifiableSortedBag(SortedBag bag) { 194 return UnmodifiableSortedBag.decorate(bag); 195 } 196 197 210 public static SortedBag predicatedSortedBag(SortedBag bag, Predicate predicate) { 211 return PredicatedSortedBag.decorate(bag, predicate); 212 } 213 214 223 public static SortedBag typedSortedBag(SortedBag bag, Class type) { 224 return TypedSortedBag.decorate(bag, type); 225 } 226 227 239 public static SortedBag transformedSortedBag(SortedBag bag, Transformer transformer) { 240 return TransformedSortedBag.decorate(bag, transformer); 241 } 242 243 } 244 | Popular Tags |