Remove getBag() - use covariant decorated()

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/branches/collections_jdk5_branch@471201 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2006-11-04 14:17:26 +00:00
parent 5212b14250
commit 6b1e3197b5
7 changed files with 27 additions and 27 deletions

View File

@ -57,25 +57,25 @@ public abstract class AbstractBagDecorator
*
* @return the decorated bag
*/
protected Bag getBag() {
return (Bag) getCollection();
protected Bag decorated() {
return (Bag) super.decorated();
}
//-----------------------------------------------------------------------
public int getCount(Object object) {
return getBag().getCount(object);
return decorated().getCount(object);
}
public boolean add(Object object, int count) {
return getBag().add(object, count);
return decorated().add(object, count);
}
public boolean remove(Object object, int count) {
return getBag().remove(object, count);
return decorated().remove(object, count);
}
public Set uniqueSet() {
return getBag().uniqueSet();
return decorated().uniqueSet();
}
}

View File

@ -56,21 +56,21 @@ public abstract class AbstractSortedBagDecorator
*
* @return the decorated bag
*/
protected SortedBag getSortedBag() {
return (SortedBag) getCollection();
protected SortedBag decorated() {
return (SortedBag) super.decorated();
}
//-----------------------------------------------------------------------
public Object first() {
return getSortedBag().first();
return decorated().first();
}
public Object last() {
return getSortedBag().last();
return decorated().last();
}
public Comparator comparator() {
return getSortedBag().comparator();
return decorated().comparator();
}
}

View File

@ -84,26 +84,26 @@ public class PredicatedBag
*
* @return the decorated bag
*/
protected Bag getBag() {
return (Bag) getCollection();
protected Bag decorated() {
return (Bag) super.decorated();
}
//-----------------------------------------------------------------------
public boolean add(Object object, int count) {
validate(object);
return getBag().add(object, count);
return decorated().add(object, count);
}
public boolean remove(Object object, int count) {
return getBag().remove(object, count);
return decorated().remove(object, count);
}
public Set uniqueSet() {
return getBag().uniqueSet();
return decorated().uniqueSet();
}
public int getCount(Object object) {
return getBag().getCount(object);
return decorated().getCount(object);
}
}

View File

@ -83,21 +83,21 @@ public class PredicatedSortedBag
*
* @return the decorated bag
*/
protected SortedBag getSortedBag() {
return (SortedBag) getCollection();
protected SortedBag decorated() {
return (SortedBag) super.decorated();
}
//-----------------------------------------------------------------------
public Object first() {
return getSortedBag().first();
return decorated().first();
}
public Object last() {
return getSortedBag().last();
return decorated().last();
}
public Comparator comparator() {
return getSortedBag().comparator();
return decorated().comparator();
}
}

View File

@ -98,7 +98,7 @@ public final class UnmodifiableBag
//-----------------------------------------------------------------------
public Iterator iterator() {
return UnmodifiableIterator.decorate(getCollection().iterator());
return UnmodifiableIterator.decorate(decorated().iterator());
}
public boolean add(Object object) {
@ -135,7 +135,7 @@ public final class UnmodifiableBag
}
public Set uniqueSet() {
Set set = getBag().uniqueSet();
Set set = decorated().uniqueSet();
return UnmodifiableSet.decorate(set);
}

View File

@ -98,7 +98,7 @@ public final class UnmodifiableSortedBag
//-----------------------------------------------------------------------
public Iterator iterator() {
return UnmodifiableIterator.decorate(getCollection().iterator());
return UnmodifiableIterator.decorate(decorated().iterator());
}
public boolean add(Object object) {
@ -135,7 +135,7 @@ public final class UnmodifiableSortedBag
}
public Set uniqueSet() {
Set set = getBag().uniqueSet();
Set set = decorated().uniqueSet();
return UnmodifiableSet.decorate(set);
}

View File

@ -80,7 +80,7 @@ public class TestPredicatedSortedBag extends AbstractTestSortedBag {
public void testDecorate() {
SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag();
SortedBag bag2 = ((PredicatedSortedBag) bag).decorated();
try {
SortedBag bag3 = decorateBag(new TreeBag(), null);
fail("Expecting IllegalArgumentException for null predicate");