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:47 UTC
[21/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/process/computer/util/ScriptEngineLambda.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/ScriptEngineLambda.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/ScriptEngineLambda.java
new file mode 100644
index 0000000..80abda1
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/ScriptEngineLambda.java
@@ -0,0 +1,111 @@
+/*
+ * 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.process.computer.util;
+
+import com.tinkerpop.gremlin.util.function.TriConsumer;
+
+import javax.script.Bindings;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.script.SimpleBindings;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class ScriptEngineLambda implements Function, Supplier, Consumer, Predicate, BiConsumer, TriConsumer {
+
+ private static final String A = "a";
+ private static final String B = "b";
+ private static final String C = "c";
+
+ protected final ScriptEngine engine;
+ protected final String script;
+
+ public ScriptEngineLambda(final String engineName, final String script) {
+ this.engine = ScriptEngineCache.get(engineName);
+ this.script = script;
+ }
+
+ public Object apply(final Object a) {
+ try {
+ final Bindings bindings = new SimpleBindings();
+ bindings.put(A, a);
+ return this.engine.eval(this.script, bindings);
+ } catch (final ScriptException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ public Object get() {
+ try {
+ return this.engine.eval(this.script);
+ } catch (final ScriptException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ public void accept(final Object a) {
+ try {
+ final Bindings bindings = new SimpleBindings();
+ bindings.put(A, a);
+ this.engine.eval(this.script, bindings);
+ } catch (final ScriptException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ public void accept(final Object a, final Object b) {
+ try {
+ final Bindings bindings = new SimpleBindings();
+ bindings.put(A, a);
+ bindings.put(B, b);
+ this.engine.eval(this.script, bindings);
+ } catch (final ScriptException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ public void accept(final Object a, final Object b, final Object c) {
+ try {
+ final Bindings bindings = new SimpleBindings();
+ bindings.put(A, a);
+ bindings.put(B, b);
+ bindings.put(C, c);
+ this.engine.eval(this.script, bindings);
+ } catch (final ScriptException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ public boolean test(final Object a) {
+ try {
+ final Bindings bindings = new SimpleBindings();
+ bindings.put(A, a);
+ return (boolean) this.engine.eval(this.script, bindings);
+ } catch (final ScriptException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/StaticMapReduce.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/StaticMapReduce.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/StaticMapReduce.java
new file mode 100644
index 0000000..7af51ec
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/StaticMapReduce.java
@@ -0,0 +1,54 @@
+/*
+ * 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.process.computer.util;
+
+import com.tinkerpop.gremlin.process.computer.MapReduce;
+import com.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.commons.configuration.Configuration;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public abstract class StaticMapReduce<MK, MV, RK, RV, R> implements MapReduce<MK, MV, RK, RV, R> {
+
+ @Override
+ public MapReduce<MK, MV, RK, RV, R> clone() throws CloneNotSupportedException {
+ return this;
+ }
+
+ @Override
+ public void storeState(final Configuration configuration) {
+ MapReduce.super.storeState(configuration);
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.mapReduceString(this, this.getMemoryKey());
+ }
+
+ @Override
+ public boolean equals(final Object object) {
+ return GraphComputerHelper.areEqual(this, object);
+ }
+
+ @Override
+ public int hashCode() {
+ return (this.getClass().getCanonicalName() + this.getMemoryKey()).hashCode();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/StaticVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/StaticVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/StaticVertexProgram.java
new file mode 100644
index 0000000..541e5e4
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/StaticVertexProgram.java
@@ -0,0 +1,40 @@
+/*
+ * 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.process.computer.util;
+
+import com.tinkerpop.gremlin.process.computer.VertexProgram;
+import org.apache.commons.configuration.Configuration;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public abstract class StaticVertexProgram<M> implements VertexProgram<M> {
+
+ @Override
+ public StaticVertexProgram<M> clone() throws CloneNotSupportedException {
+ return this;
+ }
+
+ @Override
+ public void storeState(final Configuration configuration) {
+ VertexProgram.super.storeState(configuration);
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java
new file mode 100644
index 0000000..048e533
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/VertexProgramHelper.java
@@ -0,0 +1,71 @@
+/*
+ * 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.process.computer.util;
+
+import com.tinkerpop.gremlin.process.Traversal;
+import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+import com.tinkerpop.gremlin.util.Serializer;
+import org.apache.commons.configuration.Configuration;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class VertexProgramHelper {
+
+ private VertexProgramHelper() {
+ }
+
+ public static void serialize(final Object object, final Configuration configuration, final String key) {
+ try {
+ configuration.setProperty(key, Serializer.serializeObject(object));
+ } catch (final IOException e) {
+ throw new IllegalArgumentException(e.getMessage(), e);
+ }
+ }
+
+ public static <T> T deserialize(final Configuration configuration, final String key) {
+ try {
+ final List byteList = configuration.getList(key);
+ byte[] bytes = new byte[byteList.size()];
+ for (int i = 0; i < byteList.size(); i++) {
+ bytes[i] = Byte.valueOf(byteList.get(i).toString().replace("[", "").replace("]", ""));
+ }
+ return (T) Serializer.deserializeObject(bytes);
+ } catch (final IOException | ClassNotFoundException e) {
+ throw new IllegalArgumentException(e.getMessage(), e);
+ }
+ }
+
+ public static void verifyReversibility(final Traversal.Admin<?, ?> traversal) {
+ if (!TraversalHelper.isReversible(traversal))
+ throw new IllegalArgumentException("The provided traversal is not reversible");
+ }
+
+ public static void legalConfigurationKeyValueArray(final Object... configurationKeyValues) throws IllegalArgumentException {
+ if (configurationKeyValues.length % 2 != 0)
+ throw new IllegalArgumentException("The provided arguments must have a size that is a factor of 2");
+ for (int i = 0; i < configurationKeyValues.length; i = i + 2) {
+ if (!(configurationKeyValues[i] instanceof String))
+ throw new IllegalArgumentException("The provided key/value array must have a String key on even array indices");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/DefaultGraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/DefaultGraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/DefaultGraphTraversal.java
new file mode 100644
index 0000000..ffd1e9e
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/DefaultGraphTraversal.java
@@ -0,0 +1,46 @@
+/*
+ * 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.process.graph.traversal;
+
+import com.tinkerpop.gremlin.process.traversal.DefaultTraversal;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class DefaultGraphTraversal<S, E> extends DefaultTraversal<S, E> implements GraphTraversal.Admin<S, E> {
+
+ public DefaultGraphTraversal(final Class emanatingClass) {
+ super(emanatingClass);
+ }
+
+ @Override
+ public GraphTraversal.Admin<S, E> asAdmin() {
+ return this;
+ }
+
+ @Override
+ public GraphTraversal<S, E> iterate() {
+ return GraphTraversal.Admin.super.iterate();
+ }
+
+ @Override
+ public DefaultGraphTraversal<S, E> clone() throws CloneNotSupportedException {
+ return (DefaultGraphTraversal<S, E>) super.clone();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/EdgeTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/EdgeTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/EdgeTraversal.java
new file mode 100644
index 0000000..00a5397
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/EdgeTraversal.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.process.graph.traversal;
+
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.StartStep;
+import com.tinkerpop.gremlin.structure.Edge;
+import com.tinkerpop.gremlin.structure.Property;
+
+import java.util.Map;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface EdgeTraversal extends ElementTraversal<Edge> {
+
+ @Override
+ default GraphTraversal<Edge, Edge> start() {
+ final GraphTraversal.Admin<Edge, Edge> traversal = new DefaultGraphTraversal<>(this.getClass());
+ return traversal.addStep(new StartStep<>(traversal, this));
+ }
+
+ @Override
+ public default <E2> GraphTraversal<Edge, Property<E2>> properties(final String... propertyKeys) {
+ return (GraphTraversal) this.start().properties(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<Edge, Map<String, Property<E2>>> propertyMap(final String... propertyKeys) {
+ return this.start().propertyMap(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<Edge, Map<String, E2>> valueMap(final String... propertyKeys) {
+ return this.start().valueMap(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<Edge, Map<String, E2>> valueMap(final boolean includeTokens, final String... propertyKeys) {
+ return this.start().valueMap(includeTokens, propertyKeys);
+ }
+
+ // necessary so VertexProperty.value() as a non-traversal method works
+ public default <E2> GraphTraversal<Edge, E2> value() {
+ return this.start().value();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/ElementTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/ElementTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/ElementTraversal.java
new file mode 100644
index 0000000..0484021
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/ElementTraversal.java
@@ -0,0 +1,538 @@
+/*
+ * 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.process.graph.traversal;
+
+import com.tinkerpop.gremlin.process.Path;
+import com.tinkerpop.gremlin.process.Scope;
+import com.tinkerpop.gremlin.process.T;
+import com.tinkerpop.gremlin.process.Traversal;
+import com.tinkerpop.gremlin.process.Traverser;
+import com.tinkerpop.gremlin.process.computer.GraphComputer;
+import com.tinkerpop.gremlin.structure.Direction;
+import com.tinkerpop.gremlin.structure.Edge;
+import com.tinkerpop.gremlin.structure.Element;
+import com.tinkerpop.gremlin.structure.Property;
+import com.tinkerpop.gremlin.structure.Vertex;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public abstract interface ElementTraversal<A extends Element> {
+
+ //////////////////////////////////////////////////////////////////////
+
+ default GraphTraversal<A, A> start() {
+ throw new UnsupportedOperationException("This method must be implemented by the element");
+ }
+
+ //////////////////////////////////////////////////////////////////////
+
+ public default GraphTraversal<A, A> submit(final GraphComputer graphComputer) {
+ return this.start().submit(graphComputer);
+ }
+
+ ///////////////////// MAP STEPS /////////////////////
+
+ public default <E2> GraphTraversal<A, E2> map(final Function<Traverser<A>, E2> function) {
+ return this.start().map(function);
+ }
+
+ public default <E2> GraphTraversal<A, E2> flatMap(final Function<Traverser<A>, Iterator<E2>> function) {
+ return this.start().flatMap(function);
+ }
+
+ public default GraphTraversal<A, A> identity() {
+ return this.start().identity();
+ }
+
+ public default GraphTraversal<A, Vertex> to(final Direction direction, final String... edgeLabels) {
+ return this.start().to(direction, edgeLabels);
+ }
+
+ public default GraphTraversal<A, Vertex> out(final String... edgeLabels) {
+ return this.start().out(edgeLabels);
+ }
+
+ public default GraphTraversal<A, Vertex> in(final String... edgeLabels) {
+ return this.start().in(edgeLabels);
+ }
+
+ public default GraphTraversal<A, Vertex> both(final String... edgeLabels) {
+ return this.start().both(edgeLabels);
+ }
+
+ public default GraphTraversal<A, Edge> toE(final Direction direction, final String... edgeLabels) {
+ return this.start().toE(direction, edgeLabels);
+ }
+
+ public default GraphTraversal<A, Edge> outE(final String... edgeLabels) {
+ return this.start().outE(edgeLabels);
+ }
+
+ public default GraphTraversal<A, Edge> inE(final String... edgeLabels) {
+ return this.start().inE(edgeLabels);
+ }
+
+ public default GraphTraversal<A, Edge> bothE(final String... edgeLabels) {
+ return this.start().bothE(edgeLabels);
+ }
+
+ public default GraphTraversal<A, Vertex> toV(final Direction direction) {
+ return this.start().toV(direction);
+ }
+
+ public default GraphTraversal<A, Vertex> inV() {
+ return this.start().inV();
+ }
+
+ public default GraphTraversal<A, Vertex> outV() {
+ return this.start().outV();
+ }
+
+ public default GraphTraversal<A, Vertex> bothV() {
+ return this.start().bothV();
+ }
+
+ public default GraphTraversal<A, Vertex> otherV() {
+ return this.start().otherV();
+ }
+
+ public default GraphTraversal<A, A> order() {
+ return this.start().order();
+ }
+
+ public default GraphTraversal<A, A> order(final Scope scope) {
+ return this.start().order(scope);
+ }
+
+ public default <E2> GraphTraversal<A, ? extends Property<E2>> properties(final String... propertyKeys) {
+ return this.start().properties(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<A, E2> values(final String... propertyKeys) {
+ return this.start().values(propertyKeys);
+ }
+
+ public default GraphTraversal<A, Path> path() {
+ return this.start().path();
+ }
+
+ public default <E2> GraphTraversal<A, E2> back(final String stepLabel) {
+ return this.start().back(stepLabel);
+ }
+
+ public default <E2> GraphTraversal<A, Map<String, E2>> match(final String startLabel, final Traversal... traversals) {
+ return this.start().match(startLabel, traversals);
+ }
+
+ public default <E2> GraphTraversal<A, E2> sack() {
+ return this.start().sack();
+ }
+
+ public default <E2> GraphTraversal<A, E2> select(final String stepLabel) {
+ return this.start().select(stepLabel);
+ }
+
+ public default <E2> GraphTraversal<A, Map<String, E2>> select(final String... stepLabels) {
+ return this.start().select(stepLabels);
+ }
+
+ public default GraphTraversal<A, A> unfold() {
+ return this.start().unfold();
+ }
+
+ public default GraphTraversal<A, List<A>> fold() {
+ return this.start().fold();
+ }
+
+ public default <E2> GraphTraversal<A, E2> fold(final E2 seed, final BiFunction<E2, A, E2> foldFunction) {
+ return this.start().fold(seed, foldFunction);
+ }
+
+ public default GraphTraversal<A, Long> count() {
+ return this.start().count();
+ }
+
+ public default GraphTraversal<A, Double> sum() {
+ return this.start().sum();
+ }
+
+ public default <E2 extends Number> GraphTraversal<A, E2> min() {
+ return this.start().min();
+ }
+
+ public default <E2 extends Number> GraphTraversal<A, E2> max() {
+ return this.start().max();
+ }
+
+ public default GraphTraversal<A, Double> mean() {
+ return this.start().mean();
+ }
+
+ ///////////////////// FILTER STEPS /////////////////////
+
+ public default GraphTraversal<A, A> filter(final Predicate<Traverser<A>> predicate) {
+ return this.start().filter(predicate);
+ }
+
+ public default GraphTraversal<A, A> and(final Traversal<?, ?>... andTraversals) {
+ return this.start().and(andTraversals);
+ }
+
+ public default GraphTraversal<A, A> or(final Traversal<?, ?>... orTraversals) {
+ return this.start().or(orTraversals);
+ }
+
+ public default GraphTraversal<A, A> inject(final Object... injections) {
+ return this.start().inject((A[]) injections);
+ }
+
+ public default GraphTraversal<A, A> dedup() {
+ return this.start().dedup();
+ }
+
+ public default GraphTraversal<A, A> except(final String sideEffectKeyOrPathLabel) {
+ return this.start().except(sideEffectKeyOrPathLabel);
+ }
+
+ public default GraphTraversal<A, A> except(final Object exceptObject) {
+ return this.start().except((A) exceptObject);
+ }
+
+ public default GraphTraversal<A, A> except(final Collection<A> exceptCollection) {
+ return this.start().except(exceptCollection);
+ }
+
+ public default GraphTraversal<A, A> has(final Traversal<?, ?> hasNextTraversal) {
+ return this.start().has(hasNextTraversal);
+ }
+
+ public default GraphTraversal<A, A> has(final String key) {
+ return this.start().has(key);
+ }
+
+ public default GraphTraversal<A, A> has(final String key, final Object value) {
+ return this.start().has(key, value);
+ }
+
+ public default GraphTraversal<A, A> has(final T accessor, final Object value) {
+ return this.start().has(accessor, value);
+ }
+
+ public default GraphTraversal<A, A> has(final String key, final BiPredicate predicate, final Object value) {
+ return this.start().has(key, predicate, value);
+ }
+
+ public default GraphTraversal<A, A> has(final T accessor, final BiPredicate predicate, final Object value) {
+ return this.start().has(accessor, predicate, value);
+ }
+
+ public default GraphTraversal<A, A> has(final String label, final String key, final Object value) {
+ return this.start().has(label, key, value);
+ }
+
+ public default GraphTraversal<A, A> has(final String label, final String key, final BiPredicate predicate, final Object value) {
+ return this.start().has(label, key, predicate, value);
+ }
+
+ public default GraphTraversal<A, A> hasNot(final String key) {
+ return this.start().hasNot(key);
+ }
+
+ public default GraphTraversal<A, A> hasLabel(final String... labels) {
+ return this.start().hasLabel(labels);
+ }
+
+ public default GraphTraversal<A, A> hasId(final Object... ids) {
+ return this.start().hasId(ids);
+ }
+
+ public default GraphTraversal<A, A> hasKey(final String... keys) {
+ return this.start().hasKey(keys);
+ }
+
+ public default GraphTraversal<A, A> hasValue(final Object... values) {
+ return this.start().hasValue(values);
+ }
+
+ public default <E2> GraphTraversal<A, Map<String, E2>> where(final String firstKey, final String secondKey, final BiPredicate predicate) {
+ return this.start().where(firstKey, secondKey, predicate);
+ }
+
+ public default <E2> GraphTraversal<A, Map<String, E2>> where(final String firstKey, final BiPredicate predicate, final String secondKey) {
+ return this.start().where(firstKey, predicate, secondKey);
+ }
+
+ public default <E2> GraphTraversal<A, Map<String, E2>> where(final Traversal constraint) {
+ return this.start().where(constraint);
+ }
+
+ public default GraphTraversal<A, A> is(final Object value) {
+ return this.start().is(value);
+ }
+
+ public default GraphTraversal<A, A> is(final BiPredicate predicate, final Object value) {
+ return this.start().is(predicate, value);
+ }
+
+ public default GraphTraversal<A, A> coin(final double probability) {
+ return this.start().coin(probability);
+ }
+
+ public default GraphTraversal<A, A> range(final long low, final long high) {
+ return this.start().range(low, high);
+ }
+
+ public default GraphTraversal<A, A> limit(final long limit) {
+ return this.start().limit(limit);
+ }
+
+ public default GraphTraversal<A, A> retain(final String sideEffectKeyOrPathLabel) {
+ return this.start().retain(sideEffectKeyOrPathLabel);
+ }
+
+ public default GraphTraversal<A, A> retain(final Object retainObject) {
+ return this.start().retain((A) retainObject);
+ }
+
+ public default GraphTraversal<A, A> retain(final Collection<A> retainCollection) {
+ return this.start().retain(retainCollection);
+ }
+
+ public default GraphTraversal<A, A> simplePath() {
+ return this.start().simplePath();
+ }
+
+ public default GraphTraversal<A, A> cyclicPath() {
+ return this.start().cyclicPath();
+ }
+
+ public default GraphTraversal<A, A> sample(final int amountToSample) {
+ return this.start().sample(amountToSample);
+ }
+
+ ///////////////////// SIDE-EFFECT STEPS /////////////////////
+
+ public default GraphTraversal<A, A> sideEffect(final Consumer<Traverser<A>> consumer) {
+ return this.start().sideEffect(consumer);
+ }
+
+ public default <E2> GraphTraversal<A, E2> cap(final String... sideEffectKeys) {
+ return this.start().cap(sideEffectKeys);
+ }
+
+ public default GraphTraversal<A, Edge> subgraph(final String sideEffectKey) {
+ return this.start().subgraph(sideEffectKey);
+ }
+
+ public default GraphTraversal<A, Edge> subgraph() {
+ return this.start().subgraph();
+ }
+
+ public default GraphTraversal<A, A> aggregate(final String sideEffectKey) {
+ return this.start().aggregate(sideEffectKey);
+ }
+
+ public default GraphTraversal<A, A> aggregate() {
+ return this.start().aggregate();
+ }
+
+ public default GraphTraversal<A, A> group(final String sideEffectKey) {
+ return this.start().group(sideEffectKey);
+ }
+
+ public default GraphTraversal<A, A> group() {
+ return this.start().group();
+ }
+
+ public default GraphTraversal<A, A> groupCount(final String sideEffectKey) {
+ return this.start().groupCount(sideEffectKey);
+ }
+
+ public default GraphTraversal<A, A> groupCount() {
+ return this.start().groupCount();
+ }
+
+ public default GraphTraversal<A, Vertex> addE(final Direction direction, final String edgeLabel, final String stepLabel, final Object... propertyKeyValues) {
+ return this.start().addE(direction, edgeLabel, stepLabel, propertyKeyValues);
+ }
+
+ public default GraphTraversal<A, Vertex> addInE(final String edgeLabel, final String setLabel, final Object... propertyKeyValues) {
+ return this.start().addInE(edgeLabel, setLabel, propertyKeyValues);
+ }
+
+ public default GraphTraversal<A, Vertex> addOutE(final String edgeLabel, final String stepLabel, final Object... propertyKeyValues) {
+ return this.start().addOutE(edgeLabel, stepLabel, propertyKeyValues);
+ }
+
+ public default GraphTraversal<A, Vertex> addBothE(final String edgeLabel, final String stepLabel, final Object... propertyKeyValues) {
+ return this.start().addBothE(edgeLabel, stepLabel, propertyKeyValues);
+ }
+
+ public default GraphTraversal<A, A> timeLimit(final long timeLimit) {
+ return this.start().timeLimit(timeLimit);
+ }
+
+ public default GraphTraversal<A, A> tree(final String sideEffectKey) {
+ return this.start().tree(sideEffectKey);
+ }
+
+ public default GraphTraversal<A, A> tree() {
+ return this.start().tree();
+ }
+
+ public default <V> GraphTraversal<A, A> sack(final BiFunction<V, A, V> sackFunction) {
+ return this.start().sack(sackFunction);
+ }
+
+ public default <V> GraphTraversal<A, A> sack(final BinaryOperator<V> sackOperator, final String elementPropertyKey) {
+ return this.start().sack(sackOperator, elementPropertyKey);
+ }
+
+ public default GraphTraversal<A, A> store(final String sideEffectKey) {
+ return this.start().store(sideEffectKey);
+ }
+
+ public default GraphTraversal<A, A> store() {
+ return this.start().store();
+ }
+
+ ///////////////////// BRANCH STEPS /////////////////////
+
+ public default <M, E2> GraphTraversal<A, E2> branch(final Function<Traverser<A>, M> function) {
+ return this.start().branch(function);
+ }
+
+ public default <M, E2> GraphTraversal<A, E2> branch(final Traversal<?, M> traversalFunction) {
+ return this.start().branch(traversalFunction);
+ }
+
+ public default <E2> GraphTraversal<A, E2> choose(final Predicate<A> choosePredicate, final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
+ return this.start().choose(choosePredicate, trueChoice, falseChoice);
+ }
+
+ public default <M, E2> GraphTraversal<A, E2> choose(final Function<A, M> choiceFunction) {
+ return this.start().choose(choiceFunction);
+ }
+
+ public default <M, E2> GraphTraversal<A, E2> choose(final Traversal<?, M> traversalFunction) {
+ return this.start().choose(traversalFunction);
+ }
+
+ public default <M, E2> GraphTraversal<A, E2> choose(final Traversal<?, M> traversalPredicate, final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
+ return this.start().choose(traversalPredicate, trueChoice, falseChoice);
+ }
+
+ public default <E2> GraphTraversal<A, E2> union(final Traversal<?, E2>... traversals) {
+ return this.start().union(traversals);
+ }
+
+ public default <E2> GraphTraversal<A, E2> coalesce(final Traversal<?, E2>... traversals) {
+ return this.start().coalesce(traversals);
+ }
+
+ public default GraphTraversal<A, A> repeat(final Traversal<?, A> traversal) {
+ return this.start().repeat(traversal);
+ }
+
+ public default GraphTraversal<A, A> emit(final Predicate<Traverser<A>> emitPredicate) {
+ return this.start().emit(emitPredicate);
+ }
+
+ public default GraphTraversal<A, A> emit(final Traversal<?, ?> emitTraversal) {
+ return this.start().emit(emitTraversal);
+ }
+
+ public default GraphTraversal<A, A> emit() {
+ return this.start().emit();
+ }
+
+ public default GraphTraversal<A, A> until(final Predicate<Traverser<A>> untilPredicate) {
+ return this.start().until(untilPredicate);
+ }
+
+ public default GraphTraversal<A, A> until(final Traversal<?, ?> untilTraversal) {
+ return this.start().until(untilTraversal);
+ }
+
+ public default GraphTraversal<A, A> times(final int maxLoops) {
+ return this.start().times(maxLoops);
+ }
+
+ public default <E2> GraphTraversal<A, E2> local(final Traversal<?, E2> localTraversal) {
+ return this.start().local(localTraversal);
+ }
+
+ ///////////////////// UTILITY STEPS /////////////////////
+
+ public default GraphTraversal<A, A> as(final String label) {
+ return this.start().as(label);
+ }
+
+ public default GraphTraversal<A, A> profile() {
+ return this.start().profile();
+ }
+
+ public default GraphTraversal<A, A> withSideEffect(final String key, final Supplier supplier) {
+ return this.start().withSideEffect(key, supplier);
+ }
+
+ public default <B> GraphTraversal<A, A> withSack(final Supplier<B> initialValue, final UnaryOperator<B> splitOperator) {
+ return this.start().withSack(initialValue, splitOperator);
+ }
+
+ public default <B> GraphTraversal<A, A> withSack(final Supplier<B> initialValue) {
+ return this.start().withSack(initialValue);
+ }
+
+ public default <B> GraphTraversal<A, A> withSack(final B initialValue, final UnaryOperator<B> splitOperator) {
+ return this.start().withSack(initialValue, splitOperator);
+ }
+
+ public default <B> GraphTraversal<A, A> withSack(B initialValue) {
+ return this.start().withSack(initialValue);
+ }
+
+ public default GraphTraversal<A, A> withPath() {
+ return this.start().withPath();
+ }
+
+ public default GraphTraversal<A, A> barrier() {
+ return this.start().barrier();
+ }
+
+ ////
+
+ public default GraphTraversal<A, A> iterate() {
+ return this.start().iterate();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/GraphTraversal.java
new file mode 100644
index 0000000..c93d4cd
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/GraphTraversal.java
@@ -0,0 +1,782 @@
+/*
+ * 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.process.graph.traversal;
+
+import com.tinkerpop.gremlin.process.Path;
+import com.tinkerpop.gremlin.process.Scope;
+import com.tinkerpop.gremlin.process.Step;
+import com.tinkerpop.gremlin.process.T;
+import com.tinkerpop.gremlin.process.Traversal;
+import com.tinkerpop.gremlin.process.TraversalEngine;
+import com.tinkerpop.gremlin.process.Traverser;
+import com.tinkerpop.gremlin.process.computer.ComputerResult;
+import com.tinkerpop.gremlin.process.computer.GraphComputer;
+import com.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram;
+import com.tinkerpop.gremlin.process.computer.traversal.step.map.ComputerResultStep;
+import com.tinkerpop.gremlin.process.graph.traversal.lambda.LoopTraversal;
+import com.tinkerpop.gremlin.process.graph.traversal.step.ComparatorHolder;
+import com.tinkerpop.gremlin.process.graph.traversal.step.TraversalOptionParent;
+import com.tinkerpop.gremlin.process.graph.traversal.step.branch.BranchStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.branch.ChooseStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.branch.LocalStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.branch.RepeatStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.branch.UnionStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.AndStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.CoinStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.CyclicPathStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.DedupStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.ExceptStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.HasStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.HasTraversalStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.IsStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.LambdaFilterStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.OrStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.RangeStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.RetainStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.SampleStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.SimplePathStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.TimeLimitStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.filter.WhereStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.BackStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.CoalesceStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.CountStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.EdgeOtherVertexStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.EdgeVertexStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.FoldStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.IdStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.KeyStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.LabelStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.LambdaFlatMapStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.LambdaMapStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.MaxStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.MeanStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.MinStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.OrderGlobalStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.OrderLocalStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.PathStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.PropertiesStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.PropertyMapStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.PropertyValueStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.SackStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.SelectOneStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.SelectStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.SumStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.UnfoldStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.VertexStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.map.match.MatchStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.AddEdgeStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.AggregateStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.GroupCountStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.GroupStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.IdentityStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.InjectStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.LambdaSideEffectStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.ProfileStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.SackElementValueStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.SackObjectStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.SideEffectCapStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.StartStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.StoreStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.SubgraphStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.TreeStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.util.CollectingBarrierStep;
+import com.tinkerpop.gremlin.process.graph.traversal.step.util.PathIdentityStep;
+import com.tinkerpop.gremlin.process.graph.util.HasContainer;
+import com.tinkerpop.gremlin.process.traversal.lambda.ElementValueTraversal;
+import com.tinkerpop.gremlin.process.traversal.lambda.FilterTraversal;
+import com.tinkerpop.gremlin.process.traversal.lambda.FilterTraverserTraversal;
+import com.tinkerpop.gremlin.process.traversal.lambda.IdentityTraversal;
+import com.tinkerpop.gremlin.process.traversal.lambda.MapTraversal;
+import com.tinkerpop.gremlin.process.traversal.lambda.MapTraverserTraversal;
+import com.tinkerpop.gremlin.process.traversal.lambda.TrueTraversal;
+import com.tinkerpop.gremlin.process.traversal.step.ElementFunctionComparator;
+import com.tinkerpop.gremlin.process.traversal.step.ElementValueComparator;
+import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
+import com.tinkerpop.gremlin.process.util.TraverserSet;
+import com.tinkerpop.gremlin.structure.Compare;
+import com.tinkerpop.gremlin.structure.Contains;
+import com.tinkerpop.gremlin.structure.Direction;
+import com.tinkerpop.gremlin.structure.Edge;
+import com.tinkerpop.gremlin.structure.Element;
+import com.tinkerpop.gremlin.structure.Order;
+import com.tinkerpop.gremlin.structure.Property;
+import com.tinkerpop.gremlin.structure.PropertyType;
+import com.tinkerpop.gremlin.structure.Vertex;
+import com.tinkerpop.gremlin.util.function.ConstantSupplier;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface GraphTraversal<S, E> extends Traversal<S, E> {
+
+ public interface Admin<S, E> extends Traversal.Admin<S, E>, GraphTraversal<S, E> {
+
+ @Override
+ public default <E2> GraphTraversal.Admin<S, E2> addStep(final Step<?, E2> step) {
+ return (GraphTraversal.Admin<S, E2>) Traversal.Admin.super.addStep((Step) step);
+ }
+
+ @Override
+ public default GraphTraversal<S, E> iterate() {
+ return GraphTraversal.super.iterate();
+ }
+
+ @Override
+ public GraphTraversal.Admin<S, E> clone() throws CloneNotSupportedException;
+ }
+
+ @Override
+ public default GraphTraversal<S, E> submit(final GraphComputer computer) {
+ try {
+ final TraversalVertexProgram vertexProgram = TraversalVertexProgram.build().traversal(this.asAdmin()).create();
+ final ComputerResult result = computer.program(vertexProgram).submit().get();
+ final GraphTraversal.Admin<S, S> traversal = new DefaultGraphTraversal<>(result.graph().getClass());
+ return traversal.addStep(new ComputerResultStep<>(traversal, result, vertexProgram, true));
+ } catch (final Exception e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public default GraphTraversal.Admin<S, E> asAdmin() {
+ return (GraphTraversal.Admin<S, E>) this;
+ }
+
+ ///////////////////// MAP STEPS /////////////////////
+
+ public default <E2> GraphTraversal<S, E2> map(final Function<Traverser<E>, E2> function) {
+ return this.asAdmin().addStep(new LambdaMapStep<>(this.asAdmin(), function));
+ }
+
+ public default <E2> GraphTraversal<S, E2> flatMap(final Function<Traverser<E>, Iterator<E2>> function) {
+ return this.asAdmin().addStep(new LambdaFlatMapStep<>(this.asAdmin(), function));
+ }
+
+ public default GraphTraversal<S, Object> id() {
+ return this.asAdmin().addStep(new IdStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, String> label() {
+ return this.asAdmin().addStep(new LabelStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, E> identity() {
+ return this.asAdmin().addStep(new IdentityStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, Vertex> to(final Direction direction, final String... edgeLabels) {
+ return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, direction, edgeLabels));
+ }
+
+ public default GraphTraversal<S, Vertex> out(final String... edgeLabels) {
+ return this.to(Direction.OUT, edgeLabels);
+ }
+
+ public default GraphTraversal<S, Vertex> in(final String... edgeLabels) {
+ return this.to(Direction.IN, edgeLabels);
+ }
+
+ public default GraphTraversal<S, Vertex> both(final String... edgeLabels) {
+ return this.to(Direction.BOTH, edgeLabels);
+ }
+
+ public default GraphTraversal<S, Edge> toE(final Direction direction, final String... edgeLabels) {
+ return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, direction, edgeLabels));
+ }
+
+ public default GraphTraversal<S, Edge> outE(final String... edgeLabels) {
+ return this.toE(Direction.OUT, edgeLabels);
+ }
+
+ public default GraphTraversal<S, Edge> inE(final String... edgeLabels) {
+ return this.toE(Direction.IN, edgeLabels);
+ }
+
+ public default GraphTraversal<S, Edge> bothE(final String... edgeLabels) {
+ return this.toE(Direction.BOTH, edgeLabels);
+ }
+
+ public default GraphTraversal<S, Vertex> toV(final Direction direction) {
+ return this.asAdmin().addStep(new EdgeVertexStep(this.asAdmin(), direction));
+ }
+
+ public default GraphTraversal<S, Vertex> inV() {
+ return this.toV(Direction.IN);
+ }
+
+ public default GraphTraversal<S, Vertex> outV() {
+ return this.toV(Direction.OUT);
+ }
+
+ public default GraphTraversal<S, Vertex> bothV() {
+ return this.toV(Direction.BOTH);
+ }
+
+ public default GraphTraversal<S, Vertex> otherV() {
+ return this.asAdmin().addStep(new EdgeOtherVertexStep(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, E> order() {
+ return this.order(Scope.global);
+ }
+
+ public default GraphTraversal<S, E> order(final Scope scope) {
+ return scope.equals(Scope.local) ? this.asAdmin().addStep(new OrderLocalStep<>(this.asAdmin())) : this.asAdmin().addStep(new OrderGlobalStep<>(this.asAdmin()));
+ }
+
+ public default <E2> GraphTraversal<S, ? extends Property<E2>> properties(final String... propertyKeys) {
+ return this.asAdmin().addStep(new PropertiesStep<>(this.asAdmin(), PropertyType.PROPERTY, propertyKeys));
+ }
+
+ public default <E2> GraphTraversal<S, E2> values(final String... propertyKeys) {
+ return this.asAdmin().addStep(new PropertiesStep<>(this.asAdmin(), PropertyType.VALUE, propertyKeys));
+ }
+
+ public default <E2> GraphTraversal<S, Map<String, E2>> propertyMap(final String... propertyKeys) {
+ return this.asAdmin().addStep(new PropertyMapStep<>(this.asAdmin(), false, PropertyType.PROPERTY, propertyKeys));
+ }
+
+ public default <E2> GraphTraversal<S, Map<String, E2>> valueMap(final String... propertyKeys) {
+ return this.asAdmin().addStep(new PropertyMapStep<>(this.asAdmin(), false, PropertyType.VALUE, propertyKeys));
+ }
+
+ public default <E2> GraphTraversal<S, Map<String, E2>> valueMap(final boolean includeTokens, final String... propertyKeys) {
+ return this.asAdmin().addStep(new PropertyMapStep<>(this.asAdmin(), includeTokens, PropertyType.VALUE, propertyKeys));
+ }
+
+ public default GraphTraversal<S, String> key() {
+ return this.asAdmin().addStep(new KeyStep(this.asAdmin()));
+ }
+
+ public default <E2> GraphTraversal<S, E2> value() {
+ return this.asAdmin().addStep(new PropertyValueStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, Path> path() {
+ return this.asAdmin().addStep(new PathStep<>(this.asAdmin()));
+ }
+
+ public default <E2> GraphTraversal<S, E2> back(final String stepLabel) {
+ return this.asAdmin().addStep(new BackStep<>(this.asAdmin(), stepLabel));
+ }
+
+ public default <E2> GraphTraversal<S, Map<String, E2>> match(final String startLabel, final Traversal... traversals) {
+ return (GraphTraversal) this.asAdmin().addStep(new MatchStep<E, Map<String, E2>>(this.asAdmin(), startLabel, traversals));
+ }
+
+ public default <E2> GraphTraversal<S, E2> sack() {
+ return this.asAdmin().addStep(new SackStep<>(this.asAdmin()));
+ }
+
+ public default <E2> GraphTraversal<S, Map<String, E2>> select(final String... stepLabels) {
+ return this.asAdmin().addStep(new SelectStep<>(this.asAdmin(), stepLabels));
+ }
+
+ public default <E2> GraphTraversal<S, E2> select(final String stepLabel) {
+ return this.asAdmin().addStep(new SelectOneStep(this.asAdmin(), stepLabel));
+ }
+
+ public default <E2> GraphTraversal<S, E2> unfold() {
+ return this.asAdmin().addStep(new UnfoldStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, List<E>> fold() {
+ return this.asAdmin().addStep(new FoldStep<>(this.asAdmin()));
+ }
+
+ public default <E2> GraphTraversal<S, E2> fold(final E2 seed, final BiFunction<E2, E, E2> foldFunction) {
+ return this.asAdmin().addStep(new FoldStep<>(this.asAdmin(), new ConstantSupplier<>(seed), foldFunction)); // TODO: User should provide supplier?
+ }
+
+ public default GraphTraversal<S, Long> count() {
+ return this.asAdmin().addStep(new CountStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, Double> sum() {
+ return this.asAdmin().addStep(new SumStep(this.asAdmin()));
+ }
+
+ public default <E2 extends Number> GraphTraversal<S, E2> max() {
+ return this.asAdmin().addStep(new MaxStep<>(this.asAdmin()));
+ }
+
+ public default <E2 extends Number> GraphTraversal<S, E2> min() {
+ return this.asAdmin().addStep(new MinStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, Double> mean() {
+ return this.asAdmin().addStep(new MeanStep<>(this.asAdmin()));
+ }
+
+ ///////////////////// FILTER STEPS /////////////////////
+
+ public default GraphTraversal<S, E> filter(final Predicate<Traverser<E>> predicate) {
+ return this.asAdmin().addStep(new LambdaFilterStep<>(this.asAdmin(), predicate));
+ }
+
+ public default GraphTraversal<S, E> or(final Traversal<?, ?>... orTraversals) {
+ return this.asAdmin().addStep(0 == orTraversals.length ?
+ new OrStep.OrMarker<>(this.asAdmin()) :
+ new OrStep(this.asAdmin(), Arrays.copyOf(orTraversals, orTraversals.length, Traversal.Admin[].class)));
+ }
+
+ public default GraphTraversal<S, E> and(final Traversal<?, ?>... andTraversals) {
+ return this.asAdmin().addStep(0 == andTraversals.length ?
+ new AndStep.AndMarker<>(this.asAdmin()) :
+ new AndStep(this.asAdmin(), Arrays.copyOf(andTraversals, andTraversals.length, Traversal.Admin[].class)));
+ }
+
+ public default GraphTraversal<S, E> inject(final E... injections) {
+ return this.asAdmin().addStep(new InjectStep<>(this.asAdmin(), injections));
+ }
+
+ public default GraphTraversal<S, E> dedup() {
+ return this.asAdmin().addStep(new DedupStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, E> except(final String sideEffectKeyOrPathLabel) {
+ return this.asAdmin().addStep(new ExceptStep<E>(this.asAdmin(), sideEffectKeyOrPathLabel));
+ }
+
+ public default GraphTraversal<S, E> except(final E exceptObject) {
+ return this.asAdmin().addStep(new ExceptStep<>(this.asAdmin(), exceptObject));
+ }
+
+ public default GraphTraversal<S, E> except(final Collection<E> exceptCollection) {
+ return this.asAdmin().addStep(new ExceptStep<>(this.asAdmin(), exceptCollection));
+ }
+
+ public default <E2> GraphTraversal<S, Map<String, E2>> where(final String firstKey, final String secondKey, final BiPredicate predicate) {
+ return this.asAdmin().addStep(new WhereStep(this.asAdmin(), firstKey, secondKey, predicate));
+ }
+
+ public default <E2> GraphTraversal<S, Map<String, E2>> where(final String firstKey, final BiPredicate predicate, final String secondKey) {
+ return this.where(firstKey, secondKey, predicate);
+ }
+
+ public default <E2> GraphTraversal<S, Map<String, E2>> where(final Traversal constraint) {
+ return this.asAdmin().addStep(new WhereStep<>(this.asAdmin(), constraint.asAdmin()));
+ }
+
+ public default GraphTraversal<S, E> has(final Traversal<?, ?> hasNextTraversal) {
+ return this.asAdmin().addStep(new HasTraversalStep<>(this.asAdmin(), (Traversal.Admin<E, ?>) hasNextTraversal));
+ }
+
+ public default GraphTraversal<S, E> has(final String key) {
+ return this.asAdmin().addStep(new HasStep(this.asAdmin(), new HasContainer(key, Contains.within)));
+ }
+
+ public default GraphTraversal<S, E> has(final String key, final Object value) {
+ return this.has(key, Compare.eq, value);
+ }
+
+ public default GraphTraversal<S, E> has(final T accessor, final Object value) {
+ return this.has(accessor.getAccessor(), value);
+ }
+
+ public default GraphTraversal<S, E> has(final String key, final BiPredicate predicate, final Object value) {
+ return this.asAdmin().addStep(new HasStep(this.asAdmin(), new HasContainer(key, predicate, value)));
+ }
+
+ public default GraphTraversal<S, E> has(final T accessor, final BiPredicate predicate, final Object value) {
+ return this.has(accessor.getAccessor(), predicate, value);
+ }
+
+ public default GraphTraversal<S, E> has(final String label, final String key, final Object value) {
+ return this.has(label, key, Compare.eq, value);
+ }
+
+ public default GraphTraversal<S, E> has(final String label, final String key, final BiPredicate predicate, final Object value) {
+ return this.has(T.label, label).has(key, predicate, value);
+ }
+
+ public default GraphTraversal<S, E> hasNot(final String key) {
+ return this.asAdmin().addStep(new HasStep(this.asAdmin(), new HasContainer(key, Contains.without)));
+ }
+
+ public default GraphTraversal<S, E> hasLabel(final String... labels) {
+ return labels.length == 1 ? this.has(T.label, labels[0]) : this.has(T.label, Contains.within, Arrays.asList(labels));
+ }
+
+ public default GraphTraversal<S, E> hasId(final Object... ids) {
+ return ids.length == 1 ? this.has(T.id, ids[0]) : this.has(T.id, Contains.within, Arrays.asList(ids));
+ }
+
+ public default GraphTraversal<S, E> hasKey(final String... keys) {
+ return keys.length == 1 ? this.has(T.key, keys[0]) : this.has(T.key, Contains.within, Arrays.asList(keys));
+ }
+
+ public default GraphTraversal<S, E> hasValue(final Object... values) {
+ return values.length == 1 ? this.has(T.value, values[0]) : this.has(T.value, Contains.within, Arrays.asList(values));
+ }
+
+ public default GraphTraversal<S, E> is(final Object value) {
+ return this.is(Compare.eq, value);
+ }
+
+ public default GraphTraversal<S, E> is(final BiPredicate predicate, final Object value) {
+ return this.asAdmin().addStep(new IsStep(this.asAdmin(), predicate, value));
+ }
+
+ public default GraphTraversal<S, E> coin(final double probability) {
+ return this.asAdmin().addStep(new CoinStep<>(this.asAdmin(), probability));
+ }
+
+ public default GraphTraversal<S, E> range(final long low, final long high) {
+ return this.asAdmin().addStep(new RangeStep<>(this.asAdmin(), low, high));
+ }
+
+ public default GraphTraversal<S, E> limit(final long limit) {
+ return this.range(0, limit);
+ }
+
+ public default GraphTraversal<S, E> retain(final String sideEffectKeyOrPathLabel) {
+ return this.asAdmin().addStep(new RetainStep<>(this.asAdmin(), sideEffectKeyOrPathLabel));
+ }
+
+ public default GraphTraversal<S, E> retain(final E retainObject) {
+ return this.asAdmin().addStep(new RetainStep<>(this.asAdmin(), retainObject));
+ }
+
+ public default GraphTraversal<S, E> retain(final Collection<E> retainCollection) {
+ return this.asAdmin().addStep(new RetainStep<>(this.asAdmin(), retainCollection));
+ }
+
+ public default GraphTraversal<S, E> simplePath() {
+ return this.asAdmin().addStep(new SimplePathStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, E> cyclicPath() {
+ return this.asAdmin().addStep(new CyclicPathStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, E> sample(final int amountToSample) {
+ return this.asAdmin().addStep(new SampleStep<>(this.asAdmin(), amountToSample));
+ }
+
+ ///////////////////// SIDE-EFFECT STEPS /////////////////////
+
+ public default GraphTraversal<S, E> sideEffect(final Consumer<Traverser<E>> consumer) {
+ return this.asAdmin().addStep(new LambdaSideEffectStep<>(this.asAdmin(), consumer));
+ }
+
+ public default <E2> GraphTraversal<S, E2> cap(final String... sideEffectKeys) {
+ return this.asAdmin().addStep(new SideEffectCapStep<>(this.asAdmin(), sideEffectKeys));
+ }
+
+ public default GraphTraversal<S, Edge> subgraph(final String sideEffectKey) {
+ return this.asAdmin().addStep(new SubgraphStep(this.asAdmin(), sideEffectKey));
+ }
+
+ public default GraphTraversal<S, Edge> subgraph() {
+ return this.subgraph(null);
+ }
+
+ public default GraphTraversal<S, E> aggregate(final String sideEffectKey) {
+ return this.asAdmin().addStep(new AggregateStep<>(this.asAdmin(), sideEffectKey));
+ }
+
+ public default GraphTraversal<S, E> aggregate() {
+ return this.aggregate(null);
+ }
+
+ public default GraphTraversal<S, E> group(final String sideEffectKey) {
+ return this.asAdmin().addStep(new GroupStep<>(this.asAdmin(), sideEffectKey));
+ }
+
+ public default GraphTraversal<S, E> group() {
+ return this.group(null);
+ }
+
+ public default GraphTraversal<S, E> groupCount(final String sideEffectKey) {
+ return this.asAdmin().addStep(new GroupCountStep<>(this.asAdmin(), sideEffectKey));
+ }
+
+ public default GraphTraversal<S, E> groupCount() {
+ return this.groupCount(null);
+ }
+
+ public default GraphTraversal<S, Vertex> addE(final Direction direction, final String edgeLabel, final String stepLabel, final Object... propertyKeyValues) {
+ return this.asAdmin().addStep(new AddEdgeStep(this.asAdmin(), direction, edgeLabel, stepLabel, propertyKeyValues));
+ }
+
+ public default GraphTraversal<S, Vertex> addInE(final String edgeLabel, final String stepLabel, final Object... propertyKeyValues) {
+ return this.addE(Direction.IN, edgeLabel, stepLabel, propertyKeyValues);
+ }
+
+ public default GraphTraversal<S, Vertex> addOutE(final String edgeLabel, final String stepLabel, final Object... propertyKeyValues) {
+ return this.addE(Direction.OUT, edgeLabel, stepLabel, propertyKeyValues);
+ }
+
+ public default GraphTraversal<S, Vertex> addBothE(final String edgeLabel, final String stepLabel, final Object... propertyKeyValues) {
+ return this.addE(Direction.BOTH, edgeLabel, stepLabel, propertyKeyValues);
+ }
+
+ public default GraphTraversal<S, E> timeLimit(final long timeLimit) {
+ return this.asAdmin().addStep(new TimeLimitStep<E>(this.asAdmin(), timeLimit));
+ }
+
+ public default GraphTraversal<S, E> tree(final String sideEffectKey) {
+ return this.asAdmin().addStep(new TreeStep<>(this.asAdmin(), sideEffectKey));
+ }
+
+ public default GraphTraversal<S, E> tree() {
+ return this.tree(null);
+ }
+
+ public default <V> GraphTraversal<S, E> sack(final BiFunction<V, E, V> sackFunction) {
+ return this.asAdmin().addStep(new SackObjectStep<>(this.asAdmin(), sackFunction));
+ }
+
+ public default <V> GraphTraversal<S, E> sack(final BinaryOperator<V> sackOperator, final String elementPropertyKey) {
+ return this.asAdmin().addStep(new SackElementValueStep(this.asAdmin(), sackOperator, elementPropertyKey));
+ }
+
+ public default GraphTraversal<S, E> store(final String sideEffectKey) {
+ return this.asAdmin().addStep(new StoreStep<>(this.asAdmin(), sideEffectKey));
+ }
+
+ public default GraphTraversal<S, E> store() {
+ return this.store(null);
+ }
+
+ public default GraphTraversal<S, E> profile() {
+ return this.asAdmin().addStep(new ProfileStep<>(this.asAdmin()));
+ }
+
+ ///////////////////// BRANCH STEPS /////////////////////
+
+ public default <M, E2> GraphTraversal<S, E2> branch(final Traversal<?, M> branchTraversal) {
+ final BranchStep<E, E2, M> branchStep = new BranchStep<>(this.asAdmin());
+ branchStep.setBranchTraversal((Traversal.Admin<E, M>) branchTraversal);
+ return this.asAdmin().addStep(branchStep);
+ }
+
+ public default <M, E2> GraphTraversal<S, E2> branch(final Function<Traverser<E>, M> function) {
+ return this.branch(new MapTraverserTraversal<>(function));
+ }
+
+ public default <M, E2> GraphTraversal<S, E2> choose(final Traversal<?, M> choiceTraversal) {
+ return this.asAdmin().addStep(new ChooseStep<>(this.asAdmin(), (Traversal.Admin<E, M>) choiceTraversal));
+ }
+
+ public default <E2> GraphTraversal<S, E2> choose(final Traversal<?, ?> traversalPredicate, final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
+ return this.asAdmin().addStep(new ChooseStep<E, E2, Boolean>(this.asAdmin(), (Traversal.Admin<E, ?>) traversalPredicate, (Traversal.Admin<E, E2>) trueChoice, (Traversal.Admin<E, E2>) falseChoice));
+ }
+
+ public default <M, E2> GraphTraversal<S, E2> choose(final Function<E, M> choiceFunction) {
+ return this.choose(new MapTraversal<>(choiceFunction));
+ }
+
+ public default <E2> GraphTraversal<S, E2> choose(final Predicate<E> choosePredicate, final Traversal<?, E2> trueChoice, final Traversal<?, E2> falseChoice) {
+ return this.choose(new FilterTraversal<>(choosePredicate), trueChoice, falseChoice);
+ }
+
+ public default <E2> GraphTraversal<S, E2> union(final Traversal<?, E2>... unionTraversals) {
+ return this.asAdmin().addStep(new UnionStep(this.asAdmin(), Arrays.copyOf(unionTraversals, unionTraversals.length, Traversal.Admin[].class)));
+ }
+
+ public default <E2> GraphTraversal<S, E2> coalesce(final Traversal<?, E2>... coalesceTraversals) {
+ return this.asAdmin().addStep(new CoalesceStep(this.asAdmin(), Arrays.copyOf(coalesceTraversals, coalesceTraversals.length, Traversal.Admin[].class)));
+ }
+
+ public default GraphTraversal<S, E> repeat(final Traversal<?, E> repeatTraversal) {
+ return RepeatStep.addRepeatToTraversal(this, (Traversal.Admin<E, E>) repeatTraversal);
+ }
+
+ public default GraphTraversal<S, E> emit(final Traversal<?, ?> emitTraversal) {
+ return RepeatStep.addEmitToTraversal(this, (Traversal.Admin<E, ?>) emitTraversal);
+ }
+
+ public default GraphTraversal<S, E> emit(final Predicate<Traverser<E>> emitPredicate) {
+ return this.emit(new FilterTraverserTraversal<>(emitPredicate));
+ }
+
+ public default GraphTraversal<S, E> emit() {
+ return this.emit(TrueTraversal.instance());
+ }
+
+ public default GraphTraversal<S, E> until(final Traversal<?, ?> untilTraversal) {
+ return RepeatStep.addUntilToTraversal(this, (Traversal.Admin<E, ?>) untilTraversal);
+ }
+
+ public default GraphTraversal<S, E> until(final Predicate<Traverser<E>> untilPredicate) {
+ return this.until(new FilterTraverserTraversal<>(untilPredicate));
+ }
+
+ public default GraphTraversal<S, E> times(final int maxLoops) {
+ return this.until(new LoopTraversal(maxLoops));
+ }
+
+ public default <E2> GraphTraversal<S, E2> local(final Traversal<?, E2> localTraversal) {
+ return this.asAdmin().addStep(new LocalStep<>(this.asAdmin(), localTraversal.asAdmin()));
+ }
+
+ ///////////////////// UTILITY STEPS /////////////////////
+
+ public default GraphTraversal<S, E> withSideEffect(final String key, final Supplier supplier) {
+ this.asAdmin().getSideEffects().registerSupplier(key, supplier);
+ return this;
+ }
+
+ public default <A> GraphTraversal<S, E> withSack(final Supplier<A> initialValue, final UnaryOperator<A> splitOperator) {
+ this.asAdmin().getSideEffects().setSack(initialValue, Optional.of(splitOperator));
+ return this;
+ }
+
+ public default <A> GraphTraversal<S, E> withSack(final Supplier<A> initialValue) {
+ this.asAdmin().getSideEffects().setSack(initialValue, Optional.empty());
+ return this;
+ }
+
+ public default <A> GraphTraversal<S, E> withSack(final A initialValue, final UnaryOperator<A> splitOperator) {
+ this.asAdmin().getSideEffects().setSack(new ConstantSupplier<>(initialValue), Optional.of(splitOperator));
+ return this;
+ }
+
+ public default <A> GraphTraversal<S, E> withSack(A initialValue) {
+ this.asAdmin().getSideEffects().setSack(new ConstantSupplier<>(initialValue), Optional.empty());
+ return this;
+ }
+
+ public default GraphTraversal<S, E> withPath() {
+ return this.asAdmin().addStep(new PathIdentityStep<>(this.asAdmin()));
+ }
+
+ public default GraphTraversal<S, E> as(final String stepLabel) {
+ if (this.asAdmin().getSteps().size() == 0) this.asAdmin().addStep(new StartStep<>(this.asAdmin()));
+ this.asAdmin().getEndStep().setLabel(stepLabel);
+ return this;
+ }
+
+ public default GraphTraversal<S, E> barrier() {
+ return this.asAdmin().addStep(new CollectingBarrierStep(asAdmin()) {
+ @Override
+ public void barrierConsumer(TraverserSet traverserSet) {
+
+ }
+ });
+ }
+
+ ////
+
+ public default GraphTraversal<S, E> by() {
+ ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(new IdentityTraversal<>());
+ return this;
+ }
+
+ public default <V> GraphTraversal<S, E> by(final Function<V, Object> functionProjection) {
+ ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(new MapTraversal<>(functionProjection));
+ return this;
+ }
+
+ public default GraphTraversal<S, E> by(final T tokenProjection) {
+ ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(new MapTraversal<>(tokenProjection));
+ return this;
+ }
+
+ public default GraphTraversal<S, E> by(final String elementPropertyKey) {
+ ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(new ElementValueTraversal<>(elementPropertyKey));
+ return this;
+ }
+
+ public default GraphTraversal<S, E> by(final Traversal<?, ?> byTraversal) {
+ ((TraversalParent) this.asAdmin().getEndStep()).addLocalChild(byTraversal.asAdmin());
+ return this;
+ }
+
+ ////
+
+ public default GraphTraversal<S, E> by(final Order order) {
+ ((ComparatorHolder) this.asAdmin().getEndStep()).addComparator(order);
+ return this;
+ }
+
+ public default GraphTraversal<S, E> by(final Comparator<E> comparator) {
+ ((ComparatorHolder<E>) this.asAdmin().getEndStep()).addComparator(comparator);
+ return this;
+ }
+
+ public default <V> GraphTraversal<S, E> by(final Function<Element, V> elementFunctionProjection, final Comparator<V> elementFunctionValueComparator) {
+ ((ComparatorHolder<Element>) this.asAdmin().getEndStep()).addComparator(new ElementFunctionComparator<>(elementFunctionProjection, elementFunctionValueComparator));
+ return this;
+ }
+
+ public default <V> GraphTraversal<S, E> by(final String elementPropertyProjection, final Comparator<V> propertyValueComparator) {
+ ((ComparatorHolder<Element>) this.asAdmin().getEndStep()).addComparator(new ElementValueComparator<>(elementPropertyProjection, propertyValueComparator));
+ return this;
+ }
+
+ ////
+
+ public default <M, E2> GraphTraversal<S, E> option(final M pickToken, final Traversal<E, E2> traversalOption) {
+ ((TraversalOptionParent<M, E, E2>) this.asAdmin().getEndStep()).addGlobalChildOption(pickToken, traversalOption.asAdmin());
+ return this;
+ }
+
+ public default <E2> GraphTraversal<S, E> option(final Traversal<E, E2> traversalOption) {
+ ((TraversalOptionParent<TraversalOptionParent.Pick, E, E2>) this.asAdmin().getEndStep()).addGlobalChildOption(TraversalOptionParent.Pick.any, traversalOption.asAdmin());
+ return this;
+ }
+
+ ////
+
+ @Override
+ public default void remove() {
+ try {
+ this.asAdmin().applyStrategies(TraversalEngine.STANDARD);
+ final Step<?, E> endStep = this.asAdmin().getEndStep();
+ while (true) {
+ final Object object = endStep.next().get();
+ if (object instanceof Element)
+ ((Element) object).remove();
+ else if (object instanceof Property)
+ ((Property) object).remove();
+ else {
+ throw new IllegalStateException("The following object does not have a remove() method: " + object);
+ }
+ }
+ } catch (final NoSuchElementException ignored) {
+
+ }
+ }
+
+ @Override
+ public default GraphTraversal<S, E> iterate() {
+ Traversal.super.iterate();
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/VertexPropertyTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/VertexPropertyTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/VertexPropertyTraversal.java
new file mode 100644
index 0000000..be0f293
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/VertexPropertyTraversal.java
@@ -0,0 +1,54 @@
+/*
+ * 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.process.graph.traversal;
+
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.StartStep;
+import com.tinkerpop.gremlin.structure.Property;
+import com.tinkerpop.gremlin.structure.VertexProperty;
+
+import java.util.Map;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface VertexPropertyTraversal extends ElementTraversal<VertexProperty> {
+
+ @Override
+ default GraphTraversal<VertexProperty, VertexProperty> start() {
+ final GraphTraversal.Admin<VertexProperty, VertexProperty> traversal = new DefaultGraphTraversal<>(this.getClass());
+ return traversal.addStep(new StartStep<>(traversal, this));
+ }
+
+ @Override
+ public default <E2> GraphTraversal<VertexProperty, Property<E2>> properties(final String... propertyKeys) {
+ return (GraphTraversal) this.start().properties(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<VertexProperty, Map<String, Property<E2>>> propertyMap(final String... propertyKeys) {
+ return this.start().propertyMap(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<VertexProperty, Map<String, E2>> valueMap(final String... propertyKeys) {
+ return this.start().valueMap(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<VertexProperty, Map<String, E2>> valueMap(final boolean includeTokens, final String... propertyKeys) {
+ return this.start().valueMap(includeTokens, propertyKeys);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/VertexTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/VertexTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/VertexTraversal.java
new file mode 100644
index 0000000..9bc0c9b
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/VertexTraversal.java
@@ -0,0 +1,61 @@
+/*
+ * 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.process.graph.traversal;
+
+import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.StartStep;
+import com.tinkerpop.gremlin.structure.Vertex;
+import com.tinkerpop.gremlin.structure.VertexProperty;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface VertexTraversal extends ElementTraversal<Vertex> {
+
+ @Override
+ default GraphTraversal<Vertex, Vertex> start() {
+ final GraphTraversal.Admin<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(this.getClass());
+ return traversal.addStep(new StartStep<>(traversal, this));
+ }
+
+ @Override
+ public default <E2> GraphTraversal<Vertex, VertexProperty<E2>> properties(final String... propertyKeys) {
+ return (GraphTraversal) this.start().properties(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<Vertex, Map<String, List<VertexProperty<E2>>>> propertyMap(final String... propertyKeys) {
+ return this.start().propertyMap(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<Vertex, Map<String, List<E2>>> valueMap(final String... propertyKeys) {
+ return this.start().valueMap(propertyKeys);
+ }
+
+ public default <E2> GraphTraversal<Vertex, Map<String, List<E2>>> valueMap(final boolean includeTokens, final String... propertyKeys) {
+ return this.start().valueMap(includeTokens, propertyKeys);
+ }
+
+ // necessary so VertexProperty.value() as a non-traversal method works
+ public default <E2> GraphTraversal<Vertex, E2> value() {
+ return this.start().value();
+ }
+
+}