package com.tinkerpop.blueprints.util.wrappers.readonly; import com.tinkerpop.blueprints.Element; import com.tinkerpop.blueprints.Index; import java.util.Iterator; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ class ReadOnlyIndexIterable<T extends Element> implements Iterable<Index<T>> { private final Iterable<Index<T>> iterable; protected ReadOnlyIndexIterable(final Iterable<Index<T>> iterable) { this.iterable = iterable; } public Iterator<Index<T>> iterator() { return new Iterator<Index<T>>() { private final Iterator<Index<T>> itty = iterable.iterator(); public void remove() { throw new UnsupportedOperationException(ReadOnlyTokens.MUTATE_ERROR_MESSAGE); } public Index<T> next() { return new ReadOnlyIndex<T>(this.itty.next()); } public boolean hasNext() { return this.itty.hasNext(); } }; } }