@Test public void immediateNext_returnsFirstItem() { SqlPart sqlPart = mock(SqlPart.class); SqlPartIterator iterator = new SqlPartIterator(sqlPart); SqlPart result = iterator.next(); assertThat(result, is(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 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();  }