You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:54:38 UTC
svn commit: r815033 -
/commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUtils.java
Author: bayard
Date: Tue Sep 15 05:54:37 2009
New Revision: 815033
URL: http://svn.apache.org/viewvc?rev=815033&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:
------------------------------------------------------------------------
r471166 | scolebourne | 2006-11-04 03:33:22 -0800 (Sat, 04 Nov 2006) | 1 line
Removed Typed* containers such as TypedList and TypedMap as generics now provides type safety
------------------------------------------------------------------------
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUtils.java
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUtils.java?rev=815033&r1=815032&r2=815033&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUtils.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUtils.java Tue Sep 15 05:54:37 2009
@@ -17,12 +17,11 @@
package org.apache.commons.collections;
import org.apache.commons.collections.buffer.BlockingBuffer;
+import org.apache.commons.collections.buffer.BoundedBuffer;
import org.apache.commons.collections.buffer.PredicatedBuffer;
import org.apache.commons.collections.buffer.SynchronizedBuffer;
import org.apache.commons.collections.buffer.TransformedBuffer;
-import org.apache.commons.collections.buffer.TypedBuffer;
import org.apache.commons.collections.buffer.UnmodifiableBuffer;
-import org.apache.commons.collections.buffer.BoundedBuffer;
/**
* Provides utility methods and decorators for {@link Buffer} instances.
@@ -38,7 +37,7 @@
/**
* An empty unmodifiable buffer.
*/
- public static final Buffer EMPTY_BUFFER = UnmodifiableBuffer.decorate(new ArrayStack(1));
+ public static final Buffer<Object> EMPTY_BUFFER = UnmodifiableBuffer.decorate(new ArrayStack<Object>(1));
/**
* <code>BufferUtils</code> should not normally be instantiated.
@@ -67,7 +66,7 @@
* @return a synchronized buffer backed by that buffer
* @throws IllegalArgumentException if the Buffer is null
*/
- public static Buffer synchronizedBuffer(Buffer buffer) {
+ public static <E> Buffer<E> synchronizedBuffer(Buffer<E> buffer) {
return SynchronizedBuffer.decorate(buffer);
}
@@ -83,7 +82,7 @@
* @return a blocking buffer backed by that buffer
* @throws IllegalArgumentException if the Buffer is null
*/
- public static Buffer blockingBuffer(Buffer buffer) {
+ public static <E> Buffer<E> blockingBuffer(Buffer<E> buffer) {
return BlockingBuffer.decorate(buffer);
}
@@ -101,7 +100,7 @@
* @throws IllegalArgumentException if the Buffer is null
* @since Commons Collections 3.2
*/
- public static Buffer blockingBuffer(Buffer buffer, long timeoutMillis) {
+ public static <E> Buffer<E> blockingBuffer(Buffer<E> buffer, long timeoutMillis) {
return BlockingBuffer.decorate(buffer, timeoutMillis);
}
@@ -118,7 +117,7 @@
* @throws IllegalArgumentException if the given buffer is null
* @since Commons Collections 3.2
*/
- public static Buffer boundedBuffer(Buffer buffer, int maximumSize) {
+ public static <E> Buffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize) {
return BoundedBuffer.decorate(buffer, maximumSize);
}
@@ -136,7 +135,7 @@
* @throws IllegalArgumentException if the given buffer is null
* @since Commons Collections 3.2
*/
- public static Buffer boundedBuffer(Buffer buffer, int maximumSize, long timeoutMillis) {
+ public static <E> Buffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize, long timeoutMillis) {
return BoundedBuffer.decorate(buffer, maximumSize, timeoutMillis);
}
@@ -147,7 +146,7 @@
* @return an unmodifiable buffer backed by that buffer
* @throws IllegalArgumentException if the Buffer is null
*/
- public static Buffer unmodifiableBuffer(Buffer buffer) {
+ public static <E> Buffer<E> unmodifiableBuffer(Buffer<E> buffer) {
return UnmodifiableBuffer.decorate(buffer);
}
@@ -164,25 +163,11 @@
* @return a predicated buffer
* @throws IllegalArgumentException if the Buffer or Predicate is null
*/
- public static Buffer predicatedBuffer(Buffer buffer, Predicate predicate) {
+ public static <E> Buffer<E> predicatedBuffer(Buffer<E> buffer, Predicate<? super E> predicate) {
return PredicatedBuffer.decorate(buffer, predicate);
}
/**
- * Returns a typed buffer backed by the given buffer.
- * <p>
- * Only elements of the specified type can be added to the buffer.
- *
- * @param buffer the buffer to predicate, must not be null
- * @param type the type to allow into the buffer, must not be null
- * @return a typed buffer
- * @throws IllegalArgumentException if the buffer or type is null
- */
- public static Buffer typedBuffer(Buffer buffer, Class type) {
- return TypedBuffer.decorate(buffer, type);
- }
-
- /**
* Returns a transformed buffer backed by the given buffer.
* <p>
* Each object is passed through the transformer as it is added to the
@@ -197,8 +182,17 @@
* @return a transformed buffer backed by the given buffer
* @throws IllegalArgumentException if the Buffer or Transformer is null
*/
- public static Buffer transformedBuffer(Buffer buffer, Transformer transformer) {
+ public static <E> Buffer<E> transformedBuffer(Buffer<E> buffer, Transformer<? super E, ? extends E> transformer) {
return TransformedBuffer.decorate(buffer, transformer);
}
+ /**
+ * Get an empty <code>Buffer</code>.
+ * @param <E>
+ * @return Buffer<E>
+ */
+ @SuppressWarnings("unchecked")
+ public static <E> Buffer<E> emptyBuffer() {
+ return (Buffer<E>) EMPTY_BUFFER;
+ }
}