commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r815031 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java
Date Tue, 15 Sep 2009 05:54:34 GMT
Author: bayard
Date: Tue Sep 15 05:54:33 2009
New Revision: 815031

URL: http://svn.apache.org/viewvc?rev=815031&view=rev
Log:
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()
    ------------------------------------------------------------------------

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java?rev=815031&r1=815030&r2=815031&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/buffer/SynchronizedBuffer.java
Tue Sep 15 05:54:33 2009
@@ -27,12 +27,15 @@
  * <p>
  * This class is Serializable from Commons Collections 3.1.
  *
+ * @param <E> 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<E>
+        extends SynchronizedCollection<E>
+        implements Buffer<E> {
 
     /** Serialization version */
     private static final long serialVersionUID = -6859936183953626253L;
@@ -40,14 +43,15 @@
     /**
      * Factory method to create a synchronized buffer.
      * 
+     * @param <T> 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 <T> Buffer<T> decorate(Buffer<T> buffer) {
+        return new SynchronizedBuffer<T>(buffer);
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Constructor that wraps (not copies).
@@ -55,7 +59,7 @@
      * @param buffer  the buffer to decorate, must not be null
      * @throws IllegalArgumentException if the buffer is null
      */
-    protected SynchronizedBuffer(Buffer buffer) {
+    protected SynchronizedBuffer(Buffer<E> buffer) {
         super(buffer);
     }
 
@@ -66,7 +70,7 @@
      * @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<E> buffer, Object lock) {
         super(buffer, lock);
     }
 
@@ -75,21 +79,21 @@
      * 
      * @return the decorated buffer
      */
-    protected Buffer getBuffer() {
-        return (Buffer) collection;
+    protected Buffer<E> decorated() {
+        return (Buffer<E>) 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();
         }
     }
-    
+
 }



Mime
View raw message