Package com.google.common.collect
Class ForwardingListIterator<E extends @Nullable Object>
- java.lang.Object
- 
- com.google.common.collect.ForwardingObject
- 
- com.google.common.collect.ForwardingIterator<E>
- 
- com.google.common.collect.ForwardingListIterator<E>
 
 
 
- 
- All Implemented Interfaces:
- Iterator<E>,- ListIterator<E>
 
 @GwtCompatible public abstract class ForwardingListIterator<E extends @Nullable Object> extends ForwardingIterator<E> implements ListIterator<E> A list iterator which forwards all its method calls to another list iterator. Subclasses should override one or more methods to modify the behavior of the backing iterator as desired per the decorator pattern.defaultmethod warning: This class forwards calls to only somedefaultmethods. Specifically, it forwards calls only for methods that existed beforedefaultmethods were introduced. For newer methods, likeforEachRemaining, it inherits their default implementations. When those implementations invoke methods, they invoke methods on theForwardingListIterator.- Since:
- 2.0
- Author:
- Mike Bostock
 
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedForwardingListIterator()Constructor for use by subclasses.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(E element)Inserts the specified element into the list (optional operation).protected abstract ListIterator<E>delegate()Returns the backing delegate instance that methods are forwarded to.booleanhasPrevious()Returnstrueif this list iterator has more elements when traversing the list in the reverse direction.intnextIndex()Returns the index of the element that would be returned by a subsequent call toListIterator.next().Eprevious()Returns the previous element in the list and moves the cursor position backwards.intpreviousIndex()Returns the index of the element that would be returned by a subsequent call toListIterator.previous().voidset(E element)Replaces the last element returned byListIterator.next()orListIterator.previous()with the specified element (optional operation).- 
Methods inherited from class com.google.common.collect.ForwardingIteratorhasNext, next, remove
 - 
Methods inherited from class com.google.common.collect.ForwardingObjecttoString
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.util.IteratorforEachRemaining
 - 
Methods inherited from interface java.util.ListIteratorhasNext, next, remove
 
- 
 
- 
- 
- 
Constructor Detail- 
ForwardingListIteratorprotected ForwardingListIterator() Constructor for use by subclasses.
 
- 
 - 
Method Detail- 
delegateprotected abstract ListIterator<E> 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 class- ForwardingIterator<E extends @Nullable Object>
 
 - 
addpublic void add(E element) Description copied from interface:java.util.ListIteratorInserts the specified element into the list (optional operation). The element is inserted immediately before the element that would be returned byListIterator.next(), if any, and after the element that would be returned byListIterator.previous(), if any. (If the list contains no elements, the new element becomes the sole element on the list.) The new element is inserted before the implicit cursor: a subsequent call tonextwould be unaffected, and a subsequent call topreviouswould return the new element. (This call increases by one the value that would be returned by a call tonextIndexorpreviousIndex.)- Specified by:
- addin interface- ListIterator<E extends @Nullable Object>
- Parameters:
- element- the element to insert
 
 - 
hasPreviouspublic boolean hasPrevious() Description copied from interface:java.util.ListIteratorReturnstrueif this list iterator has more elements when traversing the list in the reverse direction. (In other words, returnstrueifListIterator.previous()would return an element rather than throwing an exception.)- Specified by:
- hasPreviousin interface- ListIterator<E extends @Nullable Object>
- Returns:
- trueif the list iterator has more elements when traversing the list in the reverse direction
 
 - 
nextIndexpublic int nextIndex() Description copied from interface:java.util.ListIteratorReturns the index of the element that would be returned by a subsequent call toListIterator.next(). (Returns list size if the list iterator is at the end of the list.)- Specified by:
- nextIndexin interface- ListIterator<E extends @Nullable Object>
- Returns:
- the index of the element that would be returned by a
         subsequent call to next, or list size if the list iterator is at the end of the list
 
 - 
previous@CanIgnoreReturnValue public E previous() Description copied from interface:java.util.ListIteratorReturns the previous element in the list and moves the cursor position backwards. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls toListIterator.next()to go back and forth. (Note that alternating calls tonextandpreviouswill return the same element repeatedly.)- Specified by:
- previousin interface- ListIterator<E extends @Nullable Object>
- Returns:
- the previous element in the list
 
 - 
previousIndexpublic int previousIndex() Description copied from interface:java.util.ListIteratorReturns the index of the element that would be returned by a subsequent call toListIterator.previous(). (Returns -1 if the list iterator is at the beginning of the list.)- Specified by:
- previousIndexin interface- ListIterator<E extends @Nullable Object>
- Returns:
- the index of the element that would be returned by a
         subsequent call to previous, or -1 if the list iterator is at the beginning of the list
 
 - 
setpublic void set(E element) Description copied from interface:java.util.ListIteratorReplaces the last element returned byListIterator.next()orListIterator.previous()with the specified element (optional operation). This call can be made only if neitherListIterator.remove()norListIterator.add(E)have been called after the last call tonextorprevious.- Specified by:
- setin interface- ListIterator<E extends @Nullable Object>
- Parameters:
- element- the element with which to replace the last element returned by- nextor- previous
 
 
- 
 
-