Queue to transform objects that are added.
The add/offer 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.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| protected | TransformedQueue(final Queue<E>
the queue to decorate, must not be null queue, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public E | element()
Implements java. |
| protected Queue | |
| public boolean | offer(final E
the element to add obj)Implements java. |
| public E | peek()
Implements java. null if this queue is empty.
|
| public E | poll()
Implements java. null if this queue is empty.
|
| public E | |
| public static < the type of the elements in the queue E> TransformedQueue | Returns: a new transformed Queuethe queue to decorate, must not be null queue, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Factory method to create a transforming queue that will transform existing contents of the specified queue. |
| public static < the type of the elements in the queue E> TransformedQueue | Returns: a new transformed Queuethe queue to decorate, must not be null queue, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Factory method to create a transforming queue. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| TransformedQueue | back to summary |
|---|---|
| protected TransformedQueue(final Queue<E> queue, final Transformer<? super E, ? extends E> transformer) Constructor that wraps (not copies). If there are any elements already in the queue being decorated, they are NOT transformed.
| |
| element | back to summary |
|---|---|
| public E element() Implements java. Doc from java. Retrieves, but does not remove, the head of this queue. This method
differs from
| |
| getQueue | back to summary |
|---|---|
| protected Queue Gets the decorated queue.
| |
| offer | back to summary |
|---|---|
| public boolean offer(final E obj) Implements java. Doc from java. Inserts the specified element into this queue if it is possible to do
so immediately without violating capacity restrictions.
When using a capacity-restricted queue, this method is generally
preferable to
| |
| peek | back to summary |
|---|---|
| public E peek() Implements java. Doc from java. Retrieves, but does not remove, the head of this queue,
or returns
| |
| poll | back to summary |
|---|---|
| public E poll() Implements java. Doc from java. Retrieves and removes the head of this queue,
or returns
| |
| remove | back to summary |
|---|---|
| public E remove() Implements java. Doc from java. Retrieves and removes the head of this queue. This method differs
from
| |
| transformedQueue | back to summary |
|---|---|
| public static <E> TransformedQueue Factory method to create a transforming queue that will transform existing contents of the specified queue.
If there are any elements already in the queue being decorated, they
will be transformed by this method.
Contrast this with
| |
| transformingQueue | back to summary |
|---|---|
| public static <E> TransformedQueue Factory method to create a transforming queue.
If there are any elements already in the queue being decorated, they
are NOT transformed.
Contrast this with
| |