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 ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815033 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
23c8ad066a
commit
4524029353
|
@ -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 @@ public class BufferUtils {
|
|||
/**
|
||||
* 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 @@ public class BufferUtils {
|
|||
* @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 @@ public class BufferUtils {
|
|||
* @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 @@ public class BufferUtils {
|
|||
* @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 @@ public class BufferUtils {
|
|||
* @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 @@ public class BufferUtils {
|
|||
* @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 @@ public class BufferUtils {
|
|||
* @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,24 +163,10 @@ public class BufferUtils {
|
|||
* @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>
|
||||
|
@ -197,8 +182,17 @@ public class BufferUtils {
|
|||
* @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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue