mirror of
https://github.com/apache/commons-collections.git
synced 2025-02-09 03:25:25 +00:00
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:
parent
5212b14250
commit
6b1e3197b5
@ -57,25 +57,25 @@ public abstract class AbstractBagDecorator
|
|||||||
*
|
*
|
||||||
* @return the decorated bag
|
* @return the decorated bag
|
||||||
*/
|
*/
|
||||||
protected Bag getBag() {
|
protected Bag decorated() {
|
||||||
return (Bag) getCollection();
|
return (Bag) super.decorated();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public int getCount(Object object) {
|
public int getCount(Object object) {
|
||||||
return getBag().getCount(object);
|
return decorated().getCount(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(Object object, int count) {
|
public boolean add(Object object, int count) {
|
||||||
return getBag().add(object, count);
|
return decorated().add(object, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(Object object, int count) {
|
public boolean remove(Object object, int count) {
|
||||||
return getBag().remove(object, count);
|
return decorated().remove(object, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set uniqueSet() {
|
public Set uniqueSet() {
|
||||||
return getBag().uniqueSet();
|
return decorated().uniqueSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,21 +56,21 @@ public abstract class AbstractSortedBagDecorator
|
|||||||
*
|
*
|
||||||
* @return the decorated bag
|
* @return the decorated bag
|
||||||
*/
|
*/
|
||||||
protected SortedBag getSortedBag() {
|
protected SortedBag decorated() {
|
||||||
return (SortedBag) getCollection();
|
return (SortedBag) super.decorated();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public Object first() {
|
public Object first() {
|
||||||
return getSortedBag().first();
|
return decorated().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object last() {
|
public Object last() {
|
||||||
return getSortedBag().last();
|
return decorated().last();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Comparator comparator() {
|
public Comparator comparator() {
|
||||||
return getSortedBag().comparator();
|
return decorated().comparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -84,26 +84,26 @@ public class PredicatedBag
|
|||||||
*
|
*
|
||||||
* @return the decorated bag
|
* @return the decorated bag
|
||||||
*/
|
*/
|
||||||
protected Bag getBag() {
|
protected Bag decorated() {
|
||||||
return (Bag) getCollection();
|
return (Bag) super.decorated();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public boolean add(Object object, int count) {
|
public boolean add(Object object, int count) {
|
||||||
validate(object);
|
validate(object);
|
||||||
return getBag().add(object, count);
|
return decorated().add(object, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(Object object, int count) {
|
public boolean remove(Object object, int count) {
|
||||||
return getBag().remove(object, count);
|
return decorated().remove(object, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set uniqueSet() {
|
public Set uniqueSet() {
|
||||||
return getBag().uniqueSet();
|
return decorated().uniqueSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount(Object object) {
|
public int getCount(Object object) {
|
||||||
return getBag().getCount(object);
|
return decorated().getCount(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,21 +83,21 @@ public class PredicatedSortedBag
|
|||||||
*
|
*
|
||||||
* @return the decorated bag
|
* @return the decorated bag
|
||||||
*/
|
*/
|
||||||
protected SortedBag getSortedBag() {
|
protected SortedBag decorated() {
|
||||||
return (SortedBag) getCollection();
|
return (SortedBag) super.decorated();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public Object first() {
|
public Object first() {
|
||||||
return getSortedBag().first();
|
return decorated().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object last() {
|
public Object last() {
|
||||||
return getSortedBag().last();
|
return decorated().last();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Comparator comparator() {
|
public Comparator comparator() {
|
||||||
return getSortedBag().comparator();
|
return decorated().comparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public final class UnmodifiableBag
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public Iterator iterator() {
|
public Iterator iterator() {
|
||||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(Object object) {
|
public boolean add(Object object) {
|
||||||
@ -135,7 +135,7 @@ public final class UnmodifiableBag
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set uniqueSet() {
|
public Set uniqueSet() {
|
||||||
Set set = getBag().uniqueSet();
|
Set set = decorated().uniqueSet();
|
||||||
return UnmodifiableSet.decorate(set);
|
return UnmodifiableSet.decorate(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public final class UnmodifiableSortedBag
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public Iterator iterator() {
|
public Iterator iterator() {
|
||||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(Object object) {
|
public boolean add(Object object) {
|
||||||
@ -135,7 +135,7 @@ public final class UnmodifiableSortedBag
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set uniqueSet() {
|
public Set uniqueSet() {
|
||||||
Set set = getBag().uniqueSet();
|
Set set = decorated().uniqueSet();
|
||||||
return UnmodifiableSet.decorate(set);
|
return UnmodifiableSet.decorate(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class TestPredicatedSortedBag extends AbstractTestSortedBag {
|
|||||||
|
|
||||||
public void testDecorate() {
|
public void testDecorate() {
|
||||||
SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
|
SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
|
||||||
SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag();
|
SortedBag bag2 = ((PredicatedSortedBag) bag).decorated();
|
||||||
try {
|
try {
|
||||||
SortedBag bag3 = decorateBag(new TreeBag(), null);
|
SortedBag bag3 = decorateBag(new TreeBag(), null);
|
||||||
fail("Expecting IllegalArgumentException for null predicate");
|
fail("Expecting IllegalArgumentException for null predicate");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user