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
This commit is contained in:
parent
0cfaaf89e5
commit
23c8ad066a
|
@ -39,8 +39,8 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
*/
|
*/
|
||||||
public final class UnmodifiableBuffer
|
public final class UnmodifiableBuffer<E>
|
||||||
extends AbstractBufferDecorator
|
extends AbstractBufferDecorator<E>
|
||||||
implements Unmodifiable, Serializable {
|
implements Unmodifiable, Serializable {
|
||||||
|
|
||||||
/** Serialization version */
|
/** Serialization version */
|
||||||
|
@ -55,11 +55,11 @@ public final class UnmodifiableBuffer
|
||||||
* @return an unmodifiable Buffer
|
* @return an unmodifiable Buffer
|
||||||
* @throws IllegalArgumentException if buffer is null
|
* @throws IllegalArgumentException if buffer is null
|
||||||
*/
|
*/
|
||||||
public static Buffer decorate(Buffer buffer) {
|
public static <E> Buffer<E> decorate(Buffer<E> buffer) {
|
||||||
if (buffer instanceof Unmodifiable) {
|
if (buffer instanceof Unmodifiable) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
return new UnmodifiableBuffer(buffer);
|
return new UnmodifiableBuffer<E>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -69,7 +69,7 @@ public final class UnmodifiableBuffer
|
||||||
* @param buffer the buffer to decorate, must not be null
|
* @param buffer the buffer to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if buffer is null
|
* @throws IllegalArgumentException if buffer is null
|
||||||
*/
|
*/
|
||||||
private UnmodifiableBuffer(Buffer buffer) {
|
private UnmodifiableBuffer(Buffer<E> buffer) {
|
||||||
super(buffer);
|
super(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,21 +92,22 @@ public final class UnmodifiableBuffer
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
collection = (Collection) in.readObject();
|
collection = (Collection<E>) in.readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public Iterator iterator() {
|
public Iterator<E> iterator() {
|
||||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
return UnmodifiableIterator.decorate(decorated().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(Object object) {
|
public boolean add(Object object) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAll(Collection coll) {
|
public boolean addAll(Collection<? extends E> coll) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,16 +119,16 @@ public final class UnmodifiableBuffer
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeAll(Collection coll) {
|
public boolean removeAll(Collection<?> coll) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean retainAll(Collection coll) {
|
public boolean retainAll(Collection<?> coll) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public Object remove() {
|
public E remove() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue