Warning
The methods of ForwardingQueue forward indiscriminately to the
methods of the delegate. For example, overriding add alone will not change the
behavior of offer which can lead to unexpected behavior. In this case, you should
override offer as well, either providing your own implementation, or delegating to the
provided standardOffer method.
default method warning: This class does not forward calls to default methods. Instead, it inherits their default implementations. When those implementations
invoke methods, they invoke methods on the ForwardingQueue.
The standard methods are not guaranteed to be thread-safe, even when all of the
methods that they depend on are thread-safe.
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract Queue | delegate()
Implements abstract com. |
| public E | element()
Implements java. |
| public boolean | offer(E
the element to add o)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 | |
| protected boolean | |
| protected E | |
| protected E |
| ForwardingQueue | back to summary |
|---|---|
| protected ForwardingQueue() Constructor for use by subclasses. | |
| delegate | back to summary |
|---|---|
| protected abstract Queue Implements abstract com. Doc from com. Returns the backing delegate instance that methods are forwarded to. Abstract subclasses
generally override this method with an abstract method that has a more specific return type,
such as
| |
| 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
| |
| offer | back to summary |
|---|---|
| public boolean offer(E o) 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
| |
| standardOffer | back to summary |
|---|---|
| protected boolean standardOffer(E e) A sensible definition of
| |
| standardPeek | back to summary |
|---|---|
| protected E standardPeek() A sensible definition of
| |
| standardPoll | back to summary |
|---|---|
| protected E standardPoll() A sensible definition of
| |