Top Description Constructors Methods
com.google.common.collect

public abstract Class ForwardingIterator<T extends @Nullable Object>

extends ForwardingObject
implements Iterator<T extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Known Direct Subclasses
com.google.common.collect.ForwardingListIterator
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtCompatible, com.google.errorprone.annotations.CanIgnoreReturnValue, java.util.Iterator, org.checkerframework.checker.nullness.qual.Nullable

An iterator which forwards all its method calls to another 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 ForwardingIterator.

Author
Kevin Bourrillion
Since
2.0

Constructor Summary

AccessConstructor and Description
protected
ForwardingIterator()

Constructor for use by subclasses.

Method Summary

Modifier and TypeMethod and Description
protected abstract Iterator<T>
delegate()

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

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

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from com.google.common.collect.ForwardingObject:
toString

Constructor Detail

ForwardingIteratorback to summary
protected ForwardingIterator()

Constructor for use by subclasses.

Method Detail

delegateback to summary
protected abstract Iterator<T> delegate()

Implements abstract com.google.common.collect.ForwardingObject.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
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

Annotations
@CanIgnoreReturnValue
@Override
@ParametricNullness
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override