com.jn.langx.util.collection.iter.WrappedIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of langx-java Show documentation
Show all versions of langx-java Show documentation
Java lang extensions for java6+, a supplement to , replacement of a Guava, commons-lang.
Core utilities, Collection utilities, IO utilities, Cache, Configuration library ...
package com.jn.langx.util.collection.iter;
import com.jn.langx.annotation.NonNull;
import com.jn.langx.util.Preconditions;
import java.util.Iterator;
public class WrappedIterator implements Iterator {
private Iterator delegate;
private boolean mutable;
public WrappedIterator(@NonNull Iterator delegate, boolean mutable) {
Preconditions.checkNotNull(delegate);
this.delegate = delegate;
this.mutable = mutable;
}
@Override
public boolean hasNext() {
return delegate.hasNext();
}
@Override
public E next() {
return delegate.next();
}
@Override
public void remove() {
if (!mutable) {
throw new UnsupportedOperationException("Unsupported remove() on an immutable iterator");
}
}
}