TINKERPOP-1901 Add interfaces for tokens in Gremlin.Net These interfaces simply represent their Java counterparts which allows to use them as arguments in Gremlin steps.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d012171e Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d012171e Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d012171e Branch: refs/heads/TINKERPOP-1897 Commit: d012171e97d5d87108eef3d0257a8b859f77de04 Parents: dcf3da3 Author: Florian Hockmann <f...@florian-hockmann.de> Authored: Sat Mar 10 19:21:46 2018 +0100 Committer: Florian Hockmann <f...@florian-hockmann.de> Committed: Sat Mar 10 19:21:46 2018 +0100 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + gremlin-dotnet/glv/Enum.template | 2 +- gremlin-dotnet/glv/generate.groovy | 20 ++++++--- .../Gremlin.Net/Process/Traversal/Barrier.cs | 2 +- .../src/Gremlin.Net/Process/Traversal/Column.cs | 2 +- .../Process/Traversal/GraphTraversal.cs | 45 ++++++++++++-------- .../Process/Traversal/GraphTraversalSource.cs | 14 ++++-- .../Process/Traversal/IBiFunction.cs | 33 ++++++++++++++ .../Process/Traversal/IBinaryOperator.cs | 34 +++++++++++++++ .../Process/Traversal/IComparator.cs | 32 ++++++++++++++ .../Gremlin.Net/Process/Traversal/IConsumer.cs | 33 ++++++++++++++ .../Gremlin.Net/Process/Traversal/IFunction.cs | 32 ++++++++++++++ .../Gremlin.Net/Process/Traversal/IPredicate.cs | 32 ++++++++++++++ .../Gremlin.Net/Process/Traversal/Operator.cs | 2 +- .../src/Gremlin.Net/Process/Traversal/Order.cs | 2 +- .../src/Gremlin.Net/Process/Traversal/T.cs | 2 +- .../Process/Traversal/TraversalPredicate.cs | 2 +- .../src/Gremlin.Net/Process/Traversal/__.cs | 28 ++++++------ 18 files changed, 270 insertions(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 341a392..568097c 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima [[release-3-2-8]] === TinkerPop 3.2.8 (Release Date: NOT OFFICIALLY RELEASED YET) +* Enums are now represented as classes in Gremlin.Net which allows to use them as arguments in more steps. * Bumped to Groovy 2.4.14. * Added `checkAdjacentVertices` option to `SubgraphStrategy`. * Modified `GremlinDslProcessor` so that it generated the `getAnonymousTraversalClass()` method to return the DSL version of `__`. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/glv/Enum.template ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/glv/Enum.template b/gremlin-dotnet/glv/Enum.template index fd09312..0be23c7 100644 --- a/gremlin-dotnet/glv/Enum.template +++ b/gremlin-dotnet/glv/Enum.template @@ -26,7 +26,7 @@ namespace Gremlin.Net.Process.Traversal { #pragma warning disable 1591 - public class <%= enumClass.simpleName %> : EnumWrapper + public class <%= enumClass.simpleName %> : <%= implementedTypes %> { private <%= enumClass.simpleName %>(string enumValue) : base("<%= enumClass.simpleName %>", enumValue) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/glv/generate.groovy ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy index 7894793..6d89b2f 100644 --- a/gremlin-dotnet/glv/generate.groovy +++ b/gremlin-dotnet/glv/generate.groovy @@ -48,17 +48,17 @@ def toCSharpTypeMap = ["Long": "long", "TraversalMetrics": "E2", "Traversal": "ITraversal", "Traversal[]": "ITraversal[]", - "Predicate": "TraversalPredicate", + "Predicate": "IPredicate", "P": "TraversalPredicate", "TraversalStrategy": "ITraversalStrategy", "TraversalStrategy[]": "ITraversalStrategy[]", - "Function": "object", - "BiFunction": "object", + "Function": "IFunction", + "BiFunction": "IBiFunction", "UnaryOperator": "object", - "BinaryOperator": "object", - "Consumer": "object", + "BinaryOperator": "IBinaryOperator", + "Consumer": "IConsumer", "Supplier": "object", - "Comparator": "object", + "Comparator": "IComparator", "VertexProgram": "object"] def useE2 = ["E2", "E2"]; @@ -341,6 +341,14 @@ def toCSharpName = { enumClass, itemName -> def createEnum = { enumClass -> def b = ["enumClass": enumClass, + "implementedTypes": enumClass.getInterfaces(). + collect { it.getSimpleName() }. + findAll { toCSharpTypeMap.containsKey(it) }. + findAll { toCSharpTypeMap[it] != "object" }. + sort { a, b -> a <=> b }. + collect(["EnumWrapper"]) { typeName -> + return toCSharpTypeMap[typeName] + }.join(", "), "constants": enumClass.getEnumConstants(). sort { a, b -> a.name() <=> b.name() }. collect { value -> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs index 6c00f99..0ae4fa2 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs @@ -26,7 +26,7 @@ namespace Gremlin.Net.Process.Traversal { #pragma warning disable 1591 - public class Barrier : EnumWrapper + public class Barrier : EnumWrapper, IConsumer { private Barrier(string enumValue) : base("Barrier", enumValue) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs index 3daaa4d..9fa2039 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs @@ -26,7 +26,7 @@ namespace Gremlin.Net.Process.Traversal { #pragma warning disable 1591 - public class Column : EnumWrapper + public class Column : EnumWrapper, IFunction { private Column(string enumValue) : base("Column", enumValue) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs index d8e26ad..7100ea3 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -187,7 +187,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the barrier step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> Barrier (object barrierConsumer) + public GraphTraversal<S, E> Barrier (IConsumer barrierConsumer) { Bytecode.AddStep("barrier", barrierConsumer); return Wrap<S, E>(this); @@ -236,7 +236,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the branch step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E2> Branch<E2> (object function) + public GraphTraversal<S, E2> Branch<E2> (IFunction function) { Bytecode.AddStep("branch", function); return Wrap<S, E2>(this); @@ -263,7 +263,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the by step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> By (object comparator) + public GraphTraversal<S, E> By (IComparator comparator) { Bytecode.AddStep("by", comparator); return Wrap<S, E>(this); @@ -272,7 +272,16 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the by step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> By (object function, object comparator) + public GraphTraversal<S, E> By (IFunction function) + { + Bytecode.AddStep("by", function); + return Wrap<S, E>(this); + } + + /// <summary> + /// Adds the by step to this <see cref="GraphTraversal{SType, EType}" />. + /// </summary> + public GraphTraversal<S, E> By (IFunction function, IComparator comparator) { Bytecode.AddStep("by", function, comparator); return Wrap<S, E>(this); @@ -299,7 +308,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the by step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> By (string key, object comparator) + public GraphTraversal<S, E> By (string key, IComparator comparator) { Bytecode.AddStep("by", key, comparator); return Wrap<S, E>(this); @@ -326,7 +335,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the by step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> By (ITraversal traversal, object comparator) + public GraphTraversal<S, E> By (ITraversal traversal, IComparator comparator) { Bytecode.AddStep("by", traversal, comparator); return Wrap<S, E>(this); @@ -346,7 +355,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the choose step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E2> Choose<E2> (object choiceFunction) + public GraphTraversal<S, E2> Choose<E2> (IFunction choiceFunction) { Bytecode.AddStep("choose", choiceFunction); return Wrap<S, E2>(this); @@ -355,7 +364,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the choose step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E2> Choose<E2> (TraversalPredicate choosePredicate, ITraversal trueChoice) + public GraphTraversal<S, E2> Choose<E2> (IPredicate choosePredicate, ITraversal trueChoice) { Bytecode.AddStep("choose", choosePredicate, trueChoice); return Wrap<S, E2>(this); @@ -364,7 +373,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the choose step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E2> Choose<E2> (TraversalPredicate choosePredicate, ITraversal trueChoice, ITraversal falseChoice) + public GraphTraversal<S, E2> Choose<E2> (IPredicate choosePredicate, ITraversal trueChoice, ITraversal falseChoice) { Bytecode.AddStep("choose", choosePredicate, trueChoice, falseChoice); return Wrap<S, E2>(this); @@ -496,7 +505,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the emit step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> Emit (TraversalPredicate emitPredicate) + public GraphTraversal<S, E> Emit (IPredicate emitPredicate) { Bytecode.AddStep("emit", emitPredicate); return Wrap<S, E>(this); @@ -514,7 +523,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the filter step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> Filter (TraversalPredicate predicate) + public GraphTraversal<S, E> Filter (IPredicate predicate) { Bytecode.AddStep("filter", predicate); return Wrap<S, E>(this); @@ -532,7 +541,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the flatMap step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E2> FlatMap<E2> (object function) + public GraphTraversal<S, E2> FlatMap<E2> (IFunction function) { Bytecode.AddStep("flatMap", function); return Wrap<S, E2>(this); @@ -559,7 +568,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the fold step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E2> Fold<E2> (E2 seed, object foldFunction) + public GraphTraversal<S, E2> Fold<E2> (E2 seed, IBiFunction foldFunction) { Bytecode.AddStep("fold", seed, foldFunction); return Wrap<S, E2>(this); @@ -942,7 +951,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the map step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E2> Map<E2> (object function) + public GraphTraversal<S, E2> Map<E2> (IFunction function) { Bytecode.AddStep("map", function); return Wrap<S, E2>(this); @@ -1302,7 +1311,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the sack step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> Sack (object sackOperator) + public GraphTraversal<S, E> Sack (IBiFunction sackOperator) { Bytecode.AddStep("sack", sackOperator); return Wrap<S, E>(this); @@ -1311,7 +1320,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the sack step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> Sack (object sackOperator, string elementPropertyKey) + public GraphTraversal<S, E> Sack (IBiFunction sackOperator, string elementPropertyKey) { Bytecode.AddStep("sack", sackOperator, elementPropertyKey); return Wrap<S, E>(this); @@ -1387,7 +1396,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the sideEffect step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> SideEffect (object consumer) + public GraphTraversal<S, E> SideEffect (IConsumer consumer) { Bytecode.AddStep("sideEffect", consumer); return Wrap<S, E>(this); @@ -1591,7 +1600,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Adds the until step to this <see cref="GraphTraversal{SType, EType}" />. /// </summary> - public GraphTraversal<S, E> Until (TraversalPredicate untilPredicate) + public GraphTraversal<S, E> Until (IPredicate untilPredicate) { Bytecode.AddStep("until", untilPredicate); return Wrap<S, E>(this); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs index 2cbe4de..9c32559 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs @@ -96,7 +96,7 @@ namespace Gremlin.Net.Process.Traversal return source; } - public GraphTraversalSource WithSack(object initialValue, object mergeOperator) + public GraphTraversalSource WithSack(object initialValue, IBinaryOperator mergeOperator) { var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), new Bytecode(Bytecode)); @@ -104,7 +104,15 @@ namespace Gremlin.Net.Process.Traversal return source; } - public GraphTraversalSource WithSack(object initialValue, object splitOperator, object mergeOperator) + public GraphTraversalSource WithSack(object initialValue, object splitOperator) + { + var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withSack", initialValue, splitOperator); + return source; + } + + public GraphTraversalSource WithSack(object initialValue, object splitOperator, IBinaryOperator mergeOperator) { var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), new Bytecode(Bytecode)); @@ -120,7 +128,7 @@ namespace Gremlin.Net.Process.Traversal return source; } - public GraphTraversalSource WithSideEffect(string key, object initialValue, object reducer) + public GraphTraversalSource WithSideEffect(string key, object initialValue, IBinaryOperator reducer) { var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), new Bytecode(Bytecode)); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBiFunction.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBiFunction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBiFunction.cs new file mode 100644 index 0000000..15c9f91 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBiFunction.cs @@ -0,0 +1,33 @@ +#region License + +/* + * 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. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// Represents a function that accepts two arguments and produces a result. This is the two-arity specialization of + /// <see cref="IFunction"/>. + /// </summary> + public interface IBiFunction + { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBinaryOperator.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBinaryOperator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBinaryOperator.cs new file mode 100644 index 0000000..dcd7aed --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IBinaryOperator.cs @@ -0,0 +1,34 @@ +#region License + +/* + * 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. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// Represents an operation upon two operands of the same type, producing a result of the same type as the operands. + /// This is a specialization of <see cref="IBiFunction" /> for the case where the operands and the result are all of + /// the same type. + /// </summary> + public interface IBinaryOperator : IBiFunction + { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IComparator.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IComparator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IComparator.cs new file mode 100644 index 0000000..b7a48e0 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IComparator.cs @@ -0,0 +1,32 @@ +#region License + +/* + * 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. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// A comparison function, which imposes a total ordering on some collection of objects. + /// </summary> + public interface IComparator + { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IConsumer.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IConsumer.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IConsumer.cs new file mode 100644 index 0000000..7eed5e2 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IConsumer.cs @@ -0,0 +1,33 @@ +#region License + +/* + * 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. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// Represents an operation that accepts a single input argument and returns no result. Unlike most other functional + /// interfaces, Consumer is expected to operate via side-effects. + /// </summary> + public interface IConsumer + { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IFunction.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IFunction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IFunction.cs new file mode 100644 index 0000000..075154a --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IFunction.cs @@ -0,0 +1,32 @@ +#region License + +/* + * 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. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// Represents a function that accepts one argument and produces a result. + /// </summary> + public interface IFunction + { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IPredicate.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IPredicate.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IPredicate.cs new file mode 100644 index 0000000..a7e5e3d --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IPredicate.cs @@ -0,0 +1,32 @@ +#region License + +/* + * 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. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// Represents a predicate (boolean-valued function) of one argument. + /// </summary> + public interface IPredicate + { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs index 699a5a5..4116197 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs @@ -26,7 +26,7 @@ namespace Gremlin.Net.Process.Traversal { #pragma warning disable 1591 - public class Operator : EnumWrapper + public class Operator : EnumWrapper, IBinaryOperator { private Operator(string enumValue) : base("Operator", enumValue) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs index 93bf7bc..d20906a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs @@ -26,7 +26,7 @@ namespace Gremlin.Net.Process.Traversal { #pragma warning disable 1591 - public class Order : EnumWrapper + public class Order : EnumWrapper, IComparator { private Order(string enumValue) : base("Order", enumValue) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs index 9eba458..c0e5927 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs @@ -26,7 +26,7 @@ namespace Gremlin.Net.Process.Traversal { #pragma warning disable 1591 - public class T : EnumWrapper + public class T : EnumWrapper, IFunction { private T(string enumValue) : base("T", enumValue) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs index b854213..e8b5be8 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs @@ -26,7 +26,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Represents a predicate (boolean-valued function) used in a <see cref="ITraversal" />. /// </summary> - public class TraversalPredicate + public class TraversalPredicate : IPredicate { /// <summary> /// Initializes a new instance of the <see cref="TraversalPredicate" /> class. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d012171e/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs index 1788bad..9620e7f 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs @@ -153,7 +153,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the barrier step to that traversal. /// </summary> - public static GraphTraversal<object, object> Barrier(object barrierConsumer) + public static GraphTraversal<object, object> Barrier(IConsumer barrierConsumer) { return new GraphTraversal<object, object>().Barrier(barrierConsumer); } @@ -197,7 +197,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the branch step to that traversal. /// </summary> - public static GraphTraversal<object, E2> Branch<E2>(object function) + public static GraphTraversal<object, E2> Branch<E2>(IFunction function) { return new GraphTraversal<object, E2>().Branch<E2>(function); } @@ -223,7 +223,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the choose step to that traversal. /// </summary> - public static GraphTraversal<object, E2> Choose<E2>(object choiceFunction) + public static GraphTraversal<object, E2> Choose<E2>(IFunction choiceFunction) { return new GraphTraversal<object, E2>().Choose<E2>(choiceFunction); } @@ -231,7 +231,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the choose step to that traversal. /// </summary> - public static GraphTraversal<object, E2> Choose<E2>(TraversalPredicate choosePredicate, ITraversal trueChoice) + public static GraphTraversal<object, E2> Choose<E2>(IPredicate choosePredicate, ITraversal trueChoice) { return new GraphTraversal<object, E2>().Choose<E2>(choosePredicate, trueChoice); } @@ -239,7 +239,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the choose step to that traversal. /// </summary> - public static GraphTraversal<object, E2> Choose<E2>(TraversalPredicate choosePredicate, ITraversal trueChoice, ITraversal falseChoice) + public static GraphTraversal<object, E2> Choose<E2>(IPredicate choosePredicate, ITraversal trueChoice, ITraversal falseChoice) { return new GraphTraversal<object, E2>().Choose<E2>(choosePredicate, trueChoice, falseChoice); } @@ -357,7 +357,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the emit step to that traversal. /// </summary> - public static GraphTraversal<object, object> Emit(TraversalPredicate emitPredicate) + public static GraphTraversal<object, object> Emit(IPredicate emitPredicate) { return new GraphTraversal<object, object>().Emit(emitPredicate); } @@ -373,7 +373,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the filter step to that traversal. /// </summary> - public static GraphTraversal<object, object> Filter(TraversalPredicate predicate) + public static GraphTraversal<object, object> Filter(IPredicate predicate) { return new GraphTraversal<object, object>().Filter(predicate); } @@ -389,7 +389,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the flatMap step to that traversal. /// </summary> - public static GraphTraversal<object, E2> FlatMap<E2>(object function) + public static GraphTraversal<object, E2> FlatMap<E2>(IFunction function) { return new GraphTraversal<object, E2>().FlatMap<E2>(function); } @@ -413,7 +413,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the fold step to that traversal. /// </summary> - public static GraphTraversal<object, E2> Fold<E2>(E2 seed, object foldFunction) + public static GraphTraversal<object, E2> Fold<E2>(E2 seed, IBiFunction foldFunction) { return new GraphTraversal<object, E2>().Fold<E2>(seed, foldFunction); } @@ -739,7 +739,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the map step to that traversal. /// </summary> - public static GraphTraversal<object, E2> Map<E2>(object function) + public static GraphTraversal<object, E2> Map<E2>(IFunction function) { return new GraphTraversal<object, E2>().Map<E2>(function); } @@ -997,7 +997,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the sack step to that traversal. /// </summary> - public static GraphTraversal<object, object> Sack(object sackOperator) + public static GraphTraversal<object, object> Sack(IBiFunction sackOperator) { return new GraphTraversal<object, object>().Sack(sackOperator); } @@ -1005,7 +1005,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the sack step to that traversal. /// </summary> - public static GraphTraversal<object, object> Sack(object sackOperator, string elementPropertyKey) + public static GraphTraversal<object, object> Sack(IBiFunction sackOperator, string elementPropertyKey) { return new GraphTraversal<object, object>().Sack(sackOperator, elementPropertyKey); } @@ -1073,7 +1073,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the sideEffect step to that traversal. /// </summary> - public static GraphTraversal<object, object> SideEffect(object consumer) + public static GraphTraversal<object, object> SideEffect(IConsumer consumer) { return new GraphTraversal<object, object>().SideEffect(consumer); } @@ -1239,7 +1239,7 @@ namespace Gremlin.Net.Process.Traversal /// <summary> /// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the until step to that traversal. /// </summary> - public static GraphTraversal<object, object> Until(TraversalPredicate untilPredicate) + public static GraphTraversal<object, object> Until(IPredicate untilPredicate) { return new GraphTraversal<object, object>().Until(untilPredicate); }