@Test(expected = NoSuchElementException.class) public void nextWhenThereIsNoNext_throwsException() { SqlPartIterator iterator = new SqlPartIterator(mock(SqlPart.class)); iterator.next(); iterator.next(); }
@Override public SqlPart next() { if (mLastReturned == null) { mLastReturned = mFirst; return mFirst; } SqlPart next = mLastReturned.previous(); if (next == null) { throw new NoSuchElementException("No previous SqlPart."); } mLastReturned = next; return mLastReturned; }
SqlPartIterator implements Iterator<SqlPart> { @Override public SqlPart next() { if (mLastReturned == null) { mLastReturned = mFirst; return mFirst; } SqlPart next = mLastReturned.previous(); if (next == null) { throw new NoSuchElementException("No previous SqlPart."); } mLastReturned = next; return mLastReturned; } }
SqlPartIterator implements Iterator<SqlPart> { @Override public SqlPart next() { if (mLastReturned == null) { mLastReturned = mFirst; return mFirst; } SqlPart next = mLastReturned.previous(); if (next == null) { throw new NoSuchElementException("No previous SqlPart."); } mLastReturned = next; return mLastReturned; } SqlPartIterator(@NotNull final SqlPart first); }
SqlPartIterator implements Iterator<SqlPart> { @Override public SqlPart next() { if (mLastReturned == null) { mLastReturned = mFirst; return mFirst; } SqlPart next = mLastReturned.previous(); if (next == null) { throw new NoSuchElementException("No previous SqlPart."); } mLastReturned = next; return mLastReturned; } SqlPartIterator(@NotNull final SqlPart first); @Override boolean hasNext(); @Override SqlPart next(); @Override void remove(); }
SqlPartIterator implements Iterator<SqlPart> { @Override public SqlPart next() { if (mLastReturned == null) { mLastReturned = mFirst; return mFirst; } SqlPart next = mLastReturned.previous(); if (next == null) { throw new NoSuchElementException("No previous SqlPart."); } mLastReturned = next; return mLastReturned; } SqlPartIterator(@NotNull final SqlPart first); @Override boolean hasNext(); @Override SqlPart next(); @Override void remove();  }