dev.marksman.collectionviews.ProtectedIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of collection-views Show documentation
Show all versions of collection-views Show documentation
Low overhead, protected views over Java collections
package dev.marksman.collectionviews;
import java.util.Iterator;
final class ProtectedIterator implements Iterator {
private final Iterator underlying;
private ProtectedIterator(Iterator underlying) {
this.underlying = underlying;
}
@Override
public boolean hasNext() {
return underlying.hasNext();
}
@Override
public A next() {
return underlying.next();
}
static ProtectedIterator protectedIterator(Iterator underlying) {
return new ProtectedIterator<>(underlying);
}
}