From 0cfaaf89e545f27fd66bc0b113485f349dc26361 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Tue, 15 Sep 2009 05:54:33 +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: ------------------------------------------------------------------------ r471579 | scolebourne | 2006-11-05 16:14:58 -0800 (Sun, 05 Nov 2006) | 1 line Generify, remove getBuffer() - use covariant decorated() ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815031 13f79535-47bb-0310-9956-ffa450edef68 --- .../buffer/SynchronizedBuffer.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java b/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java index 9b6aa0c9e..ddf357f40 100644 --- a/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java +++ b/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java @@ -27,12 +27,15 @@ import org.apache.commons.collections.collection.SynchronizedCollection; *

* This class is Serializable from Commons Collections 3.1. * + * @param the type of the elements in the buffer * @since Commons Collections 3.0 * @version $Revision$ $Date$ * * @author Stephen Colebourne */ -public class SynchronizedBuffer extends SynchronizedCollection implements Buffer { +public class SynchronizedBuffer + extends SynchronizedCollection + implements Buffer { /** Serialization version */ private static final long serialVersionUID = -6859936183953626253L; @@ -40,14 +43,15 @@ public class SynchronizedBuffer extends SynchronizedCollection implements Buffer /** * Factory method to create a synchronized buffer. * + * @param the type of the elements in the buffer * @param buffer the buffer to decorate, must not be null * @return a new synchronized Buffer * @throws IllegalArgumentException if buffer is null */ - public static Buffer decorate(Buffer buffer) { - return new SynchronizedBuffer(buffer); + public static Buffer decorate(Buffer buffer) { + return new SynchronizedBuffer(buffer); } - + //----------------------------------------------------------------------- /** * Constructor that wraps (not copies). @@ -55,7 +59,7 @@ public class SynchronizedBuffer extends SynchronizedCollection implements Buffer * @param buffer the buffer to decorate, must not be null * @throws IllegalArgumentException if the buffer is null */ - protected SynchronizedBuffer(Buffer buffer) { + protected SynchronizedBuffer(Buffer buffer) { super(buffer); } @@ -66,7 +70,7 @@ public class SynchronizedBuffer extends SynchronizedCollection implements Buffer * @param lock the lock object to use, must not be null * @throws IllegalArgumentException if the buffer is null */ - protected SynchronizedBuffer(Buffer buffer, Object lock) { + protected SynchronizedBuffer(Buffer buffer, Object lock) { super(buffer, lock); } @@ -75,21 +79,21 @@ public class SynchronizedBuffer extends SynchronizedCollection implements Buffer * * @return the decorated buffer */ - protected Buffer getBuffer() { - return (Buffer) collection; + protected Buffer decorated() { + return (Buffer) super.decorated(); } //----------------------------------------------------------------------- - public Object get() { + public E get() { synchronized (lock) { - return getBuffer().get(); + return decorated().get(); } } - public Object remove() { + public E remove() { synchronized (lock) { - return getBuffer().remove(); + return decorated().remove(); } } - + }