@Override public void close() { wrappedIterator.close(); } }
@Override public boolean hasNext() { return wrappedIterator.hasNext() && currentCount.get() < maxCount; }
@Override public void remove() { wrappedIterator.remove(); }
/** * Returns an unmodifiable list of all elements in the provided iterator. * The iterator is guaranteed to be closed after its execution. * * @param iterator the provided iterator. * @param <V> the type of elements in the iterator * @return a list of all elements returned by the iterator */ static <V> List<V> toList(ClosableIterator<V> iterator) { Preconditions.checkNotNull(iterator); List<V> values = new ArrayList<>(); try { while (iterator.hasNext()) { values.add(iterator.next()); } } finally { iterator.close(); } return Collections.unmodifiableList(values); }
@Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } currentCount.incrementAndGet(); return wrappedIterator.next(); }
/** * Returns an unmodifiable list of all elements in the provided iterator. * The iterator is guaranteed to be closed after its execution. * * @param iterator the provided iterator. * @param <V> the type of elements in the iterator * @return a list of all elements returned by the iterator */ static <V> List<V> toList(ClosableIterator<V> iterator) { Preconditions.checkNotNull(iterator); List<V> values = new ArrayList<>(); try { while (iterator.hasNext()) { values.add(iterator.next()); } } finally { iterator.close(); } return Collections.unmodifiableList(values); }
@Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } currentCount.incrementAndGet(); return wrappedIterator.next(); }
/** * Returns an unmodifiable list of all elements in the provided iterator. * The iterator is guaranteed to be closed after its execution. * * @param iterator the provided iterator. * @param <V> the type of elements in the iterator * @return a list of all elements returned by the iterator */ static <V> List<V> toList(ClosableIterator<V> iterator) { Preconditions.checkNotNull(iterator); List<V> values = new ArrayList<>(); try { while (iterator.hasNext()) { values.add(iterator.next()); } } finally { iterator.close(); } return Collections.unmodifiableList(values); }
@Override public void close() { wrappedIterator.close(); } }
@Override public boolean hasNext() { return wrappedIterator.hasNext() && currentCount.get() < maxCount; }
@Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } currentCount.incrementAndGet(); return wrappedIterator.next(); }
@Override public void remove() { wrappedIterator.remove(); }
/** * Returns an unmodifiable list of all elements in the provided iterator. * The iterator is guaranteed to be closed after its execution. * * @param iterator the provided iterator. * @param <V> the type of elements in the iterator * @return a list of all elements returned by the iterator */ static <V> List<V> toList(ClosableIterator<V> iterator) { Preconditions.checkNotNull(iterator); List<V> values = new ArrayList<>(); try { while (iterator.hasNext()) { values.add(iterator.next()); } } finally { iterator.close(); } return Collections.unmodifiableList(values); }
@Override public void close() { wrappedIterator.close(); } }
@Override public boolean hasNext() { return wrappedIterator.hasNext() && currentCount.get() < maxCount; }
@Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } currentCount.incrementAndGet(); return wrappedIterator.next(); }
@Override public void remove() { wrappedIterator.remove(); }
/** * Returns an unmodifiable list of all elements in the provided iterator. * The iterator is guaranteed to be closed after its execution. * * @param iterator the provided iterator. * @param <V> the type of elements in the iterator * @return a list of all elements returned by the iterator */ static <V> List<V> toList(ClosableIterator<V> iterator) { Preconditions.checkNotNull(iterator); List<V> values = new ArrayList<>(); try { while (iterator.hasNext()) { values.add(iterator.next()); } } finally { iterator.close(); } return Collections.unmodifiableList(values); }
@Override public void close() { wrappedIterator.close(); } }
@Override public boolean hasNext() { return wrappedIterator.hasNext() && currentCount.get() < maxCount; }