Top Description Constructors Methods
com.google.common.collect

public abstract Class ForwardingListIterator<E extends @Nullable Object>

extends ForwardingIterator<E extends @Nullable Object>
implements ListIterator<E extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
java.util.ListIterator, java.util.Iterator
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtCompatible, com.google.errorprone.annotations.CanIgnoreReturnValue, java.util.ListIterator, org.checkerframework.checker.nullness.qual.Nullable

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.

default method warning: This class forwards calls to only some default methods. Specifically, it forwards calls only for methods that existed before default methods were introduced. For newer methods, like forEachRemaining, it inherits their default implementations. When those implementations invoke methods, they invoke methods on the ForwardingListIterator.

Author
Mike Bostock
Since
2.0

Constructor Summary

AccessConstructor and Description
protected
ForwardingListIterator()

Constructor for use by subclasses.

Method Summary

Modifier and TypeMethod and Description
public void
add(E
the element to insert
element
)

Implements java.util.ListIterator.add.

Inserts the specified element into the list (optional operation).
protected abstract ListIterator<E>
delegate()

Implements abstract com.google.common.collect.ForwardingIterator.delegate.

Returns the backing delegate instance that methods are forwarded to.
public boolean
hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.
public int
nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.
public E
previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards.
public int
previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.
public void
set(E
the element with which to replace the last element returned by next or previous
element
)

Implements java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation).
Inherited from com.google.common.collect.ForwardingIterator:
hasNextnextremove

Constructor Detail

ForwardingListIteratorback to summary
protected ForwardingListIterator()

Constructor for use by subclasses.

Method Detail

addback to summary
public void add(E element)

Implements java.util.ListIterator.add.

Doc from java.util.ListIterator.add.

Inserts the specified element into the list (optional operation). The element is inserted immediately before the element that would be returned by next, if any, and after the element that would be returned by 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 to next would be unaffected, and a subsequent call to previous would return the new element. (This call increases by one the value that would be returned by a call to nextIndex or previousIndex.)

Parameters
element:E

the element to insert

Annotations
@Override
delegateback to summary
protected abstract ListIterator<E> delegate()

Implements abstract com.google.common.collect.ForwardingIterator.delegate.

Doc from com.google.common.collect.ForwardingObject.delegate.

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.

Annotations
@Override
hasPreviousback to summary
public boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Doc from java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if previous would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the reverse direction

Annotations
@Override
nextIndexback to summary
public int nextIndex()

Implements java.util.ListIterator.nextIndex.

Doc from java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next. (Returns list size if the list iterator is at the end of the list.)

Returns:int

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

Annotations
@Override
previousback to summary
public E previous()

Implements java.util.ListIterator.previous.

Doc from java.util.ListIterator.previous.

Returns 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 to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:E

the previous element in the list

Annotations
@CanIgnoreReturnValue
@Override
@ParametricNullness
previousIndexback to summary
public int previousIndex()

Implements java.util.ListIterator.previousIndex.

Doc from java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

Returns:int

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

Annotations
@Override
setback to summary
public void set(E element)

Implements java.util.ListIterator.set.

Doc from java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation). This call can be made only if neither remove nor add have been called after the last call to next or previous.

Parameters
element:E

the element with which to replace the last element returned by next or previous

Annotations
@Override