@Override public boolean hasNext() { if ( sourceIterator == null ) { advanceIterator(); //if we are to skip the first element, we need to advance the iterator if ( skipFirst && sourceIterator.hasNext() ) { sourceIterator.next(); } return sourceIterator.hasNext(); } //if we've exhausted this iterator, try to advance to the next set if ( sourceIterator.hasNext() ) { return true; } //advance the iterator, to the next page, there could be more advanceIterator(); return sourceIterator.hasNext(); }