From 23c8ad066a4938711aeb9c192911c6a5d8029560 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Tue, 15 Sep 2009 05:54:35 +0000 Subject: [PATCH] Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956. Also see the following revisions: ------------------------------------------------------------------------ r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 line Remove getCollection() - use covariant decorated() ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815032 13f79535-47bb-0310-9956-ffa450edef68 --- .../buffer/UnmodifiableBuffer.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java b/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java index 4d1a6e360..b54ff17a4 100644 --- a/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java +++ b/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java @@ -39,8 +39,8 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator; * * @author Stephen Colebourne */ -public final class UnmodifiableBuffer - extends AbstractBufferDecorator +public final class UnmodifiableBuffer + extends AbstractBufferDecorator implements Unmodifiable, Serializable { /** Serialization version */ @@ -55,11 +55,11 @@ public final class UnmodifiableBuffer * @return an unmodifiable Buffer * @throws IllegalArgumentException if buffer is null */ - public static Buffer decorate(Buffer buffer) { + public static Buffer decorate(Buffer buffer) { if (buffer instanceof Unmodifiable) { return buffer; } - return new UnmodifiableBuffer(buffer); + return new UnmodifiableBuffer(buffer); } //----------------------------------------------------------------------- @@ -69,7 +69,7 @@ public final class UnmodifiableBuffer * @param buffer the buffer to decorate, must not be null * @throws IllegalArgumentException if buffer is null */ - private UnmodifiableBuffer(Buffer buffer) { + private UnmodifiableBuffer(Buffer buffer) { super(buffer); } @@ -92,21 +92,22 @@ public final class UnmodifiableBuffer * @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) { throw new UnsupportedOperationException(); } - public boolean addAll(Collection coll) { + public boolean addAll(Collection coll) { throw new UnsupportedOperationException(); } @@ -118,16 +119,16 @@ public final class UnmodifiableBuffer 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 Object remove() { + public E remove() { throw new UnsupportedOperationException(); }