public abstract class ForwardingDeque<E> extends ForwardingQueue<E> implements Deque<E>
A deque which forwards all its method calls to another deque. 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 ForwardingDeque
forward indiscriminately to the methods of the delegate. For example, overriding ForwardingCollection.add(E)
alone will not change the behavior of ForwardingQueue.offer(E)
which can lead to unexpected behavior. In this case, you should override offer
as well.
Modifier | Constructor and Description |
---|---|
protected |
ForwardingDeque()
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
void |
addFirst(E e) |
void |
addLast(E e) |
protected abstract Deque<E> |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
Iterator<E> |
descendingIterator() |
E |
getFirst() |
E |
getLast() |
boolean |
offerFirst(E e) |
boolean |
offerLast(E e) |
E |
peekFirst() |
E |
peekLast() |
E |
pollFirst() |
E |
pollLast() |
E |
pop() |
void |
push(E e) |
E |
removeFirst() |
boolean |
removeFirstOccurrence(Object o) |
E |
removeLast() |
boolean |
removeLastOccurrence(Object o) |
element, offer, peek, poll, remove, standardOffer, standardPeek, standardPoll
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray
toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, contains, element, iterator, offer, peek, poll, remove, remove, size
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
protected abstract Deque<E> delegate()
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.
delegate
in class ForwardingQueue<E>
public Iterator<E> descendingIterator()
descendingIterator
in interface Deque<E>
public boolean offerFirst(E e)
offerFirst
in interface Deque<E>
public E removeFirst()
removeFirst
in interface Deque<E>
public E removeLast()
removeLast
in interface Deque<E>
public boolean removeFirstOccurrence(Object o)
removeFirstOccurrence
in interface Deque<E>
public boolean removeLastOccurrence(Object o)
removeLastOccurrence
in interface Deque<E>