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:34 UTC
[08/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/io/kryo/VertexByteArrayInputStream.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/VertexByteArrayInputStream.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/VertexByteArrayInputStream.java
new file mode 100644
index 0000000..2f721f0
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/VertexByteArrayInputStream.java
@@ -0,0 +1,74 @@
+/*
+ * 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.io.kryo;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * An {@link InputStream} implementation that can independently process a Gremlin Kryo file written with
+ * {@link KryoWriter#writeVertices(java.io.OutputStream, com.tinkerpop.gremlin.process.Traversal)}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class VertexByteArrayInputStream extends FilterInputStream {
+
+ private static final byte[] vertexTerminatorClass = new byte[]{15, 1, 1, 9};
+ private static final byte[] pattern = ByteBuffer.allocate(vertexTerminatorClass.length + 8).put(vertexTerminatorClass).putLong(4185403236219066774L).array();
+
+ public VertexByteArrayInputStream(final InputStream inputStream) {
+ super(inputStream);
+ }
+
+ /**
+ * Read the bytes of the next {@link com.tinkerpop.gremlin.structure.Vertex} in the stream. The returned
+ * stream can then be passed to {@link KryoReader#readVertex(java.io.InputStream, java.util.function.Function)}.
+ */
+ public ByteArrayOutputStream readVertexBytes() throws IOException {
+ final ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ final LinkedList<Byte> buffer = new LinkedList<>();
+
+ int current = read();
+ while (current > -1 && (buffer.size() < 12 || !isMatch(buffer))) {
+ stream.write(current);
+
+ current = read();
+ if (buffer.size() > 11)
+ buffer.removeFirst();
+
+ buffer.addLast((byte) current);
+ }
+
+ return stream;
+ }
+
+ private static boolean isMatch(final List<Byte> input) {
+ for (int i = 0; i < pattern.length; i++) {
+ if (pattern[i] != input.get(i)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/VertexTerminator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/VertexTerminator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/VertexTerminator.java
new file mode 100644
index 0000000..36bec63
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/VertexTerminator.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.structure.io.kryo;
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+/**
+ * Represents the end of a vertex in a serialization stream.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class VertexTerminator {
+ public static final VertexTerminator INSTANCE = new VertexTerminator();
+
+ public final byte[] terminal;
+
+ private VertexTerminator() {
+ terminal = ByteBuffer.allocate(8).putLong(4185403236219066774L).array();
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final VertexTerminator that = (VertexTerminator) o;
+
+ return terminal == that.terminal;
+
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(terminal);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/ClusterAware.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/ClusterAware.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/ClusterAware.java
new file mode 100644
index 0000000..187ab8f
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/ClusterAware.java
@@ -0,0 +1,28 @@
+/*
+ * 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.server;
+
+import java.util.List;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface ClusterAware<V extends Comparable<V>> {
+ public List<Partition<V>> getVertexPartitions();
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/IntervalVertexRange.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/IntervalVertexRange.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/IntervalVertexRange.java
new file mode 100644
index 0000000..938813a
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/IntervalVertexRange.java
@@ -0,0 +1,85 @@
+/*
+ * 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.server;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class IntervalVertexRange<V extends Comparable<V>> implements VertexRange<V> {
+
+ /**
+ * Generated uid on Dec 10 2013
+ */
+ private static final long serialVersionUID = -71905414131570157L;
+
+ /**
+ * Inclusive.
+ */
+ private final V startRange;
+
+ /**
+ * Exclusive
+ */
+ private final V endRange;
+
+ public IntervalVertexRange(final V startRange, final V endRange, final int priority) {
+ this.startRange = startRange;
+ this.endRange = endRange;
+ }
+
+ @Override
+ public V getStartRange() {
+ return startRange;
+ }
+
+ @Override
+ public V getEndRange() {
+ return endRange;
+ }
+
+ @Override
+ public boolean contains(V item) {
+ return startRange.compareTo(item) <= 0 && endRange.compareTo(item) > 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final IntervalVertexRange<?> that = (IntervalVertexRange<?>) o;
+
+ if (!endRange.equals(that.endRange)) return false;
+ if (!startRange.equals(that.startRange)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = startRange.hashCode();
+ result = 31 * result + endRange.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "ElementRange[start=" + startRange + ", end=" + endRange + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/Partition.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/Partition.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/Partition.java
new file mode 100644
index 0000000..ea18255
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/Partition.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.structure.server;
+
+import java.util.List;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @author Matthias Broecheler (me@matthiasb.com)
+ */
+public interface Partition<V extends Comparable<V>> {
+
+ /**
+ * The priority specifies the priority this partition has in answering queries for vertices/edges that fall
+ * in this range.
+ */
+ public int getPriority();
+
+ public List<VertexRange<V>> getVertexRanges();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/VertexRange.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/VertexRange.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/VertexRange.java
new file mode 100644
index 0000000..41049c7
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/server/VertexRange.java
@@ -0,0 +1,31 @@
+/*
+ * 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.server;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @author Matthias Broecheler (me@matthiasb.com)
+ */
+public interface VertexRange<V extends Comparable<V>> {
+ public boolean contains(final V item);
+
+ public V getStartRange();
+
+ public V getEndRange();
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/GraphStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/GraphStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/GraphStrategy.java
new file mode 100644
index 0000000..ba9d22c
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/GraphStrategy.java
@@ -0,0 +1,708 @@
+/*
+ * 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.strategy;
+
+import com.tinkerpop.gremlin.process.graph.traversal.GraphTraversal;
+import com.tinkerpop.gremlin.structure.Direction;
+import com.tinkerpop.gremlin.structure.Edge;
+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.util.function.TriFunction;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+
+/**
+ * Defines a collection of functions that plug-in to Gremlin Structure API methods to enhance or alter the functionality of
+ * the implementation. The methods defined in {@link GraphStrategy} follow a common pattern where each method
+ * represents some injection point for new logic in the Gremlin Structure API. A method always accepts a
+ * {@link StrategyContext} which contains the context of the call being made and will have
+ * a different {@link StrategyContext#getCurrent()} object depending on that context (e.g the
+ * {@link com.tinkerpop.gremlin.structure.Vertex#addEdge(String, com.tinkerpop.gremlin.structure.Vertex, Object...)} method will send the instance of
+ * the {@link com.tinkerpop.gremlin.structure.Vertex} that was the object of that method call).
+ * <p/>
+ * A method will always return a {@link java.util.function.UnaryOperator} where the argument and return value to it is a function with
+ * the same signature as the calling method where the strategy logic is being injected. The argument passed in to
+ * this function will be a reference to the original calling function (from an implementation perspective, it might
+ * be best to think of this "calling function" as the original Gremlin Structure API method that performs the ultimate
+ * operation against the graph). In constructing the outgoing function to the {@link java.util.function.UnaryOperator}, it should
+ * of course match the signature of the original calling function and depending on the functionality,
+ * call the original function to trigger a call to the underlying implementation.
+ * <p/>
+ * The most simplistic implementation of a strategy method is to simply return a
+ * {@link java.util.function.UnaryOperator#identity()} which happens to be the default implementation for all the
+ * methods. By returning the {@code identity} function, the incoming original function is simply returned back
+ * unchanged with no additional enhancements to the execution of it.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public interface GraphStrategy {
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph.Iterators#vertexIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Graph.Iterators#vertexIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Function<Object[], Iterator<Vertex>>> getGraphIteratorsVertexIteratorStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph.Iterators#edgeIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Graph.Iterators#edgeIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Function<Object[], Iterator<Edge>>> getGraphIteratorsEdgeIteratorStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph.Variables#keys()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Graph.Variables#keys()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Set<String>>> getVariableKeysStrategy(final StrategyContext<StrategyVariables> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph.Variables#asMap()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Graph.Variables#asMap()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Map<String, Object>>> getVariableAsMapStrategy(final StrategyContext<StrategyVariables> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph.Variables#get(String)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with {@link com.tinkerpop.gremlin.structure.Graph.Variables#get(String)} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default <R> UnaryOperator<Function<String, Optional<R>>> getVariableGetStrategy(final StrategyContext<StrategyVariables> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.BiConsumer} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph.Variables#set(String, Object)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.BiConsumer} with {@link com.tinkerpop.gremlin.structure.Graph.Variables#set(String, Object)} signature
+ * and returns an enhanced strategy {@link java.util.function.BiConsumer} with the same signature
+ */
+ public default UnaryOperator<BiConsumer<String, Object>> getVariableSetStrategy(final StrategyContext<StrategyVariables> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Consumer} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph.Variables#remove(String)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Consumer} with {@link com.tinkerpop.gremlin.structure.Graph.Variables#remove(String)} signature
+ * and returns an enhanced strategy {@link java.util.function.BiConsumer} with the same signature
+ */
+ public default UnaryOperator<Consumer<String>> getVariableRemoveStrategy(final StrategyContext<StrategyVariables> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph#addVertex(Object...)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with {@link com.tinkerpop.gremlin.structure.Graph#addVertex(Object...)} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default UnaryOperator<Function<Object[], Vertex>> getAddVertexStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link com.tinkerpop.gremlin.util.function.TriFunction} that enhances the features of
+ * {@link com.tinkerpop.gremlin.structure.Vertex#addEdge(String, com.tinkerpop.gremlin.structure.Vertex, Object...)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link com.tinkerpop.gremlin.util.function.TriFunction} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex#addEdge(String, com.tinkerpop.gremlin.structure.Vertex, Object...)} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default UnaryOperator<TriFunction<String, Vertex, Object[], Edge>> getAddEdgeStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge#remove()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Edge#remove()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Void>> getRemoveEdgeStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex#remove()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex#remove()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Void>> getRemoveVertexStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Property#remove()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Property#remove()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<Void>> getRemovePropertyStrategy(final StrategyContext<StrategyProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty#remove()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty#remove()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<Void>> getRemoveVertexPropertyStrategy(final StrategyContext<StrategyVertexProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex#property(String)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex#property(String)} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default <V> UnaryOperator<Function<String, VertexProperty<V>>> getVertexGetPropertyStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex#keys()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex#keys()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Set<String>>> getVertexKeysStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex#label()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex#label()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<String>> getVertexLabelStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.BiFunction} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex#property(String, Object)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.BiFunction} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex#property(String, Object)} signature
+ * and returns an enhanced strategy {@link java.util.function.BiFunction} with the same signature
+ */
+ public default <V> UnaryOperator<BiFunction<String, V, VertexProperty<V>>> getVertexPropertyStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Element.Iterators#propertyIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Element.Iterators#propertyIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Function<String[], Iterator<VertexProperty<V>>>> getVertexIteratorsPropertyIteratorStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link TriFunction} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex.Iterators#vertexIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link BiFunction} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex.Iterators#vertexIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<BiFunction<Direction, String[], Iterator<Vertex>>> getVertexIteratorsVertexIteratorStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link TriFunction} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex.Iterators#edgeIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link BiFunction} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex.Iterators#edgeIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<BiFunction<Direction, String[], Iterator<Edge>>> getVertexIteratorsEdgeIteratorStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex.Iterators#valueIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex.Iterators#valueIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Function<String[], Iterator<V>>> getVertexIteratorsValueIteratorStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex#id()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex#id()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Object>> getVertexIdStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Vertex#graph()}.
+ * Note that in this case, the {@link Graph} is {@link StrategyGraph} and this would be the expected
+ * type to pass back out.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Vertex#graph()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Graph>> getVertexGraphStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Element#value(String)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Element#value(String)} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default <V> UnaryOperator<Function<String, V>> getVertexValueStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge#property(String)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Edge#property(String)} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default <V> UnaryOperator<Function<String, Property<V>>> getEdgeGetPropertyStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge.Iterators#vertexIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Edge.Iterators#vertexIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Function<Direction, Iterator<Vertex>>> getEdgeIteratorsVertexIteratorStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge.Iterators#valueIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Edge.Iterators#valueIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Function<String[], Iterator<V>>> getEdgeIteratorsValueIteratorStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge.Iterators#propertyIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Edge.Iterators#propertyIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Function<String[], Iterator<Property<V>>>> getEdgeIteratorsPropertyIteratorStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge#keys()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Edge#keys()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Set<String>>> getEdgeKeysStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.BiFunction} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge#property(String, Object)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.BiFunction} with
+ * {@link com.tinkerpop.gremlin.structure.Edge#property(String, Object)} signature
+ * and returns an enhanced strategy {@link java.util.function.BiFunction} with the same signature
+ */
+ public default <V> UnaryOperator<BiFunction<String, V, Property<V>>> getEdgePropertyStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge#value(String)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Element#value(String)} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default <V> UnaryOperator<Function<String, V>> getEdgeValueStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge#id()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Edge#id()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Object>> getEdgeIdStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge#graph()}.
+ * Note that in this case, the {@link Graph} is {@link StrategyGraph} and this would be the expected
+ * type to pass back out.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Edge#graph()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Graph>> getEdgeGraphStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Edge#label()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Edge#label()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<String>> getEdgeLabelStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty#id()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty#id()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<Object>> getVertexPropertyIdStrategy(final StrategyContext<StrategyVertexProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty#value()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Supplier} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty#value()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<V>> getVertexPropertyValueStrategy(final StrategyContext<StrategyVertexProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Property#key()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Supplier} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Property#key()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<String>> getVertexPropertyKeyStrategy(final StrategyContext<StrategyVertexProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty.Iterators#propertyIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty.Iterators#propertyIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V, U> UnaryOperator<Function<String[], Iterator<Property<V>>>> getVertexPropertyIteratorsPropertyIteratorStrategy(final StrategyContext<StrategyVertexProperty<U>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty.Iterators#valueIterator}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty.Iterators#valueIterator} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V, U> UnaryOperator<Function<String[], Iterator<V>>> getVertexPropertyIteratorsValueIteratorStrategy(final StrategyContext<StrategyVertexProperty<U>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.BiFunction} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty#property(String, Object)}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.BiFunction} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty#property(String, Object)} signature
+ * and returns an enhanced strategy {@link java.util.function.BiFunction} with the same signature
+ */
+ public default <V, U> UnaryOperator<BiFunction<String, V, Property<V>>> getVertexPropertyPropertyStrategy(final StrategyContext<StrategyVertexProperty<U>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty#graph()}.
+ * Note that in this case, the {@link Graph} is {@link StrategyGraph} and this would be the expected
+ * type to pass back out.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty#graph()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<Graph>> getVertexPropertyGraphStrategy(final StrategyContext<StrategyVertexProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty#label()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty#label()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<String>> getVertexPropertyLabelStrategy(final StrategyContext<StrategyVertexProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty#keys()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty#keys()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<Set<String>>> getVertexPropertyKeysStrategy(final StrategyContext<StrategyVertexProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.VertexProperty#element}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.VertexProperty#element} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<Vertex>> getVertexPropertyGetElementStrategy(final StrategyContext<StrategyVertexProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph#close()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Supplier} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Graph#close()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default UnaryOperator<Supplier<Void>> getGraphCloseStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph#V}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Graph#V} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default UnaryOperator<Function<Object[], GraphTraversal<Vertex, Vertex>>> getGraphVStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Function} that enhances the features of {@link com.tinkerpop.gremlin.structure.Graph#E}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Function} that accepts a {@link java.util.function.Function} with
+ * {@link com.tinkerpop.gremlin.structure.Graph#E} signature
+ * and returns an enhanced strategy {@link java.util.function.Function} with the same signature
+ */
+ public default UnaryOperator<Function<Object[], GraphTraversal<Edge, Edge>>> getGraphEStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Property#value()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Supplier} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Property#value()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<V>> getPropertyValueStrategy(final StrategyContext<StrategyProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+ /**
+ * Construct a {@link java.util.function.Supplier} that enhances the features of {@link com.tinkerpop.gremlin.structure.Property#key()}.
+ *
+ * @param ctx the context within which this strategy function is called
+ * @param composingStrategy the strategy that composed this strategy function
+ * @return a {@link java.util.function.Supplier} that accepts a {@link java.util.function.Supplier} with
+ * {@link com.tinkerpop.gremlin.structure.Property#key()} signature
+ * and returns an enhanced strategy {@link java.util.function.Supplier} with the same signature
+ */
+ public default <V> UnaryOperator<Supplier<String>> getPropertyKeyStrategy(final StrategyContext<StrategyProperty<V>> ctx, final GraphStrategy composingStrategy) {
+ return UnaryOperator.identity();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/IdStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/IdStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/IdStrategy.java
new file mode 100644
index 0000000..d47b086
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/IdStrategy.java
@@ -0,0 +1,275 @@
+/*
+ * 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.strategy;
+
+import com.tinkerpop.gremlin.process.T;
+import com.tinkerpop.gremlin.process.graph.traversal.GraphTraversal;
+import com.tinkerpop.gremlin.structure.Contains;
+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 com.tinkerpop.gremlin.structure.VertexProperty;
+import com.tinkerpop.gremlin.structure.util.ElementHelper;
+import com.tinkerpop.gremlin.structure.util.StringFactory;
+import com.tinkerpop.gremlin.util.function.TriFunction;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+
+/**
+ * A {@link GraphStrategy} implementation which enables mapper element IDs even for those graphs which don't
+ * otherwise support them.
+ * <p/>
+ * For those graphs which support vertex indices but not edge indices (or vice versa), the strategy can be configured
+ * to use mapper IDs only for vertices or only for edges. ID generation is also configurable via ID {@link Supplier}
+ * functions.
+ * <p/>
+ * If the {@link IdStrategy} is used in combination with a sequence of other strategies and when ID assignment
+ * is enabled for an element, calls to strategies following this one are not made. It is important to consider that
+ * aspect of its operation when doing strategy composition. Typically, the {@link IdStrategy} should be
+ * executed last in a sequence.
+ *
+ * @author Joshua Shinavier (http://fortytwo.net)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class IdStrategy implements GraphStrategy {
+
+ private final String idKey;
+
+ private final Supplier<?> edgeIdSupplier;
+ private final Supplier<?> vertexIdSupplier;
+
+ private final boolean supportsVertexId;
+ private final boolean supportsEdgeId;
+
+ /**
+ * Creates a new instance. Public instantiation should be handled through the {@link Builder}.
+ */
+ private IdStrategy(final String idKey, final Supplier<?> vertexIdSupplier,
+ final Supplier<?> edgeIdSupplier, final boolean supportsVertexId,
+ final boolean supportsEdgeId) {
+ this.idKey = idKey;
+ this.edgeIdSupplier = edgeIdSupplier;
+ this.vertexIdSupplier = vertexIdSupplier;
+ this.supportsEdgeId = supportsEdgeId;
+ this.supportsVertexId = supportsVertexId;
+ }
+
+ @Override
+ public UnaryOperator<Function<Object[], Vertex>> getAddVertexStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return (f) -> (keyValues) -> {
+ throwIfIdKeyIsSet(Vertex.class, ElementHelper.getKeys(keyValues));
+ return f.apply(this.injectId(supportsVertexId, keyValues, vertexIdSupplier).toArray());
+ };
+ }
+
+ @Override
+ public UnaryOperator<TriFunction<String, Vertex, Object[], Edge>> getAddEdgeStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return (f) -> (label, v, keyValues) -> {
+ throwIfIdKeyIsSet(Edge.class, ElementHelper.getKeys(keyValues));
+ return f.apply(label, v, this.injectId(supportsEdgeId, keyValues, edgeIdSupplier).toArray());
+ };
+ }
+
+ @Override
+ public UnaryOperator<Function<Object[], Iterator<Edge>>> getGraphIteratorsEdgeIteratorStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return supportsVertexId ? (f) -> (ids) -> ctx.getStrategyGraph().getBaseGraph().E().has(idKey, Contains.within, Arrays.asList(ids)) : UnaryOperator.identity();
+ }
+
+ @Override
+ public UnaryOperator<Function<Object[], Iterator<Vertex>>> getGraphIteratorsVertexIteratorStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return supportsVertexId ? (f) -> (ids) -> ctx.getStrategyGraph().getBaseGraph().V().has(idKey, Contains.within, Arrays.asList(ids)) : UnaryOperator.identity();
+ }
+
+ @Override
+ public UnaryOperator<Function<Object[], GraphTraversal<Edge, Edge>>> getGraphEStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return supportsEdgeId ? (f) -> (ids) -> ctx.getStrategyGraph().getBaseGraph().E().has(idKey, Contains.within, Arrays.asList(ids)) : UnaryOperator.identity();
+ }
+
+ @Override
+ public UnaryOperator<Function<Object[], GraphTraversal<Vertex, Vertex>>> getGraphVStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+ return supportsVertexId ? (f) -> (ids) -> ctx.getStrategyGraph().getBaseGraph().V().has(idKey, Contains.within, Arrays.asList(ids)) : UnaryOperator.identity();
+ }
+
+ @Override
+ public UnaryOperator<Supplier<Object>> getVertexIdStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return supportsVertexId ? (f) -> () -> ctx.getCurrent().getBaseVertex().value(idKey) : UnaryOperator.identity();
+ }
+
+ @Override
+ public UnaryOperator<Supplier<Object>> getEdgeIdStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return supportsEdgeId ? (f) -> () -> ctx.getCurrent().getBaseEdge().value(idKey) : UnaryOperator.identity();
+ }
+
+ @Override
+ public <V> UnaryOperator<BiFunction<String, V, VertexProperty<V>>> getVertexPropertyStrategy(final StrategyContext<StrategyVertex> ctx, final GraphStrategy composingStrategy) {
+ return (f) -> (k, v) -> {
+ throwIfIdKeyIsSet(ctx.getCurrent().getClass(), k);
+ return f.apply(k, v);
+ };
+ }
+
+ @Override
+ public <V> UnaryOperator<BiFunction<String, V, Property<V>>> getEdgePropertyStrategy(final StrategyContext<StrategyEdge> ctx, final GraphStrategy composingStrategy) {
+ return (f) -> (k, v) -> {
+ throwIfIdKeyIsSet(ctx.getCurrent().getClass(), k);
+ return f.apply(k, v);
+ };
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.graphStrategyString(this);
+ }
+
+ private void throwIfIdKeyIsSet(final Class<? extends Element> element, final String k) {
+ if (supportsAnId(element) && this.idKey.equals(k))
+ throw new IllegalArgumentException(String.format("The key [%s] is protected by %s and cannot be set", idKey, IdStrategy.class.getSimpleName()));
+ }
+
+ private void throwIfIdKeyIsSet(final Class<? extends Element> element, final Set<String> keys) {
+ if (supportsAnId(element) && keys.contains(this.idKey))
+ throw new IllegalArgumentException(String.format("The key [%s] is protected by %s and cannot be set", idKey, IdStrategy.class.getSimpleName()));
+ }
+
+ private boolean supportsAnId(final Class<? extends Element> element) {
+ return ((Vertex.class.isAssignableFrom(element) && supportsVertexId) || (Edge.class.isAssignableFrom(element) && supportsEdgeId));
+ }
+
+ /**
+ * Gets the property name of the key used to lookup graph elements. Use this value to create an index in the underlying graph instance.
+ */
+ public String getIdKey() {
+ return this.idKey;
+ }
+
+ public boolean isSupportsVertexId() {
+ return supportsVertexId;
+ }
+
+ public boolean isSupportsEdgeId() {
+ return supportsEdgeId;
+ }
+
+ private List<Object> injectId(final boolean supports, final Object[] keyValues, final Supplier<?> idMaker) {
+ final List<Object> o = new ArrayList<>(Arrays.asList(keyValues));
+ if (supports) {
+ final Object val = ElementHelper.getIdValue(keyValues).orElse(idMaker.get());
+ final int pos = o.indexOf(T.id);
+ if (pos > -1) {
+ o.remove(pos);
+ o.remove(pos);
+ }
+
+ o.addAll(Arrays.asList(this.idKey, val));
+ }
+
+ return o;
+ }
+
+ /**
+ * Create the {@link Builder} to create a {@link IdStrategy}.
+ *
+ * @param idKey The key to use for the index to lookup graph elements.
+ */
+ public static Builder build(final String idKey) {
+ return new Builder(idKey);
+ }
+
+ public static final class Builder {
+ private final String idKey;
+ private Supplier<?> vertexIdSupplier;
+ private Supplier<?> edgeIdSupplier;
+ private boolean supportsVertexId;
+ private boolean supportsEdgeId;
+
+
+ private Builder(final String idKey) {
+ this.idKey = idKey;
+ this.edgeIdSupplier = Builder::supplyStringId;
+ this.vertexIdSupplier = Builder::supplyStringId;
+ this.supportsEdgeId = true;
+ this.supportsVertexId = true;
+
+ }
+
+ public IdStrategy create() {
+ if (!this.supportsEdgeId && !this.supportsVertexId)
+ throw new IllegalStateException("Since supportsEdgeId and supportsVertexId are false, there is no need to use IdGraphStrategy");
+
+ return new IdStrategy(this.idKey, this.vertexIdSupplier, this.edgeIdSupplier,
+ this.supportsVertexId, this.supportsEdgeId);
+ }
+
+ /**
+ * Provide a function that will provide ids when none are provided explicitly when creating vertices. By default
+ * a UUID string will be used if this value is not set.
+ */
+ public Builder vertexIdMaker(final Supplier<?> vertexIdSupplier) {
+ if (null == vertexIdSupplier)
+ throw new IllegalArgumentException("vertexIdSupplier");
+
+ this.vertexIdSupplier = vertexIdSupplier;
+ return this;
+ }
+
+ /**
+ * Provide a function that will provide ids when none are provided explicitly when creating edges. By default
+ * a UUID string will be used if this value is not set.
+ */
+ public Builder edgeIdMaker(final Supplier<?> edgeIdSupplier) {
+ if (null == edgeIdSupplier)
+ throw new IllegalArgumentException("edgeIdSupplier");
+
+ this.edgeIdSupplier = edgeIdSupplier;
+ return this;
+ }
+
+ /**
+ * Turn off support for this strategy for edges. Note that this value cannot be false if
+ * {@link #supportsVertexId(boolean)} is also false.
+ */
+ public Builder supportsEdgeId(final boolean supports) {
+ this.supportsEdgeId = supports;
+ return this;
+ }
+
+ /**
+ * Turn off support for this strategy for edges. Note that this value cannot be false if
+ * {@link #supportsEdgeId(boolean)} is also false.
+ */
+ public Builder supportsVertexId(final boolean supports) {
+ this.supportsVertexId = supports;
+ return this;
+ }
+
+ private static String supplyStringId() {
+ return UUID.randomUUID().toString();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/IdentityStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/IdentityStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/IdentityStrategy.java
new file mode 100644
index 0000000..f1a0f5a
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/IdentityStrategy.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.structure.strategy;
+
+import com.tinkerpop.gremlin.structure.util.StringFactory;
+
+/**
+ * A pass through implementation of {@link GraphStrategy} where all strategy functions are simply executed as
+ * they were originally implemented.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class IdentityStrategy implements GraphStrategy {
+ private static final IdentityStrategy instance = new IdentityStrategy();
+
+ private IdentityStrategy() {
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.graphStrategyString(this);
+ }
+
+ public static final IdentityStrategy instance() {
+ return instance;
+ }
+}