org.apache.commons.collections4.queue

## Class AbstractQueueDecorator<E>

- java.lang.Object
- - org.apache.commons.collections4.collection.AbstractCollectionDecorator<E>
  - - org.apache.commons.collections4.queue.AbstractQueueDecorator<E>

- Type Parameters:
    `E` - the type of the elements in the queue
  All Implemented Interfaces:
    Serializable, Iterable<E>, Collection<E>, Queue<E>
  Direct Known Subclasses:
    UnmodifiableQueue

      public abstract class AbstractQueueDecorator<E>
      extends AbstractCollectionDecorator<E>
      implements Queue<E>

  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
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractQueueDecorator()` Constructor only used in deserialization, do not use otherwise.
    `protected` | `AbstractQueueDecorator(Queue<E> queue)` Constructor that wraps (not copies).

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Queue<E>` | `decorated()` Gets the queue being decorated.
    `E` | `element()`
    `boolean` | `offer(E obj)`
    `E` | `peek()`
    `E` | `poll()`
    `E` | `remove()`

    - ### Methods inherited from class org.apache.commons.collections4.collection.AbstractCollectionDecorator

      `add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeIf, retainAll, setCollection, size, toArray, toArray, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Queue

      `add`

    - ### Methods inherited from interface java.util.Collection

      `addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Constructor Detail

    - #### AbstractQueueDecorator

          protected AbstractQueueDecorator()

      Constructor only used in deserialization, do not use otherwise.

    - #### AbstractQueueDecorator

          protected AbstractQueueDecorator(Queue<E> queue)

      Constructor that wraps (not copies).
      Parameters:
        `queue` - the queue to decorate, must not be null
      Throws:
        `NullPointerException` - if queue is null

  - ### Method Detail

    - #### decorated

          protected Queue<E> decorated()

      Gets the queue being decorated.
      Overrides:
        `decorated` in class `AbstractCollectionDecorator<E>`
      Returns:
        the decorated queue

    - #### offer

          public boolean offer(E obj)

      Specified by:
        `offer` in interface `Queue<E>`

    - #### poll

          public E poll()

      Specified by:
        `poll` in interface `Queue<E>`

    - #### peek

          public E peek()

      Specified by:
        `peek` in interface `Queue<E>`

    - #### element

          public E element()

      Specified by:
        `element` in interface `Queue<E>`

    - #### remove

          public E remove()

      Specified by:
        `remove` in interface `Queue<E>`

Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.