/** * Return true if any Iterator in the IteratorChain has a remaining element. * * @return true if elements remain */ @Override public boolean hasNext() { lockChain(); updateCurrentIterator(); lastUsedIterator = currentIterator; return currentIterator.hasNext(); }
/** * Returns the next Object of the current Iterator * * @return Object from the current Iterator * @throws java.util.NoSuchElementException if all the Iterators are * exhausted */ @Override public E next() { lockChain(); updateCurrentIterator(); lastUsedIterator = currentIterator; return currentIterator.next(); }
/** * Removes from the underlying collection the last element returned by the * Iterator. As with next() and hasNext(), this method calls remove() on the * underlying Iterator. Therefore, this method may throw an * UnsupportedOperationException if the underlying Iterator does not support * this method. * * @throws UnsupportedOperationException if the remove operator is not * supported by the underlying Iterator * @throws IllegalStateException if the next method has not yet been called, * or the remove method has already been called after the last call to the * next method. */ @Override public void remove() { lockChain(); if (currentIterator == null) { updateCurrentIterator(); } lastUsedIterator.remove(); }