Revert "TINKERPOP-1589 Re-introduced CloseableIterator"

This reverts commit 25232ad5fe4b6036962c246b11b50191a4244981.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/30bad4bd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/30bad4bd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/30bad4bd

Branch: refs/heads/TINKERPOP-1599
Commit: 30bad4bd89c06ffa139958e022106dfaf58ab05e
Parents: 25232ad
Author: PaulJackson123 <[email protected]>
Authored: Fri Jan 27 18:40:23 2017 -0500
Committer: PaulJackson123 <[email protected]>
Committed: Fri Jan 27 18:40:23 2017 -0500

----------------------------------------------------------------------
 .../traversal/step/map/EdgeVertexStep.java      | 149 +++++++-------
 .../process/traversal/step/map/FlatMapStep.java |  25 ++-
 .../traversal/step/map/PropertiesStep.java      | 165 ++++++++-------
 .../process/traversal/step/map/VertexStep.java  | 205 +++++++++----------
 .../structure/util/CloseableIterator.java       | 109 +++++-----
 5 files changed, 320 insertions(+), 333 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/30bad4bd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/EdgeVertexStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/EdgeVertexStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/EdgeVertexStep.java
index 1851d97..df20587 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/EdgeVertexStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/EdgeVertexStep.java
@@ -1,77 +1,72 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class EdgeVertexStep extends FlatMapStep<Edge, Vertex> implements 
AutoCloseable {
-
-    private Direction direction;
-
-    public EdgeVertexStep(final Traversal.Admin traversal, final Direction 
direction) {
-        super(traversal);
-        this.direction = direction;
-    }
-
-    @Override
-    protected Iterator<Vertex> flatMap(final Traverser.Admin<Edge> traverser) {
-        return traverser.get().vertices(this.direction);
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, this.direction);
-    }
-
-    @Override
-    public int hashCode() {
-        return super.hashCode() ^ this.direction.hashCode();
-    }
-
-    public Direction getDirection() {
-        return this.direction;
-    }
-
-    public void reverseDirection() {
-        this.direction = this.direction.opposite();
-    }
-
-    @Override
-    public Set<TraverserRequirement> getRequirements() {
-        return Collections.singleton(TraverserRequirement.OBJECT);
-    }
-
-    @Override
-    public void close() {
-        closeIterator();
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class EdgeVertexStep extends FlatMapStep<Edge, Vertex> {
+
+    private Direction direction;
+
+    public EdgeVertexStep(final Traversal.Admin traversal, final Direction 
direction) {
+        super(traversal);
+        this.direction = direction;
+    }
+
+    @Override
+    protected Iterator<Vertex> flatMap(final Traverser.Admin<Edge> traverser) {
+        return traverser.get().vertices(this.direction);
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, this.direction);
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode() ^ this.direction.hashCode();
+    }
+
+    public Direction getDirection() {
+        return this.direction;
+    }
+
+    public void reverseDirection() {
+        this.direction = this.direction.opposite();
+    }
+
+    @Override
+    public Set<TraverserRequirement> getRequirements() {
+        return Collections.singleton(TraverserRequirement.OBJECT);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/30bad4bd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
index 42f6ecd..ce79bdf 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/FlatMapStep.java
@@ -21,7 +21,6 @@ package 
org.apache.tinkerpop.gremlin.process.traversal.step.map;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
-import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;
 import org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator;
 
 import java.util.Iterator;
@@ -29,10 +28,10 @@ import java.util.Iterator;
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public abstract class FlatMapStep<S, E> extends AbstractStep<S, E> {
+public abstract class FlatMapStep<S, E> extends AbstractStep<S, E> implements 
AutoCloseable {
 
     private Traverser.Admin<S> head = null;
-    protected Iterator<E> iterator = EmptyIterator.instance();
+    private Iterator<E> iterator = EmptyIterator.instance();
 
     public FlatMapStep(final Traversal.Admin traversal) {
         super(traversal);
@@ -57,10 +56,24 @@ public abstract class FlatMapStep<S, E> extends 
AbstractStep<S, E> {
     public void reset() {
         super.reset();
         closeIterator();
-        this.iterator = EmptyIterator.instance();
     }
 
-    protected void closeIterator() {
-        CloseableIterator.closeIterator(this.iterator);
+    @Override
+    public void close() {
+        closeIterator();
+    }
+
+    private void closeIterator() {
+        try {
+            if (this.iterator instanceof AutoCloseable) {
+                ((AutoCloseable) this.iterator).close();
+            }
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        finally {
+            this.iterator = EmptyIterator.instance();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/30bad4bd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PropertiesStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PropertiesStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PropertiesStep.java
index b418a7c..d91ec36 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PropertiesStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PropertiesStep.java
@@ -1,85 +1,80 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.PropertyType;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class PropertiesStep<E> extends FlatMapStep<Element, E> implements 
AutoCloseable {
-
-    protected final String[] propertyKeys;
-    protected final PropertyType returnType;
-
-    public PropertiesStep(final Traversal.Admin traversal, final PropertyType 
propertyType, final String... propertyKeys) {
-        super(traversal);
-        this.returnType = propertyType;
-        this.propertyKeys = propertyKeys;
-    }
-
-    @Override
-    protected Iterator<E> flatMap(final Traverser.Admin<Element> traverser) {
-        return this.returnType.equals(PropertyType.VALUE) ?
-                traverser.get().values(this.propertyKeys) :
-                (Iterator) traverser.get().properties(this.propertyKeys);
-    }
-
-    public PropertyType getReturnType() {
-        return this.returnType;
-    }
-
-    public String[] getPropertyKeys() {
-        return this.propertyKeys;
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, 
Arrays.asList(this.propertyKeys), this.returnType.name().toLowerCase());
-    }
-
-    @Override
-    public int hashCode() {
-        int result = super.hashCode() ^ this.returnType.hashCode();
-        for (final String propertyKey : this.propertyKeys) {
-            result ^= propertyKey.hashCode();
-        }
-        return result;
-    }
-
-    @Override
-    public Set<TraverserRequirement> getRequirements() {
-        return Collections.singleton(TraverserRequirement.OBJECT);
-    }
-
-    @Override
-    public void close() {
-        closeIterator();
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.PropertyType;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class PropertiesStep<E> extends FlatMapStep<Element, E> {
+
+    protected final String[] propertyKeys;
+    protected final PropertyType returnType;
+
+    public PropertiesStep(final Traversal.Admin traversal, final PropertyType 
propertyType, final String... propertyKeys) {
+        super(traversal);
+        this.returnType = propertyType;
+        this.propertyKeys = propertyKeys;
+    }
+
+    @Override
+    protected Iterator<E> flatMap(final Traverser.Admin<Element> traverser) {
+        return this.returnType.equals(PropertyType.VALUE) ?
+                traverser.get().values(this.propertyKeys) :
+                (Iterator) traverser.get().properties(this.propertyKeys);
+    }
+
+    public PropertyType getReturnType() {
+        return this.returnType;
+    }
+
+    public String[] getPropertyKeys() {
+        return this.propertyKeys;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, 
Arrays.asList(this.propertyKeys), this.returnType.name().toLowerCase());
+    }
+
+    @Override
+    public int hashCode() {
+        int result = super.hashCode() ^ this.returnType.hashCode();
+        for (final String propertyKey : this.propertyKeys) {
+            result ^= propertyKey.hashCode();
+        }
+        return result;
+    }
+
+    @Override
+    public Set<TraverserRequirement> getRequirements() {
+        return Collections.singleton(TraverserRequirement.OBJECT);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/30bad4bd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/VertexStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/VertexStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/VertexStep.java
index 882c519..9e24953 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/VertexStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/VertexStep.java
@@ -1,105 +1,100 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class VertexStep<E extends Element> extends FlatMapStep<Vertex, E> 
implements AutoCloseable {
-
-    private final String[] edgeLabels;
-    private Direction direction;
-    private final Class<E> returnClass;
-
-    public VertexStep(final Traversal.Admin traversal, final Class<E> 
returnClass, final Direction direction, final String... edgeLabels) {
-        super(traversal);
-        this.direction = direction;
-        this.edgeLabels = edgeLabels;
-        this.returnClass = returnClass;
-    }
-
-    @Override
-    protected Iterator<E> flatMap(final Traverser.Admin<Vertex> traverser) {
-        return Vertex.class.isAssignableFrom(this.returnClass) ?
-                (Iterator<E>) traverser.get().vertices(this.direction, 
this.edgeLabels) :
-                (Iterator<E>) traverser.get().edges(this.direction, 
this.edgeLabels);
-    }
-
-    public Direction getDirection() {
-        return this.direction;
-    }
-
-    public String[] getEdgeLabels() {
-        return this.edgeLabels;
-    }
-
-    public Class<E> getReturnClass() {
-        return this.returnClass;
-    }
-
-    public void reverseDirection() {
-        this.direction = this.direction.opposite();
-    }
-
-    public boolean returnsVertex() {
-        return this.returnClass.equals(Vertex.class);
-    }
-
-    public boolean returnsEdge() {
-        return this.returnClass.equals(Edge.class);
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, this.direction, 
Arrays.asList(this.edgeLabels), this.returnClass.getSimpleName().toLowerCase());
-    }
-
-    @Override
-    public int hashCode() {
-        int result = super.hashCode() ^ this.direction.hashCode() ^ 
this.returnClass.hashCode();
-        for (final String edgeLabel : this.edgeLabels) {
-            result ^= edgeLabel.hashCode();
-        }
-        return result;
-    }
-
-    @Override
-    public Set<TraverserRequirement> getRequirements() {
-        return Collections.singleton(TraverserRequirement.OBJECT);
-    }
-
-    @Override
-    public void close() {
-        closeIterator();
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class VertexStep<E extends Element> extends FlatMapStep<Vertex, E> {
+
+    private final String[] edgeLabels;
+    private Direction direction;
+    private final Class<E> returnClass;
+
+    public VertexStep(final Traversal.Admin traversal, final Class<E> 
returnClass, final Direction direction, final String... edgeLabels) {
+        super(traversal);
+        this.direction = direction;
+        this.edgeLabels = edgeLabels;
+        this.returnClass = returnClass;
+    }
+
+    @Override
+    protected Iterator<E> flatMap(final Traverser.Admin<Vertex> traverser) {
+        return Vertex.class.isAssignableFrom(this.returnClass) ?
+                (Iterator<E>) traverser.get().vertices(this.direction, 
this.edgeLabels) :
+                (Iterator<E>) traverser.get().edges(this.direction, 
this.edgeLabels);
+    }
+
+    public Direction getDirection() {
+        return this.direction;
+    }
+
+    public String[] getEdgeLabels() {
+        return this.edgeLabels;
+    }
+
+    public Class<E> getReturnClass() {
+        return this.returnClass;
+    }
+
+    public void reverseDirection() {
+        this.direction = this.direction.opposite();
+    }
+
+    public boolean returnsVertex() {
+        return this.returnClass.equals(Vertex.class);
+    }
+
+    public boolean returnsEdge() {
+        return this.returnClass.equals(Edge.class);
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, this.direction, 
Arrays.asList(this.edgeLabels), this.returnClass.getSimpleName().toLowerCase());
+    }
+
+    @Override
+    public int hashCode() {
+        int result = super.hashCode() ^ this.direction.hashCode() ^ 
this.returnClass.hashCode();
+        for (final String edgeLabel : this.edgeLabels) {
+            result ^= edgeLabel.hashCode();
+        }
+        return result;
+    }
+
+    @Override
+    public Set<TraverserRequirement> getRequirements() {
+        return Collections.singleton(TraverserRequirement.OBJECT);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/30bad4bd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/CloseableIterator.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/CloseableIterator.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/CloseableIterator.java
index 6999a12..5f334a5 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/CloseableIterator.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/CloseableIterator.java
@@ -1,60 +1,49 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util;
-
-import org.apache.tinkerpop.gremlin.structure.Graph;
-
-import java.io.Closeable;
-import java.util.Iterator;
-
-/**
- * An extension of {@code Iterator} that implements {@code Closeable} which 
allows a {@link Graph} implementation
- * that hold open resources to provide the user the option to release those 
resources.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public interface CloseableIterator<T> extends Iterator<T>, Closeable {
-
-    /**
-     * Wraps an existing {@code Iterator} in a {@code CloseableIterator}. If 
the {@code Iterator} is already of that
-     * type then it will simply be returned as-is.
-     */
-    public static <T> CloseableIterator<T> asCloseable(final Iterator<T> 
iterator) {
-        if (iterator instanceof CloseableIterator)
-            return (CloseableIterator<T>) iterator;
-
-        return new DefaultCloseableIterator<T>(iterator);
-    }
-
-    @Override
-    public default void close() {
-        // do nothing by default
-    }
-
-    public static <T> void closeIterator(Iterator<T> iterator) {
-        if (iterator instanceof AutoCloseable) {
-            try {
-                ((AutoCloseable) iterator).close();
-            }
-            catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.structure.util;
+
+import org.apache.tinkerpop.gremlin.structure.Graph;
+
+import java.io.Closeable;
+import java.util.Iterator;
+
+/**
+ * An extension of {@code Iterator} that implements {@code Closeable} which 
allows a {@link Graph} implementation
+ * that hold open resources to provide the user the option to release those 
resources.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface CloseableIterator<T> extends Iterator<T>, Closeable {
+
+    /**
+     * Wraps an existing {@code Iterator} in a {@code CloseableIterator}. If 
the {@code Iterator} is already of that
+     * type then it will simply be returned as-is.
+     */
+    public static <T> CloseableIterator<T> asCloseable(final Iterator<T> 
iterator) {
+        if (iterator instanceof CloseableIterator)
+            return (CloseableIterator<T>) iterator;
+
+        return new DefaultCloseableIterator<T>(iterator);
+    }
+
+    @Override
+    public default void close() {
+        // do nothing by default
+    }
+}

Reply via email to