Class ForwardingBlockingDeque<E>
- All Implemented Interfaces:
Iterable<E>, Collection<E>, BlockingDeque<E>, BlockingQueue<E>, Deque<E>, Queue<E>, SequencedCollection<E>
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, 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.
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 ForwardingBlockingDeque.
The standard methods are not guaranteed to be thread-safe, even when all of the
methods that they depend on are thread-safe.
- Since:
- 21.0 (since 14.0 as
ForwardingBlockingDeque) - Author:
- Emily Soldal
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor for use by subclasses. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract BlockingDeque<E> delegate()Returns the backing delegate instance that methods are forwarded to.intdrainTo(Collection<? super E> c) intdrainTo(Collection<? super E> c, int maxElements) booleanbooleanofferFirst(E e, long timeout, TimeUnit unit) booleanvoidvoidvoidinttake()takeLast()Methods inherited from class ForwardingDeque
addFirst, addLast, descendingIterator, getFirst, getLast, offerFirst, offerLast, peekFirst, peekLast, pollFirst, pollLast, pop, push, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrenceMethods inherited from class ForwardingQueue
element, offer, peek, poll, remove, standardOffer, standardPeek, standardPollMethods inherited from class ForwardingCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArrayMethods inherited from class ForwardingObject
toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface BlockingDeque
add, addFirst, addLast, contains, element, iterator, offer, offerFirst, offerLast, peek, poll, push, remove, remove, removeFirstOccurrence, removeLastOccurrence, sizeMethods inherited from interface Collection
clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
ForwardingBlockingDeque
protected ForwardingBlockingDeque()Constructor for use by subclasses.
-
-
Method Details
-
delegate
Description copied from class:ForwardingObjectReturns 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 asForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.- Specified by:
delegatein classForwardingDeque<E>
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacityin interfaceBlockingQueue<E>
-
putFirst
- Specified by:
putFirstin interfaceBlockingDeque<E>- Throws:
InterruptedException
-
putLast
- Specified by:
putLastin interfaceBlockingDeque<E>- Throws:
InterruptedException
-
offerFirst
- Specified by:
offerFirstin interfaceBlockingDeque<E>- Throws:
InterruptedException
-
offerLast
- Specified by:
offerLastin interfaceBlockingDeque<E>- Throws:
InterruptedException
-
takeFirst
- Specified by:
takeFirstin interfaceBlockingDeque<E>- Throws:
InterruptedException
-
takeLast
- Specified by:
takeLastin interfaceBlockingDeque<E>- Throws:
InterruptedException
-
pollFirst
- Specified by:
pollFirstin interfaceBlockingDeque<E>- Throws:
InterruptedException
-
pollLast
- Specified by:
pollLastin interfaceBlockingDeque<E>- Throws:
InterruptedException
-
put
- Specified by:
putin interfaceBlockingDeque<E>- Specified by:
putin interfaceBlockingQueue<E>- Throws:
InterruptedException
-
offer
- Specified by:
offerin interfaceBlockingDeque<E>- Specified by:
offerin interfaceBlockingQueue<E>- Throws:
InterruptedException
-
take
- Specified by:
takein interfaceBlockingDeque<E>- Specified by:
takein interfaceBlockingQueue<E>- Throws:
InterruptedException
-
poll
- Specified by:
pollin interfaceBlockingDeque<E>- Specified by:
pollin interfaceBlockingQueue<E>- Throws:
InterruptedException
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<E>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<E>
-