public class TransformedBuffer<E> extends TransformedCollection<E> implements Buffer<E>
Buffer to transform objects that are added.
The add methods are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.
This class is Serializable from Commons Collections 3.1.
transformercollection| Modifier | Constructor and Description |
|---|---|
protected |
TransformedBuffer(Buffer<E> buffer,
Transformer<? super E,? extends E> transformer)
Constructor that wraps (not copies).
|
| Modifier and Type | Method and Description |
|---|---|
E |
get()
Gets the next object from the buffer without removing it.
|
protected Buffer<E> |
getBuffer()
Gets the decorated buffer.
|
E |
remove()
Gets and removes the next object from the buffer.
|
static <E> TransformedBuffer<E> |
transformedBuffer(Buffer<E> buffer,
Transformer<? super E,? extends E> transformer)
Factory method to create a transforming buffer that will transform
existing contents of the specified buffer.
|
static <E> TransformedBuffer<E> |
transformingBuffer(Buffer<E> buffer,
Transformer<? super E,? extends E> transformer)
Factory method to create a transforming buffer.
|
add, addAll, transform, transform, transformedCollection, transformingCollectionclear, contains, containsAll, decorated, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toStringprotected TransformedBuffer(Buffer<E> buffer, Transformer<? super E,? extends E> transformer)
If there are any elements already in the buffer being decorated, they are NOT transformed.
buffer - the buffer to decorate, must not be nulltransformer - the transformer to use for conversion, must not be nullIllegalArgumentException - if buffer or transformer is nullpublic static <E> TransformedBuffer<E> transformingBuffer(Buffer<E> buffer, Transformer<? super E,? extends E> transformer)
If there are any elements already in the buffer being decorated, they
are NOT transformed.
Contrast this with transformedBuffer(Buffer, Transformer).
E - the type of the elements in the bufferbuffer - the buffer to decorate, must not be nulltransformer - the transformer to use for conversion, must not be nullIllegalArgumentException - if buffer or transformer is nullpublic static <E> TransformedBuffer<E> transformedBuffer(Buffer<E> buffer, Transformer<? super E,? extends E> transformer)
If there are any elements already in the buffer being decorated, they
will be transformed by this method.
Contrast this with transformingBuffer(Buffer, Transformer).
E - the type of the elements in the bufferbuffer - the buffer to decorate, must not be nulltransformer - the transformer to use for conversion, must not be nullIllegalArgumentException - if buffer or transformer is nullpublic E get()
BufferCopyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.