You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by fl...@apache.org on 2018/03/11 10:21:00 UTC
[1/2] tinkerpop git commit: TINKERPOP-1901 Transformed Gremlin.Net
enums into classes
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1901 [created] d012171e9
TINKERPOP-1901 Transformed Gremlin.Net enums into classes
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/dcf3da39
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/dcf3da39
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/dcf3da39
Branch: refs/heads/TINKERPOP-1901
Commit: dcf3da3917a9626d432ef26089bb05c6a15158ed
Parents: ab66ed3
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sat Mar 10 19:17:15 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Sat Mar 10 19:17:15 2018 +0100
----------------------------------------------------------------------
docs/src/reference/gremlin-variants.asciidoc | 2 +-
gremlin-dotnet/glv/Enum.template | 7 +-
gremlin-dotnet/glv/generate.groovy | 21 +----
.../Gremlin.Net/Process/Traversal/Barrier.cs | 9 +-
.../Process/Traversal/Cardinality.cs | 13 ++-
.../src/Gremlin.Net/Process/Traversal/Column.cs | 11 ++-
.../Gremlin.Net/Process/Traversal/Direction.cs | 13 ++-
.../Process/Traversal/EnumWrapper.cs | 52 +++++++++++
.../Process/Traversal/GraphSONVersion.cs | 11 ++-
.../Process/Traversal/GryoVersion.cs | 9 +-
.../Process/Traversal/NamingConversions.cs | 91 --------------------
.../Gremlin.Net/Process/Traversal/Operator.cs | 29 ++++---
.../src/Gremlin.Net/Process/Traversal/Order.cs | 21 +++--
.../src/Gremlin.Net/Process/Traversal/Pick.cs | 11 ++-
.../src/Gremlin.Net/Process/Traversal/Pop.cs | 13 ++-
.../src/Gremlin.Net/Process/Traversal/Scope.cs | 11 ++-
.../src/Gremlin.Net/Process/Traversal/T.cs | 15 ++--
.../Structure/IO/GraphSON/EnumSerializer.cs | 5 +-
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../TraversalEnumParameter.cs | 5 +-
20 files changed, 181 insertions(+), 170 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index f06fe02..ace8119 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -362,7 +362,7 @@ terminal/action methods off of `ITraversal`.
=== Static Enums and Methods
-Gremlin has various tokens (e.g. `T`, `P`, `Order`, `Operator`, etc.) that are represented in Gremlin.Net as Enums.
+Gremlin has various tokens (e.g. `T`, `P`, `Order`, `Operator`, etc.) that are represented in Gremlin.Net as classes.
These can be used analogously to how they are used in Gremlin-Java.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/glv/Enum.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/Enum.template b/gremlin-dotnet/glv/Enum.template
index 1fddab1..fd09312 100644
--- a/gremlin-dotnet/glv/Enum.template
+++ b/gremlin-dotnet/glv/Enum.template
@@ -26,8 +26,13 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum <%= enumClass.simpleName %>
+ public class <%= enumClass.simpleName %> : EnumWrapper
{
+ private <%= enumClass.simpleName %>(string enumValue)
+ : base("<%= enumClass.simpleName %>", enumValue)
+ {
+ }
+
<%= constants %>
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 12cfa88..7894793 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -339,36 +339,23 @@ def toCSharpName = { enumClass, itemName ->
return itemName.substring(0, 1).toUpperCase() + itemName.substring(1)
}
-def createEnum = { enumClass, csharpToJava ->
+def createEnum = { enumClass ->
def b = ["enumClass": enumClass,
"constants": enumClass.getEnumConstants().
sort { a, b -> a.name() <=> b.name() }.
collect { value ->
def csharpName = toCSharpName(enumClass, value.name())
- csharpToJava.put(enumClass.simpleName + "." + csharpName, value.name())
- return csharpName
- }.join(",\n\t\t")]
+ return "public static ${enumClass.simpleName} ${csharpName} => new ${enumClass.simpleName}(\"${value.name()}\");"
+ }.join("\n\t\t")]
def enumTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/Enum.template")).make(b)
def enumFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/" + enumClass.getSimpleName() + ".cs")
enumFile.newWriter().withWriter{ it << enumTemplate }
}
-def enumCSharpToJavaNames = [:]
CoreImports.getClassImports().findAll { Enum.class.isAssignableFrom(it) }.
sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }.
- each { createEnum(it, enumCSharpToJavaNames) }
-
-def lastIndex = (enumCSharpToJavaNames.size() - 1);
-def body = new StringBuilder()
-enumCSharpToJavaNames.eachWithIndex{ node, i ->
- body.append("""{"$node.key", "$node.value"}""")
- body.append(i == lastIndex ? "\n" : ",\n ")
-}
-
-def namingConversionsTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/NamingConversions.template")).make(["body":body])
-def namingConversionsFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/NamingConversions.cs")
-namingConversionsFile.newWriter().withWriter{ it << namingConversionsTemplate }
+ each { createEnum(it) }
def determineVersion = {
def env = System.getenv()
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/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 555d372..6c00f99 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs
@@ -26,9 +26,14 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Barrier
+ public class Barrier : EnumWrapper
{
- NormSack
+ private Barrier(string enumValue)
+ : base("Barrier", enumValue)
+ {
+ }
+
+ public static Barrier NormSack => new Barrier("normSack");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
index 5a07258..f158153 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
@@ -26,11 +26,16 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Cardinality
+ public class Cardinality : EnumWrapper
{
- List,
- Set,
- Single
+ private Cardinality(string enumValue)
+ : base("Cardinality", enumValue)
+ {
+ }
+
+ public static Cardinality List => new Cardinality("list");
+ public static Cardinality Set => new Cardinality("set");
+ public static Cardinality Single => new Cardinality("single");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/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 432323f..3daaa4d 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs
@@ -26,10 +26,15 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Column
+ public class Column : EnumWrapper
{
- Keys,
- Values
+ private Column(string enumValue)
+ : base("Column", enumValue)
+ {
+ }
+
+ public static Column Keys => new Column("keys");
+ public static Column Values => new Column("values");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
index 6f19748..9566d51 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
@@ -26,11 +26,16 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Direction
+ public class Direction : EnumWrapper
{
- Both,
- In,
- Out
+ private Direction(string enumValue)
+ : base("Direction", enumValue)
+ {
+ }
+
+ public static Direction Both => new Direction("BOTH");
+ public static Direction In => new Direction("IN");
+ public static Direction Out => new Direction("OUT");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/EnumWrapper.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/EnumWrapper.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/EnumWrapper.cs
new file mode 100644
index 0000000..66b8c5a
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/EnumWrapper.cs
@@ -0,0 +1,52 @@
+#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 enum.
+ /// </summary>
+ public abstract class EnumWrapper
+ {
+ /// <summary>
+ /// Gets the name of the enum.
+ /// </summary>
+ public string EnumName { get; }
+
+ /// <summary>
+ /// Gets the value of the enum.
+ /// </summary>
+ public string EnumValue { get; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EnumWrapper" /> class.
+ /// </summary>
+ /// <param name="enumName">The name of the enum.</param>
+ /// <param name="enumValue">The value of the enum.</param>
+ protected EnumWrapper(string enumName, string enumValue)
+ {
+ EnumName = enumName;
+ EnumValue = enumValue;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
index e978bc6..ad73ad1 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
@@ -26,10 +26,15 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum GraphSONVersion
+ public class GraphSONVersion : EnumWrapper
{
- V1_0,
- V2_0
+ private GraphSONVersion(string enumValue)
+ : base("GraphSONVersion", enumValue)
+ {
+ }
+
+ public static GraphSONVersion V1_0 => new GraphSONVersion("V1_0");
+ public static GraphSONVersion V2_0 => new GraphSONVersion("V2_0");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
index 5ee7358..45387e2 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
@@ -26,9 +26,14 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum GryoVersion
+ public class GryoVersion : EnumWrapper
{
- V1_0
+ private GryoVersion(string enumValue)
+ : base("GryoVersion", enumValue)
+ {
+ }
+
+ public static GryoVersion V1_0 => new GryoVersion("V1_0");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs
deleted file mode 100644
index aecdc57..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/NamingConversions.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-#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
-
-using System.Collections.Generic;
-
-// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
-namespace Gremlin.Net.Process.Traversal
-{
- internal static class NamingConversions
- {
- /// <summary>
- /// Gets the Java name equivalent for a given enum value
- /// </summary>
- internal static string GetEnumJavaName(string typeName, string value)
- {
- var key = $"{typeName}.{value}";
- string javaName;
- if (!CSharpToJavaEnums.TryGetValue(key, out javaName))
- {
- throw new KeyNotFoundException($"Java name for {key} not found");
- }
- return javaName;
- }
-
- internal static readonly IDictionary<string, string> CSharpToJavaEnums = new Dictionary<string, string>
- {
- {"Barrier.NormSack", "normSack"},
- {"Cardinality.List", "list"},
- {"Cardinality.Set", "set"},
- {"Cardinality.Single", "single"},
- {"Column.Keys", "keys"},
- {"Column.Values", "values"},
- {"Direction.Both", "BOTH"},
- {"Direction.In", "IN"},
- {"Direction.Out", "OUT"},
- {"GraphSONVersion.V1_0", "V1_0"},
- {"GraphSONVersion.V2_0", "V2_0"},
- {"GryoVersion.V1_0", "V1_0"},
- {"Operator.AddAll", "addAll"},
- {"Operator.And", "and"},
- {"Operator.Assign", "assign"},
- {"Operator.Div", "div"},
- {"Operator.Max", "max"},
- {"Operator.Min", "min"},
- {"Operator.Minus", "minus"},
- {"Operator.Mult", "mult"},
- {"Operator.Or", "or"},
- {"Operator.Sum", "sum"},
- {"Operator.SumLong", "sumLong"},
- {"Order.Decr", "decr"},
- {"Order.Incr", "incr"},
- {"Order.KeyDecr", "keyDecr"},
- {"Order.KeyIncr", "keyIncr"},
- {"Order.Shuffle", "shuffle"},
- {"Order.ValueDecr", "valueDecr"},
- {"Order.ValueIncr", "valueIncr"},
- {"Pick.Any", "any"},
- {"Pick.None", "none"},
- {"Pop.All", "all"},
- {"Pop.First", "first"},
- {"Pop.Last", "last"},
- {"Scope.Global", "global"},
- {"Scope.Local", "local"},
- {"T.Id", "id"},
- {"T.Key", "key"},
- {"T.Label", "label"},
- {"T.Value", "value"}
-
- };
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/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 72b0048..699a5a5 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs
@@ -26,19 +26,24 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Operator
+ public class Operator : EnumWrapper
{
- AddAll,
- And,
- Assign,
- Div,
- Max,
- Min,
- Minus,
- Mult,
- Or,
- Sum,
- SumLong
+ private Operator(string enumValue)
+ : base("Operator", enumValue)
+ {
+ }
+
+ public static Operator AddAll => new Operator("addAll");
+ public static Operator And => new Operator("and");
+ public static Operator Assign => new Operator("assign");
+ public static Operator Div => new Operator("div");
+ public static Operator Max => new Operator("max");
+ public static Operator Min => new Operator("min");
+ public static Operator Minus => new Operator("minus");
+ public static Operator Mult => new Operator("mult");
+ public static Operator Or => new Operator("or");
+ public static Operator Sum => new Operator("sum");
+ public static Operator SumLong => new Operator("sumLong");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/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 1f12710..93bf7bc 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs
@@ -26,15 +26,20 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Order
+ public class Order : EnumWrapper
{
- Decr,
- Incr,
- KeyDecr,
- KeyIncr,
- Shuffle,
- ValueDecr,
- ValueIncr
+ private Order(string enumValue)
+ : base("Order", enumValue)
+ {
+ }
+
+ public static Order Decr => new Order("decr");
+ public static Order Incr => new Order("incr");
+ public static Order KeyDecr => new Order("keyDecr");
+ public static Order KeyIncr => new Order("keyIncr");
+ public static Order Shuffle => new Order("shuffle");
+ public static Order ValueDecr => new Order("valueDecr");
+ public static Order ValueIncr => new Order("valueIncr");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
index e6394ae..a47d4a6 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
@@ -26,10 +26,15 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Pick
+ public class Pick : EnumWrapper
{
- Any,
- None
+ private Pick(string enumValue)
+ : base("Pick", enumValue)
+ {
+ }
+
+ public static Pick Any => new Pick("any");
+ public static Pick None => new Pick("none");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
index a7a8403..9e97a09 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
@@ -26,11 +26,16 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Pop
+ public class Pop : EnumWrapper
{
- All,
- First,
- Last
+ private Pop(string enumValue)
+ : base("Pop", enumValue)
+ {
+ }
+
+ public static Pop All => new Pop("all");
+ public static Pop First => new Pop("first");
+ public static Pop Last => new Pop("last");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
index d5af93a..65a6e67 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
@@ -26,10 +26,15 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum Scope
+ public class Scope : EnumWrapper
{
- Global,
- Local
+ private Scope(string enumValue)
+ : base("Scope", enumValue)
+ {
+ }
+
+ public static Scope Global => new Scope("global");
+ public static Scope Local => new Scope("local");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/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 c21b50a..9eba458 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs
@@ -26,12 +26,17 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- public enum T
+ public class T : EnumWrapper
{
- Id,
- Key,
- Label,
- Value
+ private T(string enumValue)
+ : base("T", enumValue)
+ {
+ }
+
+ public static T Id => new T("id");
+ public static T Key => new T("key");
+ public static T Label => new T("label");
+ public static T Value => new T("value");
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs
index b4ab870..ccea7cd 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/EnumSerializer.cs
@@ -30,9 +30,8 @@ namespace Gremlin.Net.Structure.IO.GraphSON
{
public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer)
{
- var enumName = objectData.GetType().Name;
- var valueJavaName = NamingConversions.GetEnumJavaName(enumName, objectData.ToString());
- return GraphSONUtil.ToTypedValue(enumName, valueJavaName);
+ EnumWrapper enumToSerialize = objectData;
+ return GraphSONUtil.ToTypedValue(enumToSerialize.EnumName, enumToSerialize.EnumValue);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
index a60a558..d5b7acc 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -53,7 +53,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
{typeof(Guid), new UuidSerializer()},
{typeof(DateTimeOffset), new DateSerializer()},
{typeof(Type), new ClassSerializer()},
- {typeof(Enum), new EnumSerializer()},
+ {typeof(EnumWrapper), new EnumSerializer()},
{typeof(TraversalPredicate), new TraversalPredicateSerializer()},
{typeof(Vertex), new VertexSerializer()},
{typeof(Edge), new EdgeSerializer()},
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dcf3da39/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEnumParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEnumParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEnumParameter.cs
index c305df7..9457cae 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEnumParameter.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEnumParameter.cs
@@ -26,7 +26,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Gremlin.Net.Process.Traversal;
-using TEnum = Gremlin.Net.Process.Traversal.T;
namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
{
@@ -38,7 +37,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
private readonly string _text;
private static readonly IDictionary<string, Type> EnumTypesByName = typeof(Scope).GetTypeInfo().Assembly
- .GetTypes().Where(t => t.GetTypeInfo().IsEnum && t.GetTypeInfo().IsPublic)
+ .GetTypes().Where(t => t.GetTypeInfo().IsSubclassOf(typeof(EnumWrapper)) && t.GetTypeInfo().IsPublic)
.ToDictionary(e => e.Name, e => e);
private readonly object _value;
@@ -55,7 +54,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
}
_type = type;
var valueName = text.Substring(separatorIndex + 1);
- _value = Enum.Parse(type, GetCsharpName(valueName));
+ _value = _type.GetProperty(GetCsharpName(valueName)).GetValue(null);
}
private string GetCsharpName(string valueText)
[2/2] tinkerpop git commit: TINKERPOP-1901 Add interfaces for tokens
in Gremlin.Net
Posted by fl...@apache.org.
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-1901
Commit: d012171e97d5d87108eef3d0257a8b859f77de04
Parents: dcf3da3
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Sat Mar 10 19:21:46 2018 +0100
Committer: Florian Hockmann <fh...@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);
}