1 16 package org.apache.commons.collections.bag; 17 18 import java.util.Set ; 19 20 import org.apache.commons.collections.Bag; 21 import org.apache.commons.collections.Predicate; 22 import org.apache.commons.collections.collection.PredicatedCollection; 23 24 43 public class PredicatedBag 44 extends PredicatedCollection implements Bag { 45 46 47 private static final long serialVersionUID = -2575833140344736876L; 48 49 61 public static Bag decorate(Bag bag, Predicate predicate) { 62 return new PredicatedBag(bag, predicate); 63 } 64 65 77 protected PredicatedBag(Bag bag, Predicate predicate) { 78 super(bag, predicate); 79 } 80 81 86 protected Bag getBag() { 87 return (Bag) getCollection(); 88 } 89 90 public boolean add(Object object, int count) { 92 validate(object); 93 return getBag().add(object, count); 94 } 95 96 public boolean remove(Object object, int count) { 97 return getBag().remove(object, count); 98 } 99 100 public Set uniqueSet() { 101 return getBag().uniqueSet(); 102 } 103 104 public int getCount(Object object) { 105 return getBag().getCount(object); 106 } 107 108 } 109 | Popular Tags |