com.tinkerpop.blueprints.util.WrappingCloseableIterable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blueprints-core Show documentation
Show all versions of blueprints-core Show documentation
Core interfaces and utilities for Blueprints
The newest version!
package com.tinkerpop.blueprints.util;
import com.tinkerpop.blueprints.CloseableIterable;
import java.util.Iterator;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class WrappingCloseableIterable implements CloseableIterable {
private final Iterable iterable;
public WrappingCloseableIterable(final Iterable iterable) {
this.iterable = iterable;
}
public Iterator iterator() {
return new Iterator() {
private final Iterator itty = iterable.iterator();
public void remove() {
this.itty.remove();
}
public T next() {
return this.itty.next();
}
public boolean hasNext() {
return this.itty.hasNext();
}
};
}
public void close() {
if (this.iterable instanceof CloseableIterable) {
((CloseableIterable) this.iterable).close();
}
}
public String toString() {
return this.iterable.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy