ForwardingBlockingDeque
Date: 2016-05-24

com.google.common.collect

## Class ForwardingBlockingDeque<E>

- java.lang.Object
- - com.google.common.collect.ForwardingObject
  - - com.google.common.collect.ForwardingCollection<E>
    - - com.google.common.collect.ForwardingQueue<E>
      - - com.google.common.collect.ForwardingDeque<E>
        - - com.google.common.collect.ForwardingBlockingDeque<E>

- All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.concurrent.BlockingDeque<E>, java.util.concurrent.BlockingQueue<E>, java.util.Deque<E>, java.util.Queue<E>

      public abstract class ForwardingBlockingDeque<E>
      extends ForwardingDeque<E>
      implements java.util.concurrent.BlockingDeque<E>

  A `BlockingDeque` which forwards all its method calls to another `BlockingDeque`. Subclasses should override one or more methods to modify the behavior of the backing deque as desired per the decorator pattern.

  Warning: The methods of `ForwardingBlockingDeque` forward indiscriminately to the methods of the delegate. For example, overriding `ForwardingCollection.add(E)` alone will not change the behaviour of `offer(E, long, java.util.concurrent.TimeUnit)` which can lead to unexpected behaviour. In this case, you should override `offer` as well, either providing your own implementation, or delegating to the provided `standardOffer` method.

  The `standard` methods are not guaranteed to be thread-safe, even when all of the methods that they depend on are thread-safe.

  Since:
    14.0

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ForwardingBlockingDeque()` Constructor for use by subclasses.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract java.util.concurrent.BlockingDeque<E>` | `delegate()` Returns the backing delegate instance that methods are forwarded to.
    `int` | `drainTo(java.util.Collection<? super E> c)`
    `int` | `drainTo(java.util.Collection<? super E> c, int maxElements)`
    `boolean` | `offer(E e, long timeout, java.util.concurrent.TimeUnit unit)`
    `boolean` | `offerFirst(E e, long timeout, java.util.concurrent.TimeUnit unit)`
    `boolean` | `offerLast(E e, long timeout, java.util.concurrent.TimeUnit unit)`
    `E` | `poll(long timeout, java.util.concurrent.TimeUnit unit)`
    `E` | `pollFirst(long timeout, java.util.concurrent.TimeUnit unit)`
    `E` | `pollLast(long timeout, java.util.concurrent.TimeUnit unit)`
    `void` | `put(E e)`
    `void` | `putFirst(E e)`
    `void` | `putLast(E e)`
    `int` | `remainingCapacity()`
    `E` | `take()`
    `E` | `takeFirst()`
    `E` | `takeLast()`

    - ### Methods inherited from class com.google.common.collect.ForwardingDeque

      `addFirst, addLast, descendingIterator, getFirst, getLast, offerFirst, offerLast, peekFirst, peekLast, pollFirst, pollLast, pop, push, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence`

    - ### Methods inherited from class com.google.common.collect.ForwardingQueue

      `element, offer, peek, poll, remove, standardOffer, standardPeek, standardPoll`

    - ### Methods inherited from class com.google.common.collect.ForwardingCollection

      `add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray`

    - ### Methods inherited from class com.google.common.collect.ForwardingObject

      `toString`

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

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

    - ### Methods inherited from interface java.util.concurrent.BlockingDeque

      `add, addFirst, addLast, contains, element, iterator, offer, offerFirst, offerLast, peek, poll, push, remove, remove, removeFirstOccurrence, removeLastOccurrence, size`

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

      `descendingIterator, getFirst, getLast, peekFirst, peekLast, pollFirst, pollLast, pop, removeFirst, removeLast`

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

      `addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray`

- - ### Constructor Detail

    - #### ForwardingBlockingDeque

          protected ForwardingBlockingDeque()

      Constructor for use by subclasses.

  - ### Method Detail

    - #### delegate

          protected abstract java.util.concurrent.BlockingDeque<E> delegate()

      Description copied from class: `ForwardingObject`
      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 `ForwardingSet.delegate()`. Concrete subclasses override this method to supply the instance being decorated.
      Specified by:
        `delegate` in class `ForwardingDeque<E>`

    - #### remainingCapacity

          public int remainingCapacity()

      Specified by:
        `remainingCapacity` in interface `java.util.concurrent.BlockingQueue<E>`

    - #### putFirst

          public void putFirst(E e)
                        throws java.lang.InterruptedException

      Specified by:
        `putFirst` in interface `java.util.concurrent.BlockingDeque<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### putLast

          public void putLast(E e)
                       throws java.lang.InterruptedException

      Specified by:
        `putLast` in interface `java.util.concurrent.BlockingDeque<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### offerFirst

          public boolean offerFirst(E e,
                           long timeout,
                           java.util.concurrent.TimeUnit unit)
                             throws java.lang.InterruptedException

      Specified by:
        `offerFirst` in interface `java.util.concurrent.BlockingDeque<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### offerLast

          public boolean offerLast(E e,
                          long timeout,
                          java.util.concurrent.TimeUnit unit)
                            throws java.lang.InterruptedException

      Specified by:
        `offerLast` in interface `java.util.concurrent.BlockingDeque<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### takeFirst

          public E takeFirst()
                      throws java.lang.InterruptedException

      Specified by:
        `takeFirst` in interface `java.util.concurrent.BlockingDeque<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### takeLast

          public E takeLast()
                     throws java.lang.InterruptedException

      Specified by:
        `takeLast` in interface `java.util.concurrent.BlockingDeque<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### pollFirst

          public E pollFirst(long timeout,
                    java.util.concurrent.TimeUnit unit)
                      throws java.lang.InterruptedException

      Specified by:
        `pollFirst` in interface `java.util.concurrent.BlockingDeque<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### pollLast

          public E pollLast(long timeout,
                   java.util.concurrent.TimeUnit unit)
                     throws java.lang.InterruptedException

      Specified by:
        `pollLast` in interface `java.util.concurrent.BlockingDeque<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### put

          public void put(E e)
                   throws java.lang.InterruptedException

      Specified by:
        `put` in interface `java.util.concurrent.BlockingDeque<E>`
      Specified by:
        `put` in interface `java.util.concurrent.BlockingQueue<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### offer

          public boolean offer(E e,
                      long timeout,
                      java.util.concurrent.TimeUnit unit)
                        throws java.lang.InterruptedException

      Specified by:
        `offer` in interface `java.util.concurrent.BlockingDeque<E>`
      Specified by:
        `offer` in interface `java.util.concurrent.BlockingQueue<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### take

          public E take()
                 throws java.lang.InterruptedException

      Specified by:
        `take` in interface `java.util.concurrent.BlockingDeque<E>`
      Specified by:
        `take` in interface `java.util.concurrent.BlockingQueue<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### poll

          public E poll(long timeout,
               java.util.concurrent.TimeUnit unit)
                 throws java.lang.InterruptedException

      Specified by:
        `poll` in interface `java.util.concurrent.BlockingDeque<E>`
      Specified by:
        `poll` in interface `java.util.concurrent.BlockingQueue<E>`
      Throws:
        `java.lang.InterruptedException`

    - #### drainTo

          public int drainTo(java.util.Collection<? super E> c)

      Specified by:
        `drainTo` in interface `java.util.concurrent.BlockingQueue<E>`

    - #### drainTo

          public int drainTo(java.util.Collection<? super E> c,
                    int maxElements)

      Specified by:
        `drainTo` in interface `java.util.concurrent.BlockingQueue<E>`