diff --git a/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java b/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java index 2f5ab84d0..ab9c58eba 100644 --- a/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java +++ b/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java @@ -41,8 +41,8 @@ import org.apache.commons.collections.set.UnmodifiableSet; * * @author Stephen Colebourne */ -public final class UnmodifiableSortedBag - extends AbstractSortedBagDecorator implements Unmodifiable, Serializable { +public final class UnmodifiableSortedBag + extends AbstractSortedBagDecorator implements Unmodifiable, Serializable { /** Serialization version */ private static final long serialVersionUID = -3190437252665717841L; @@ -56,11 +56,11 @@ public final class UnmodifiableSortedBag * @return an unmodifiable SortedBag * @throws IllegalArgumentException if bag is null */ - public static SortedBag decorate(SortedBag bag) { + public static SortedBag decorate(SortedBag bag) { if (bag instanceof Unmodifiable) { return bag; } - return new UnmodifiableSortedBag(bag); + return new UnmodifiableSortedBag(bag); } //----------------------------------------------------------------------- @@ -70,7 +70,7 @@ public final class UnmodifiableSortedBag * @param bag the bag to decorate, must not be null * @throws IllegalArgumentException if bag is null */ - private UnmodifiableSortedBag(SortedBag bag) { + private UnmodifiableSortedBag(SortedBag bag) { super(bag); } @@ -93,21 +93,22 @@ public final class UnmodifiableSortedBag * @throws IOException * @throws ClassNotFoundException */ + @SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - collection = (Collection) in.readObject(); + collection = (Collection) in.readObject(); } //----------------------------------------------------------------------- - public Iterator iterator() { - return UnmodifiableIterator.decorate(getCollection().iterator()); + public Iterator iterator() { + return UnmodifiableIterator.decorate(decorated().iterator()); } - public boolean add(Object object) { + public boolean add(E object) { throw new UnsupportedOperationException(); } - public boolean addAll(Collection coll) { + public boolean addAll(Collection coll) { throw new UnsupportedOperationException(); } @@ -119,16 +120,16 @@ public final class UnmodifiableSortedBag throw new UnsupportedOperationException(); } - public boolean removeAll(Collection coll) { + public boolean removeAll(Collection coll) { throw new UnsupportedOperationException(); } - public boolean retainAll(Collection coll) { + public boolean retainAll(Collection coll) { throw new UnsupportedOperationException(); } //----------------------------------------------------------------------- - public boolean add(Object object, int count) { + public boolean add(E object, int count) { throw new UnsupportedOperationException(); } @@ -136,8 +137,8 @@ public final class UnmodifiableSortedBag throw new UnsupportedOperationException(); } - public Set uniqueSet() { - Set set = getBag().uniqueSet(); + public Set uniqueSet() { + Set set = decorated().uniqueSet(); return UnmodifiableSet.decorate(set); }