Top Description Fields Constructors Methods
org.apache.commons.collections4.queue

public abstract Class AbstractQueueDecorator<E>

extends AbstractCollectionDecorator<E>
implements Queue<E>
Class Inheritance
All Implemented Interfaces
java.util.Queue, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
org.apache.commons.collections4.queue.UnmodifiableQueue
Type Parameters
<E>
the type of the elements in the queue
Imports
java.util.Queue, org.apache.commons.collections4.collection.AbstractCollectionDecorator

Decorates another Queue to provide additional behaviour.

Methods are forwarded directly to the decorated queue.

This implementation does not forward the hashCode and equals methods through to the backing object, but relies on Object's implementation. This is necessary as some Queue implementations, e.g. LinkedList, have custom a equals implementation for which symmetry can not be preserved. See class javadoc of AbstractCollectionDecorator for more information.

Since
4.0

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected
AbstractQueueDecorator()

Constructor only used in deserialization, do not use otherwise.

protected
AbstractQueueDecorator(final Queue<E>
the queue to decorate, must not be null
queue
)

Constructor that wraps (not copies).

Method Summary

Modifier and TypeMethod and Description
protected Queue<E>

Returns:

the decorated queue
decorated
()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.decorated.

Gets the queue being decorated.
public E
element()

Implements java.util.Queue.element.

Retrieves, but does not remove, the head of this queue.
public boolean
offer(final E
the element to add
obj
)

Implements java.util.Queue.offer.

Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
public E
peek()

Implements java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
public E
poll()

Implements java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.
public E
remove()

Implements java.util.Queue.remove.

Retrieves and removes the head of this queue.
Inherited from org.apache.commons.collections4.collection.AbstractCollectionDecorator:
addaddAllclearcontainscontainsAllisEmptyiteratorremoveremoveAllremoveIfretainAllsetCollectionsizetoArraytoArraytoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.collections4.collection.AbstractCollectionDecorator.serialVersionUID.

Serialization version

Constructor Detail

AbstractQueueDecoratorback to summary
protected AbstractQueueDecorator()

Constructor only used in deserialization, do not use otherwise.

AbstractQueueDecoratorback to summary
protected AbstractQueueDecorator(final Queue<E> queue)

Constructor that wraps (not copies).

Parameters
queue:Queue<E>

the queue to decorate, must not be null

Exceptions
NullPointerException:
if queue is null

Method Detail

decoratedback to summary
protected Queue<E> decorated()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.decorated.

Gets the queue being decorated.

Returns:Queue<E>

the decorated queue

Annotations
@Override
elementback to summary
public E element()

Implements java.util.Queue.element.

Doc from java.util.Queue.element.

Retrieves, but does not remove, the head of this queue. This method differs from peek only in that it throws an exception if this queue is empty.

Returns:E

the head of this queue

Annotations
@Override
offerback to summary
public boolean offer(final E obj)

Implements java.util.Queue.offer.

Doc from java.util.Queue.offer.

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 add, which can fail to insert an element only by throwing an exception.

Parameters
obj:E

the element to add

Returns:boolean

true if the element was added to this queue, else false

Annotations
@Override
peekback to summary
public E peek()

Implements java.util.Queue.peek.

Doc from java.util.Queue.peek.

Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

Returns:E

the head of this queue, or null if this queue is empty

Annotations
@Override
pollback to summary
public E poll()

Implements java.util.Queue.poll.

Doc from java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

Returns:E

the head of this queue, or null if this queue is empty

Annotations
@Override
removeback to summary
public E remove()

Implements java.util.Queue.remove.

Doc from java.util.Queue.remove.

Retrieves and removes the head of this queue. This method differs from poll() only in that it throws an exception if this queue is empty.

Returns:E

the head of this queue

Annotations
@Override