Package com.google.common.collect
Class ForwardingDeque<E extends @Nullable java.lang.Object>
- 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>
-
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Deque<E>
,java.util.Queue<E>
- Direct Known Subclasses:
ForwardingBlockingDeque
,ForwardingBlockingDeque
@GwtIncompatible public abstract class ForwardingDeque<E extends @Nullable java.lang.Object> extends ForwardingQueue<E> implements java.util.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, overridingForwardingCollection.add(E)
alone will not change the behavior ofForwardingQueue.offer(E)
which can lead to unexpected behavior. In this case, you should overrideoffer
as well.default
method warning: This class does not forward calls todefault
methods. Instead, it inherits their default implementations. When those implementations invoke methods, they invoke methods on theForwardingDeque
.- Since:
- 12.0
- Author:
- Kurt Alfred Kluever
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForwardingDeque()
Constructor for use by subclasses.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addFirst(E e)
void
addLast(E e)
protected abstract java.util.Deque<E>
delegate()
Returns the backing delegate instance that methods are forwarded to.java.util.Iterator<E>
descendingIterator()
E
getFirst()
E
getLast()
boolean
offerFirst(E e)
boolean
offerLast(E e)
@Nullable E
peekFirst()
@Nullable E
peekLast()
@Nullable E
pollFirst()
@Nullable E
pollLast()
E
pop()
void
push(E e)
E
removeFirst()
boolean
removeFirstOccurrence(@Nullable java.lang.Object o)
E
removeLast()
boolean
removeLastOccurrence(@Nullable java.lang.Object o)
-
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.Collection
clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Constructor Detail
-
ForwardingDeque
protected ForwardingDeque()
Constructor for use by subclasses.
-
-
Method Detail
-
delegate
protected abstract java.util.Deque<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 asForwardingSet.delegate()
. Concrete subclasses override this method to supply the instance being decorated.- Specified by:
delegate
in classForwardingQueue<E extends @Nullable java.lang.Object>
-
addFirst
public void addFirst(E e)
- Specified by:
addFirst
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
addLast
public void addLast(E e)
- Specified by:
addLast
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
descendingIterator
public java.util.Iterator<E> descendingIterator()
- Specified by:
descendingIterator
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
getFirst
public E getFirst()
- Specified by:
getFirst
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
getLast
public E getLast()
- Specified by:
getLast
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
offerFirst
@CanIgnoreReturnValue public boolean offerFirst(E e)
- Specified by:
offerFirst
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
offerLast
@CanIgnoreReturnValue public boolean offerLast(E e)
- Specified by:
offerLast
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
peekFirst
public @Nullable E peekFirst()
- Specified by:
peekFirst
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
peekLast
public @Nullable E peekLast()
- Specified by:
peekLast
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
pollFirst
@CanIgnoreReturnValue public @Nullable E pollFirst()
- Specified by:
pollFirst
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
pollLast
@CanIgnoreReturnValue public @Nullable E pollLast()
- Specified by:
pollLast
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
pop
@CanIgnoreReturnValue public E pop()
- Specified by:
pop
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
push
public void push(E e)
- Specified by:
push
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
removeFirst
@CanIgnoreReturnValue public E removeFirst()
- Specified by:
removeFirst
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
removeLast
@CanIgnoreReturnValue public E removeLast()
- Specified by:
removeLast
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
removeFirstOccurrence
@CanIgnoreReturnValue public boolean removeFirstOccurrence(@Nullable java.lang.Object o)
- Specified by:
removeFirstOccurrence
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
removeLastOccurrence
@CanIgnoreReturnValue public boolean removeLastOccurrence(@Nullable java.lang.Object o)
- Specified by:
removeLastOccurrence
in interfacejava.util.Deque<E extends @Nullable java.lang.Object>
-
-