You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/02/12 14:01:30 UTC

[04/77] [partial] incubator-tinkerpop git commit: moved com/tinkerpop directories to org/apache/tinkerpop

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
new file mode 100644
index 0000000..ab4562b
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
@@ -0,0 +1,135 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.detached;
+
+import com.tinkerpop.gremlin.structure.Graph;
+import com.tinkerpop.gremlin.structure.Property;
+import com.tinkerpop.gremlin.structure.Vertex;
+import com.tinkerpop.gremlin.structure.VertexProperty;
+import com.tinkerpop.gremlin.structure.util.ElementHelper;
+import com.tinkerpop.gremlin.structure.util.StringFactory;
+import com.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class DetachedVertexProperty<V> extends DetachedElement<Property<V>> implements VertexProperty<V>, VertexProperty.Iterators {
+
+    protected V value;
+    protected transient DetachedVertex vertex;
+
+    private DetachedVertexProperty() {
+    }
+
+    protected DetachedVertexProperty(final VertexProperty<V> vertexProperty, final boolean withProperties) {
+        super(vertexProperty);
+        this.value = vertexProperty.value();
+        this.vertex = DetachedFactory.detach(vertexProperty.element(), false);
+
+        // only serialize properties if requested, the graph supports it and there are meta properties present.
+        // this prevents unnecessary object creation of a new HashMap which will just be empty.  it will use
+        // Collections.emptyMap() by default
+        if (withProperties && vertexProperty.graph().features().vertex().supportsMetaProperties()) {
+            final Iterator<Property<Object>> propertyIterator = vertexProperty.iterators().propertyIterator();
+            if (propertyIterator.hasNext()) {
+                this.properties = new HashMap<>();
+                propertyIterator.forEachRemaining(property -> this.properties.put(property.key(), Collections.singletonList(DetachedFactory.detach(property))));
+            }
+        }
+    }
+
+    public DetachedVertexProperty(final Object id, final String label, final V value,
+                                  final Map<String, Object> properties,
+                                  final Vertex vertex) {
+        super(id, label);
+        this.value = value;
+        this.vertex = DetachedFactory.detach(vertex, true);
+
+        if (!properties.isEmpty()) {
+            this.properties = new HashMap<>();
+            properties.entrySet().iterator().forEachRemaining(entry -> this.properties.put(entry.getKey(), Collections.singletonList(new DetachedProperty<>(entry.getKey(), entry.getValue(), this))));
+        }
+    }
+
+    @Override
+    public boolean isPresent() {
+        return true;
+    }
+
+    @Override
+    public String key() {
+        return this.label;
+    }
+
+    @Override
+    public V value() {
+        return this.value;
+    }
+
+    @Override
+    public Vertex element() {
+        return this.vertex;
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException("Detached properties are readonly: " + this.toString());
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.propertyString(this);
+    }
+
+    @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
+    @Override
+    public boolean equals(final Object object) {
+        return ElementHelper.areEqual(this, object);
+    }
+
+    @Override
+    public VertexProperty<V> attach(final Vertex hostVertex) {
+        final Iterator<VertexProperty<V>> vertexPropertyIterator = IteratorUtils.filter(hostVertex.iterators().propertyIterator(this.label), vp -> ElementHelper.areEqual(this, vp));
+        if (!vertexPropertyIterator.hasNext())
+            throw new IllegalStateException("The detached vertex property could not be be found at the provided vertex: " + this);
+        return vertexPropertyIterator.next();
+    }
+
+    @Override
+    public VertexProperty<V> attach(final Graph hostGraph) {
+        return this.attach(this.vertex.attach(hostGraph));
+    }
+
+
+    @Override
+    public VertexProperty.Iterators iterators() {
+        return this;
+    }
+
+    @Override
+    public <U> Iterator<Property<U>> propertyIterator(final String... propertyKeys) {
+        return (Iterator) super.propertyIterator(propertyKeys);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyGraph.java
new file mode 100644
index 0000000..cd7a2b5
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyGraph.java
@@ -0,0 +1,110 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.empty;
+
+import com.tinkerpop.gremlin.process.Traversal;
+import com.tinkerpop.gremlin.process.computer.GraphComputer;
+import com.tinkerpop.gremlin.process.graph.traversal.GraphTraversal;
+import com.tinkerpop.gremlin.process.graph.traversal.util.EmptyGraphTraversal;
+import com.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
+import com.tinkerpop.gremlin.structure.Edge;
+import com.tinkerpop.gremlin.structure.Graph;
+import com.tinkerpop.gremlin.structure.Transaction;
+import com.tinkerpop.gremlin.structure.Vertex;
+import org.apache.commons.configuration.Configuration;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class EmptyGraph implements Graph, Graph.Iterators {
+
+    private static final String MESSAGE = "The graph is immutable and empty";
+    private static final EmptyGraph INSTANCE = new EmptyGraph();
+
+    private EmptyGraph() {
+
+    }
+
+    public static Graph instance() {
+        return INSTANCE;
+    }
+
+    @Override
+    public GraphTraversal<Vertex, Vertex> V(final Object... vertexIds) {
+        return EmptyGraphTraversal.instance();
+    }
+
+    @Override
+    public GraphTraversal<Edge, Edge> E(final Object... edgeIds) {
+        return EmptyGraphTraversal.instance();
+    }
+
+    @Override
+    public <T extends Traversal<S, S>, S> T of(final Class<T> traversal) {
+        return (T) EmptyTraversal.instance();
+    }
+
+    @Override
+    public Vertex addVertex(Object... keyValues) {
+        throw new IllegalStateException(MESSAGE);
+    }
+
+    @Override
+    public GraphComputer compute(final Class... graphComputerClass) {
+        throw new IllegalStateException(MESSAGE);
+    }
+
+    @Override
+    public Transaction tx() {
+        throw new IllegalStateException(MESSAGE);
+    }
+
+    @Override
+    public Variables variables() {
+        throw new IllegalStateException(MESSAGE);
+    }
+
+    @Override
+    public Configuration configuration() {
+        throw new IllegalStateException(MESSAGE);
+    }
+
+    @Override
+    public void close() throws Exception {
+        throw new IllegalStateException(MESSAGE);
+    }
+
+    @Override
+    public Iterators iterators() {
+        return this;
+    }
+
+    @Override
+    public Iterator<Vertex> vertexIterator(final Object... vertexIds) {
+        return Collections.emptyIterator();
+    }
+
+    @Override
+    public Iterator<Edge> edgeIterator(final Object... edgeIds) {
+        return Collections.emptyIterator();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyProperty.java
new file mode 100644
index 0000000..5a62dc8
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyProperty.java
@@ -0,0 +1,81 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.empty;
+
+import com.tinkerpop.gremlin.structure.Element;
+import com.tinkerpop.gremlin.structure.Property;
+import com.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.NoSuchElementException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class EmptyProperty<V> implements Property<V> {
+
+    private static final EmptyProperty INSTANCE = new EmptyProperty();
+
+    private EmptyProperty() {
+
+    }
+
+    @Override
+    public String key() {
+        throw Exceptions.propertyDoesNotExist();
+    }
+
+    @Override
+    public V value() throws NoSuchElementException {
+        throw Exceptions.propertyDoesNotExist();
+    }
+
+    @Override
+    public boolean isPresent() {
+        return false;
+    }
+
+    @Override
+    public Element element() {
+        throw Exceptions.propertyDoesNotExist();
+    }
+
+    @Override
+    public void remove() {
+
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.propertyString(this);
+    }
+
+    @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
+    @Override
+    public boolean equals(final Object object) {
+        return object instanceof EmptyProperty;
+    }
+
+    public int hashCode() {
+        return 1281483122;
+    }
+
+    public static <V> Property<V> instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyVertexProperty.java
new file mode 100644
index 0000000..d8eb6fd
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/empty/EmptyVertexProperty.java
@@ -0,0 +1,101 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.empty;
+
+import com.tinkerpop.gremlin.structure.Graph;
+import com.tinkerpop.gremlin.structure.Property;
+import com.tinkerpop.gremlin.structure.Vertex;
+import com.tinkerpop.gremlin.structure.VertexProperty;
+import com.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class EmptyVertexProperty<V> implements VertexProperty<V> {
+
+    private static final EmptyVertexProperty INSTANCE = new EmptyVertexProperty();
+
+    public static <U> VertexProperty<U> instance() {
+        return INSTANCE;
+    }
+
+    @Override
+    public Vertex element() {
+        throw Property.Exceptions.propertyDoesNotExist();
+    }
+
+    @Override
+    public Object id() {
+        throw Property.Exceptions.propertyDoesNotExist();
+    }
+
+    @Override
+    public Graph graph() {
+        throw Property.Exceptions.propertyDoesNotExist();
+    }
+
+    @Override
+    public <U> Property<U> property(String key) {
+        return Property.<U>empty();
+    }
+
+    @Override
+    public <U> Property<U> property(String key, U value) {
+        return Property.<U>empty();
+    }
+
+    @Override
+    public String key() {
+        throw Property.Exceptions.propertyDoesNotExist();
+    }
+
+    @Override
+    public V value() throws NoSuchElementException {
+        throw Property.Exceptions.propertyDoesNotExist();
+    }
+
+    @Override
+    public boolean isPresent() {
+        return false;
+    }
+
+    @Override
+    public void remove() {
+
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.propertyString(this);
+    }
+
+    @Override
+    public VertexProperty.Iterators iterators() {
+        return new Iterators() {
+            @Override
+            public <U> Iterator<Property<U>> propertyIterator(String... propertyKeys) {
+                return Collections.emptyIterator();
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedEdge.java
new file mode 100644
index 0000000..10b5035
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedEdge.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.wrapped;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface WrappedEdge<E> {
+
+    public E getBaseEdge();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedElement.java
new file mode 100644
index 0000000..d8aba7e
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedElement.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.wrapped;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface WrappedElement<E> {
+
+    public E getBaseElement();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedGraph.java
new file mode 100644
index 0000000..dc5e6a4
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedGraph.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.wrapped;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface WrappedGraph<G> {
+
+    public G getBaseGraph();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedProperty.java
new file mode 100644
index 0000000..b56a825
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedProperty.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.wrapped;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface WrappedProperty<P> {
+
+    public P getBaseProperty();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVariables.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVariables.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVariables.java
new file mode 100644
index 0000000..3673f4e
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVariables.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.wrapped;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface WrappedVariables<V> {
+
+    public V getBaseVariables();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVertex.java
new file mode 100644
index 0000000..13e4293
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVertex.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.wrapped;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface WrappedVertex<V> {
+
+    public V getBaseVertex();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVertexProperty.java
new file mode 100644
index 0000000..068d861
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedVertexProperty.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.structure.util.wrapped;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface WrappedVertexProperty<P> {
+
+    public P getBaseVertexProperty();
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Gremlin.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Gremlin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Gremlin.java
new file mode 100644
index 0000000..fb4b55e
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Gremlin.java
@@ -0,0 +1,42 @@
+/*
+ * 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 com.tinkerpop.gremlin.util;
+
+import com.jcabi.manifests.Manifests;
+
+import java.io.IOException;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class Gremlin {
+    private static String version;
+
+    static {
+        version = Manifests.read("version");
+    }
+
+    public static String version() {
+        return version;
+    }
+
+    public static void main(final String[] arguments) throws IOException {
+        System.out.println("gremlin " + version());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Serializer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Serializer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Serializer.java
new file mode 100644
index 0000000..747b5e7
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Serializer.java
@@ -0,0 +1,47 @@
+/*
+ * 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 com.tinkerpop.gremlin.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class Serializer {
+
+    public static byte[] serializeObject(final Object object) throws IOException {
+        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        final ObjectOutputStream out = new ObjectOutputStream(outputStream);
+        out.writeObject(object);
+        out.close();
+        return outputStream.toByteArray();
+    }
+
+    public static Object deserializeObject(final byte[] objectBytes) throws IOException, ClassNotFoundException {
+        final ByteArrayInputStream inputStream = new ByteArrayInputStream(objectBytes);
+        final ObjectInputStream in = new ObjectInputStream(inputStream);
+        final Object object = in.readObject();
+        in.close();
+        return object;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/StreamFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/StreamFactory.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/StreamFactory.java
new file mode 100644
index 0000000..5c84ff9
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/StreamFactory.java
@@ -0,0 +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 com.tinkerpop.gremlin.util;
+
+import java.util.Iterator;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+/**
+ * Utility methods for constructing {@link java.util.stream.Stream} objects.
+ *
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class StreamFactory {
+
+    /**
+     * Construct a {@link java.util.stream.Stream} from an {@link Iterable}.
+     */
+    public static <T> Stream<T> stream(final Iterable<T> iterable) {
+        return StreamFactory.stream(iterable.iterator());
+    }
+
+    /**
+     * Construct a parallel {@link java.util.stream.Stream} from an {@link Iterable}.
+     */
+    public static <T> Stream<T> parallelStream(final Iterable<T> iterable) {
+        return StreamFactory.parallelStream(iterable.iterator());
+    }
+
+    /**
+     * Construct a {@link java.util.stream.Stream} from an {@link java.util.Iterator}.
+     */
+    public static <T> Stream<T> stream(final Iterator<T> iterator) {
+        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.IMMUTABLE | Spliterator.SIZED), false);
+    }
+
+    /**
+     * Construct a parallel {@link java.util.stream.Stream} from an {@link java.util.Iterator}.
+     */
+    public static <T> Stream<T> parallelStream(final Iterator<T> iterator) {
+        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.IMMUTABLE | Spliterator.SIZED), true);
+    }
+
+    /**
+     * Construct an {@link Iterable} from an {@link java.util.stream.Stream}.
+     */
+    public static <T> Iterable<T> iterable(final Stream<T> stream) {
+        return stream::iterator;
+    }
+
+    public static <T> Stream<T> stream(final T t) {
+        return Stream.of(t);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TimeUtil.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TimeUtil.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TimeUtil.java
new file mode 100644
index 0000000..f4c8744
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TimeUtil.java
@@ -0,0 +1,42 @@
+/*
+ * 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 com.tinkerpop.gremlin.util;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class TimeUtil {
+    public static long secondsSince(final long startNanos) {
+        return timeSince(startNanos, TimeUnit.SECONDS);
+    }
+
+    public static long millisSince(final long startNanos) {
+        return timeSince(startNanos, TimeUnit.MILLISECONDS);
+    }
+
+    public static long minutesSince(final long startNanos) {
+        return timeSince(startNanos, TimeUnit.MINUTES);
+    }
+
+    public static long timeSince(final long startNanos, final TimeUnit destUnit) {
+        return destUnit.convert(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/config/YamlConfiguration.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/config/YamlConfiguration.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/config/YamlConfiguration.java
new file mode 100644
index 0000000..77f80f2
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/config/YamlConfiguration.java
@@ -0,0 +1,150 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.config;
+
+import org.apache.commons.configuration.AbstractHierarchicalFileConfiguration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.tree.ConfigurationNode;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * Apache Commons Configuration object for YAML.  Adapted from code originally found here:
+ * https://github.com/PEXPlugins/SimpleConfigs
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class YamlConfiguration extends AbstractHierarchicalFileConfiguration {
+    public final static int DEFAULT_IDENT = 4;
+    private final DumperOptions yamlOptions = new DumperOptions();
+    private final Yaml yaml = new Yaml(yamlOptions);
+    private boolean xmlCompatibility = true;
+
+    public YamlConfiguration() {
+        super();
+        initialize();
+    }
+
+    public YamlConfiguration(final HierarchicalConfiguration c) {
+        super(c);
+        initialize();
+    }
+
+    public YamlConfiguration(final String fileName) throws ConfigurationException {
+        super(fileName);
+        initialize();
+    }
+
+    public YamlConfiguration(final File file) throws ConfigurationException {
+        super(file);
+        initialize();
+    }
+
+    public YamlConfiguration(final URL url) throws ConfigurationException {
+        super(url);
+        initialize();
+    }
+
+    private void initialize() {
+        yamlOptions.setIndent(DEFAULT_IDENT);
+        yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+    }
+
+    public void setXmlCompatibility(final boolean xmlCompatibility) {
+        this.xmlCompatibility = xmlCompatibility;
+    }
+
+    @Override
+    public void load(final Reader in) throws ConfigurationException {
+        try {
+            this.loadHierarchy(this.getRootNode(), yaml.load(in));
+        } catch (Throwable e) {
+            throw new ConfigurationException("Failed to load configuration: " + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void save(final Writer out) throws ConfigurationException {
+        try {
+            yaml.dump(this.saveHierarchy(this.getRootNode()), out);
+        } catch (Throwable e) {
+            throw new ConfigurationException("Failed to save configuration: " + e.getMessage(), e);
+        }
+    }
+
+    protected void loadHierarchy(final ConfigurationNode parentNode, final Object obj) {
+        final String parentName = parentNode.getName();
+        if (obj instanceof Map<?, ?>) {
+            for (Map.Entry<String, Object> entry : ((Map<String, Object>) obj).entrySet()) {
+                final Node childNode = new Node(entry.getKey());
+
+                // if parent node is look like "tableS", "userS" or "groupS"
+                if (this.xmlCompatibility && parentName != null && parentName.endsWith("s")) {
+                    //this is done to have "users.user[@name='smith'] instead of "users.smith"
+                    childNode.setName(parentName.substring(0, parentName.length() - 1));
+                    childNode.addAttribute(new Node("name", entry.getKey()));
+                }
+
+                childNode.setReference(entry);
+                loadHierarchy(childNode, entry.getValue());
+                parentNode.addChild(childNode);
+            }
+        } else if (obj instanceof Collection) {
+            for (Object child : (Collection) obj) {
+                final Node childNode = new Node("item");
+                childNode.setReference(child);
+                loadHierarchy(childNode, child);
+                parentNode.addChild(childNode);
+            }
+        }
+
+        parentNode.setValue(obj);
+    }
+
+    protected Object saveHierarchy(final ConfigurationNode parentNode) {
+        if (parentNode.getChildrenCount() == 0)
+            return parentNode.getValue();
+
+        if (parentNode.getChildrenCount("item") == parentNode.getChildrenCount()) {
+            return parentNode.getChildren().stream().map(this::saveHierarchy).collect(Collectors.toList());
+        } else {
+            final Map<String, Object> map = new LinkedHashMap<>();
+            for (ConfigurationNode childNode : parentNode.getChildren()) {
+                String nodeName = childNode.getName();
+                if (this.xmlCompatibility && childNode.getAttributes("name").size() > 0)
+                    nodeName = String.valueOf(childNode.getAttributes("name").get(0).getValue());
+
+
+                map.put(nodeName, saveHierarchy(childNode));
+            }
+
+            return map;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ArrayListSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ArrayListSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ArrayListSupplier.java
new file mode 100644
index 0000000..ac694a9
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ArrayListSupplier.java
@@ -0,0 +1,42 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class ArrayListSupplier<A> implements Supplier<ArrayList<A>>, Serializable {
+    private static final ArrayListSupplier INSTANCE = new ArrayListSupplier();
+
+    private ArrayListSupplier() {
+    }
+
+    @Override
+    public ArrayList<A> get() {
+        return new ArrayList<>();
+    }
+
+    public static <A> ArrayListSupplier<A> instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplier.java
new file mode 100644
index 0000000..0c5d25c
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplier.java
@@ -0,0 +1,43 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import com.tinkerpop.gremlin.process.util.BulkSet;
+
+import java.io.Serializable;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class BulkSetSupplier<A> implements Supplier<BulkSet<A>>, Serializable {
+    private static final BulkSetSupplier INSTANCE = new BulkSetSupplier();
+
+    private BulkSetSupplier() {
+    }
+
+    @Override
+    public BulkSet<A> get() {
+        return new BulkSet<>();
+    }
+
+    public static <A> BulkSetSupplier<A> instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/CloningUnaryOperator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
new file mode 100644
index 0000000..51f9bf2
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
@@ -0,0 +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 com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.function.UnaryOperator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class CloningUnaryOperator<A> implements UnaryOperator<A>, Serializable {
+
+    private static final CloningUnaryOperator INSTANCE = new CloningUnaryOperator();
+
+    private CloningUnaryOperator() {
+    }
+
+    @Override
+    public A apply(final A a) {
+        if (a instanceof HashMap)
+            return (A) ((HashMap) a).clone();
+        else if (a instanceof HashSet)
+            return (A) ((HashSet) a).clone();
+        else
+            throw new IllegalArgumentException("The provided class is not registered for cloning: " + a.getClass());
+    }
+
+    public static <A> CloningUnaryOperator<A> instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ConstantSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ConstantSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ConstantSupplier.java
new file mode 100644
index 0000000..5f2ee81
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ConstantSupplier.java
@@ -0,0 +1,38 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class ConstantSupplier<A> implements Supplier<A>, Serializable {
+
+    private final A a;
+
+    public ConstantSupplier(final A a) {
+        this.a = a;
+    }
+
+    public A get() {
+        return this.a;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtils.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtils.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtils.java
new file mode 100644
index 0000000..14e006e
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtils.java
@@ -0,0 +1,81 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class FunctionUtils {
+    private FunctionUtils() {
+    }
+
+    public static <T, U> Function<T, U> wrapFunction(final ThrowingFunction<T, U> functionThatThrows) {
+        return (a) -> {
+            try {
+                return functionThatThrows.apply(a);
+            } catch (RuntimeException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        };
+    }
+
+    public static <T> Consumer<T> wrapConsumer(final ThrowingConsumer<T> consumerThatThrows) {
+        return (a) -> {
+            try {
+                consumerThatThrows.accept(a);
+            } catch (RuntimeException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        };
+    }
+
+    public static <T,U> BiConsumer<T,U> wrapBiConsumer(final ThrowingBiConsumer<T,U> consumerThatThrows) {
+        return (a,b) -> {
+            try {
+                consumerThatThrows.accept(a,b);
+            } catch (RuntimeException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        };
+    }
+
+    public static <T> Supplier<T> wrapSupplier(final ThrowingSupplier<T> supplierThatThrows) {
+        return () -> {
+            try {
+                return supplierThatThrows.get();
+            } catch (RuntimeException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/HashMapSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/HashMapSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/HashMapSupplier.java
new file mode 100644
index 0000000..ca44bff
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/HashMapSupplier.java
@@ -0,0 +1,44 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HashMapSupplier<K, V> implements Supplier<Map<K, V>>, Serializable {
+
+    private static final HashMapSupplier INSTANCE = new HashMapSupplier();
+
+    private HashMapSupplier() {
+    }
+
+    @Override
+    public HashMap<K, V> get() {
+        return new HashMap<>();
+    }
+
+    public static <K, V> HashMapSupplier<K, V> instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/HashSetSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/HashSetSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/HashSetSupplier.java
new file mode 100644
index 0000000..7447bef
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/HashSetSupplier.java
@@ -0,0 +1,42 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HashSetSupplier<A> implements Supplier<HashSet<A>>, Serializable {
+    private static final HashSetSupplier INSTANCE = new HashSetSupplier();
+
+    private HashSetSupplier() {
+    }
+
+    @Override
+    public HashSet<A> get() {
+        return new HashSet<>();
+    }
+
+    public static <A> HashSetSupplier<A> instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
new file mode 100644
index 0000000..ec94d16
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
@@ -0,0 +1,47 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.MeanStep;
+
+import java.io.Serializable;
+import java.util.function.Supplier;
+
+public final class MeanNumberSupplier implements Supplier<MeanStep.MeanNumber>, Serializable {
+
+    private static final MeanNumberSupplier INSTANCE = new MeanNumberSupplier();
+
+    private MeanNumberSupplier() {
+
+    }
+
+    @Override
+    public MeanStep.MeanNumber get() {
+        return new MeanStep.MeanNumber();
+    }
+
+    public static MeanNumberSupplier instance() {
+        return INSTANCE;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingBiConsumer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingBiConsumer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingBiConsumer.java
new file mode 100644
index 0000000..ca4cf68
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingBiConsumer.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@FunctionalInterface
+public interface ThrowingBiConsumer<A, B> {
+    public void accept(final A a, final B b) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingConsumer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingConsumer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingConsumer.java
new file mode 100644
index 0000000..db0ab12
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingConsumer.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@FunctionalInterface
+public interface ThrowingConsumer<A> {
+    public void accept(final A a) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingFunction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingFunction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingFunction.java
new file mode 100644
index 0000000..86662a9
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingFunction.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@FunctionalInterface
+public interface ThrowingFunction<T, R> {
+    R apply(final T t) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingSupplier.java
new file mode 100644
index 0000000..57e93fe
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/ThrowingSupplier.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@FunctionalInterface
+public interface ThrowingSupplier<T> {
+    public T get() throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TraversableLambda.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TraversableLambda.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TraversableLambda.java
new file mode 100644
index 0000000..736866d
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TraversableLambda.java
@@ -0,0 +1,37 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import com.tinkerpop.gremlin.process.Traversal;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface TraversableLambda<S,E> extends Cloneable {
+
+    public Traversal<S, E> getTraversal();
+
+    public TraversableLambda clone() throws CloneNotSupportedException;
+
+    public static <T> T tryAndClone(final Object object) throws CloneNotSupportedException {
+        return (object instanceof TraversableLambda) ? (T) ((TraversableLambda) object).clone() : (T) object;
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TreeSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TreeSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TreeSupplier.java
new file mode 100644
index 0000000..4a599c1
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TreeSupplier.java
@@ -0,0 +1,43 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import com.tinkerpop.gremlin.process.graph.util.Tree;
+
+import java.io.Serializable;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class TreeSupplier<A> implements Supplier<Tree<A>>, Serializable {
+    private static final TreeSupplier INSTANCE = new TreeSupplier();
+
+    private TreeSupplier() {
+    }
+
+    @Override
+    public Tree<A> get() {
+        return new Tree<>();
+    }
+
+    public static <A> TreeSupplier<A> instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TriConsumer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TriConsumer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TriConsumer.java
new file mode 100644
index 0000000..1f59d96
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TriConsumer.java
@@ -0,0 +1,63 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import java.util.Objects;
+
+/**
+ * Represents an operation that accepts two input arguments and returns no result. This is the tri-arity
+ * specialization of {@link java.util.function.Consumer}. Unlike most other functional interfaces, {@link TriConsumer}
+ * is expected to operate via side-effects.
+ * <p/>
+ * This is a functional interface whose functional method is {@link #accept(Object, Object, Object)}.
+ *
+ * @param <A> the type of the first argument to the operation
+ * @param <B> the type of the second argument to the operation
+ * @param <C> the type of the third argument to the operation
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface TriConsumer<A, B, C> {
+
+    /**
+     * Performs this operation on the given arguments.
+     *
+     * @param a the first argument to the operation
+     * @param b the second argument to the operation
+     * @param c the third argument to the operation
+     */
+    public void accept(final A a, final B b, final C c);
+
+    /**
+     * Returns a composed @{link TriConsumer} that performs, in sequence, this operation followed by the {@code after}
+     * operation. If performing either operation throws an exception, it is relayed to the caller of the composed
+     * operation. If performing this operation throws an exception, the after operation will not be performed.
+     *
+     * @param after the operation to perform after this operation
+     * @return a composed {@link TriConsumer} that performs in sequence this operation followed by the {@code after}
+     * operation
+     * @throws NullPointerException if {@code after} is null
+     */
+    public default TriConsumer<A, B, C> andThen(final TriConsumer<? super A, ? super B, ? super C> after) {
+        Objects.requireNonNull(after);
+        return (A a, B b, C c) -> {
+            accept(a, b, c);
+            after.accept(a, b, c);
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TriFunction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TriFunction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TriFunction.java
new file mode 100644
index 0000000..55ffe1e
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/TriFunction.java
@@ -0,0 +1,53 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.function;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface TriFunction<A, B, C, R> {
+
+    /**
+     * Applies this function to the given arguments.
+     *
+     * @param a the first argument to the function
+     * @param b the second argument to the function
+     * @param c the third argument to the function
+     * @return the function result
+     */
+    public R apply(final A a, final B b, final C c);
+
+    /**
+     * Returns a composed function that first applies this function to its input, and then applies the after function
+     * to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed
+     * function.
+     *
+     * @param after the function to apply after this function is applied
+     * @param <V>   the type of the output of the {@code after} function, and of the composed function
+     * @return a composed function that first applies this function and then applies the {@code after} function.
+     * @throws NullPointerException if {@code after} is null
+     */
+    public default <V> TriFunction<A, B, C, V> andThen(final Function<? super R, ? extends V> after) {
+        Objects.requireNonNull(after);
+        return (A a, B b, C c) -> after.apply(apply(a, b, c));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/ArrayIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/ArrayIterator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/ArrayIterator.java
new file mode 100644
index 0000000..42a73c0
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/ArrayIterator.java
@@ -0,0 +1,58 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.iterator;
+
+import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Iterator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class ArrayIterator<T> implements Iterator<T>, Serializable {
+
+    private final T[] array;
+    private int current = 0;
+
+    public ArrayIterator(final T[] array) {
+        this.array = array;
+    }
+
+    @Override
+    public boolean hasNext() {
+        return this.current < this.array.length;
+    }
+
+    @Override
+    public T next() {
+        if (this.hasNext()) {
+            this.current++;
+            return this.array[this.current - 1];
+        } else {
+            throw FastNoSuchElementException.instance();
+        }
+    }
+
+    @Override
+    public String toString() {
+        return Arrays.asList(array).toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/DoubleIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/DoubleIterator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/DoubleIterator.java
new file mode 100644
index 0000000..840ccdf
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/DoubleIterator.java
@@ -0,0 +1,59 @@
+/*
+ * 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 com.tinkerpop.gremlin.util.iterator;
+
+import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+final class DoubleIterator<T> implements Iterator<T>, Serializable {
+
+    private final T a;
+    private final T b;
+    private char current = 'a';
+
+    protected DoubleIterator(final T a, final T b) {
+        this.a = a;
+        this.b = b;
+    }
+
+    @Override
+    public boolean hasNext() {
+        return this.current != 'x';
+    }
+
+    @Override
+    public T next() {
+        if (this.current == 'x')
+            throw FastNoSuchElementException.instance();
+        else {
+            if (this.current == 'a') {
+                this.current = 'b';
+                return this.a;
+            } else {
+                this.current = 'x';
+                return this.b;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/EmptyIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/EmptyIterator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/EmptyIterator.java
new file mode 100644
index 0000000..af7f312
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/EmptyIterator.java
@@ -0,0 +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 com.tinkerpop.gremlin.util.iterator;
+
+import com.tinkerpop.gremlin.process.FastNoSuchElementException;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class EmptyIterator<S> implements Iterator<S>, Serializable {
+
+    private static final EmptyIterator INSTANCE = new EmptyIterator<>();
+
+    private EmptyIterator() {
+    }
+
+    @Override
+    public boolean hasNext() {
+        return false;
+    }
+
+    @Override
+    public S next() {
+        throw FastNoSuchElementException.instance();
+    }
+
+    public static <S> Iterator<S> instance() {
+        return INSTANCE;
+    }
+}
\ No newline at end of file