@Nonnull
    public Iterator<Long> iterator() {
        return new Iterator<Long>() {
            private long base2 = base;
            private int remaining = batchSize;

            @Override
            public boolean hasNext() {
                return remaining > 0;
            }

            @Override
            public Long next() {
                if (remaining == 0) {
                    throw new NoSuchElementException();
                }
                remaining--;
                try {
                    return base2;
                } finally {
                    base2 += increment;
                }
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
@ Nonnull public Iterator < Long > iterator ( ) { return new Iterator < Long > ( ) { private long base2 = base ; private int remaining = batchSize ; @ Override public boolean hasNext ( ) { return remaining > 0 ; } @ Override public Long next ( ) { if ( remaining == 0 ) { throw new NoSuchElementException ( ) ; } remaining -- ; try { return base2 ; } finally { base2 += increment ; } } @ Override public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; }
Returns iterator that will iterate contained IDs (boxing the as {@code Long}).
{@code remove()} is not supported.