Class AbstractIteratorTester.MultiExceptionListIterator

java.lang.Object
com.google.common.collect.testing.AbstractIteratorTester.MultiExceptionListIterator
All Implemented Interfaces:
Iterator<E>, ListIterator<E>
Enclosing class:
AbstractIteratorTester<E,I extends Iterator<E>>

protected final class AbstractIteratorTester.MultiExceptionListIterator extends Object implements ListIterator<E>
Quasi-implementation of ListIterator that works from a list of elements and a set of features to support (from the enclosing AbstractIteratorTester instance). Instead of throwing exceptions like NoSuchElementException at the appropriate times, it throws AbstractIteratorTester.PermittedMetaException instances, which wrap a set of all exceptions that the iterator could throw during the invocation of that method. This is necessary because, e.g., a call to iterator().remove() of an unmodifiable list could throw either IllegalStateException or UnsupportedOperationException. Note that iterator implementations should always throw one of the exceptions in a PermittedExceptions instance, since PermittedExceptions is thrown only when a method call is invalid.

This class is accessible but not supported in GWT as it references AbstractIteratorTester.PermittedMetaException.

  • Field Details

    • nextElements

      final Stack<E> nextElements
      The elements to be returned by future calls to next(), with the first at the top of the stack.
    • previousElements

      final Stack<E> previousElements
      The elements to be returned by future calls to previous(), with the first at the top of the stack.
    • stackWithLastReturnedElementAtTop

      Stack<E> stackWithLastReturnedElementAtTop
      nextElements if next() was called more recently then previous, previousElements if the reverse is true, or -- overriding both of these -- null if remove() or add() has been called more recently than either. We use this to determine which stack to pop from on a call to remove() (or to pop from and push to on a call to set()).
  • Constructor Details

    • MultiExceptionListIterator

      MultiExceptionListIterator(List<E> expectedElements)
  • Method Details