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/13 22:39:46 UTC
[1/8] tinkerpop git commit: TINKERPOP-1901 Transformed Gremlin.Net
enums into classes [Forced Update!]
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1919 97c179d29 -> 5cf1cba59 (forced update)
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-1919
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)
[8/8] tinkerpop git commit: TINKERPOP-1919 Add note about merged P
classes to upgrade docs
Posted by fl...@apache.org.
TINKERPOP-1919 Add note about merged P classes to upgrade docs
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5cf1cba5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5cf1cba5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5cf1cba5
Branch: refs/heads/TINKERPOP-1919
Commit: 5cf1cba59cfb6818b371b1d605dac3b8d190157a
Parents: 359b08c
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 23:39:21 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 23:39:21 2018 +0100
----------------------------------------------------------------------
docs/src/upgrade/release-3.2.x-incubating.asciidoc | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5cf1cba5/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 0cb8ddc..0848843 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -53,6 +53,18 @@ However, usage of these tokens themselves shouldn't change at all (e.g. `T.Id` i
See: link:https://issues.apache.org/jira/browse/TINKERPOP-1901[TINKERPOP-1901]
+==== Gremlin.Net: Traversal Predicate Classes Merged
+
+Gremlin.Net used two classes for traversal predicates: `P` and `TraversalPredicate`. Steps that worked with traversal
+predicates expected objects of type `TraversalPredicate`, but they were constructed from the `P` class
+(e.g. `P.Gt(1)` returned a `TraversalPredicate`). Merging these two classes into the `P` class should avoid unnecessary
+confusion. Most users should not notice this change as predicates can still be constructed exactly as before, e.g.,
+`P.Gt(1).And(P.Lt(3))` still works without any modifications.
+Only users that implemented their own predicates and used `TraversalPredicate` as the base class need to change their
+implementation to now use `P` as the new base class.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1919[TINKERPOP-1919]
+
=== Upgrading for Providers
==== Graph System Providers
[7/8] tinkerpop git commit: TINKERPOP-1919 Merge classes P and
TraversalPredicate
Posted by fl...@apache.org.
TINKERPOP-1919 Merge classes P and TraversalPredicate
There is no good reason to keep those two classes separate anymore and
having P as the type for step parameters is probably easier to
understand for users than TraversalPredicate.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/359b08cc
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/359b08cc
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/359b08cc
Branch: refs/heads/TINKERPOP-1919
Commit: 359b08cc79ed89cab1fbc4e2b0b69b94a4e9cd06
Parents: 5049339
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Mon Mar 12 21:16:18 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 22:12:31 2018 +0100
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
gremlin-dotnet/glv/P.template | 62 ++++++++++-
gremlin-dotnet/glv/generate.groovy | 2 +-
.../Process/Traversal/GraphTraversal.cs | 20 ++--
.../src/Gremlin.Net/Process/Traversal/P.cs | 106 ++++++++++++++-----
.../Process/Traversal/TraversalPredicate.cs | 85 ---------------
.../src/Gremlin.Net/Process/Traversal/__.cs | 20 ++--
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../Structure/IO/GraphSON/PSerializer.cs | 45 ++++++++
.../IO/GraphSON/TraversalPredicateSerializer.cs | 45 --------
.../Gherkin/GherkinTestRunner.cs | 18 +---
.../Gherkin/IgnoreException.cs | 5 -
.../Gherkin/TraversalEvaluation/PParameter.cs | 97 +++++++++++++++++
.../TraversalEvaluationTests.cs | 2 +-
.../TraversalEvaluation/TraversalParser.cs | 2 +-
.../TraversalPredicateParameter.cs | 93 ----------------
.../GraphSON/BytecodeGraphSONSerializerTests.cs | 2 +-
.../IO/GraphSON/GraphSONWriterTests.cs | 4 +-
18 files changed, 311 insertions(+), 300 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 58c4dd0..97b90a5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -43,6 +43,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Fixed a bug in Gremlin Console which prevented handling of `gremlin.sh` flags that had an "=" between the flag and its arguments.
* Fixed bug where `SparkMessenger` was not applying the `edgeFunction` from `MessageScope`.
* Fixed a bug in `ComputerAwareStep` that didn't handle `reset()` properly and thus occasionally produced some extra traversers.
+* Removed `TraversalPredicate` class in Gremlin.Net. It is now included in the `P` class instead.
[[release-3-2-7]]
=== TinkerPop 3.2.7 (Release Date: December 17, 2017)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/glv/P.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template
index f337127..ad037c1 100644
--- a/gremlin-dotnet/glv/P.template
+++ b/gremlin-dotnet/glv/P.template
@@ -30,20 +30,72 @@ namespace Gremlin.Net.Process.Traversal
/// A <see cref="P" /> is a predicate of the form Func<object, bool>.
/// That is, given some object, return true or false.
/// </summary>
- public class P
+ public class P : IPredicate
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="P" /> class.
+ /// </summary>
+ /// <param name="operatorName">The name of the predicate.</param>
+ /// <param name="value">The value of the predicate.</param>
+ /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
+ public P(string operatorName, dynamic value, P other = null)
+ {
+ OperatorName = operatorName;
+ Value = value;
+ Other = other;
+ }
+
+ /// <summary>
+ /// Gets the name of the predicate.
+ /// </summary>
+ public string OperatorName { get; }
+
+ /// <summary>
+ /// Gets the value of the predicate.
+ /// </summary>
+ public dynamic Value { get; }
+
+ /// <summary>
+ /// Gets an optional other predicate that is used as an argument for this predicate.
+ /// </summary>
+ public P Other { get; }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical AND of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P And(P otherPredicate)
+ {
+ return new P("and", this, otherPredicate);
+ }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical OR of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P Or(P otherPredicate)
+ {
+ return new P("or", this, otherPredicate);
+ }
<% pmethods.findAll{ !(it in ["within", "without"]) }.each { method -> %>
- public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args)
+ public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("<%= method %>", value);
+ return new P("<%= method %>", value);
}
<% } %><% pmethods.findAll{ it in ["within", "without"] }.each { method -> %>
- public static TraversalPredicate <%= toCSharpMethodName.call(method) %>(params object[] args)
+ public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
{
- return new TraversalPredicate("<%= method %>", args);
+ return new P("<%= method %>", args);
}
<% } %>
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return Other == null ? \$"{OperatorName}({Value})" : \$"{OperatorName}({Value},{Other})";
+ }
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 0404307..5057ff8 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -49,7 +49,7 @@ def toCSharpTypeMap = ["Long": "long",
"Traversal": "ITraversal",
"Traversal[]": "ITraversal[]",
"Predicate": "IPredicate",
- "P": "TraversalPredicate",
+ "P": "P",
"TraversalStrategy": "ITraversalStrategy",
"TraversalStrategy[]": "ITraversalStrategy[]",
"Function": "IFunction",
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 7100ea3..c8708df 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -667,7 +667,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string propertyKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (string propertyKey, P predicate)
{
Bytecode.AddStep("has", propertyKey, predicate);
return Wrap<S, E>(this);
@@ -685,7 +685,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (string label, string propertyKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (string label, string propertyKey, P predicate)
{
Bytecode.AddStep("has", label, propertyKey, predicate);
return Wrap<S, E>(this);
@@ -712,7 +712,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the has step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Has (T accessor, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Has (T accessor, P predicate)
{
Bytecode.AddStep("has", accessor, predicate);
return Wrap<S, E>(this);
@@ -741,7 +741,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasId step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasId (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasId (P predicate)
{
Bytecode.AddStep("hasId", predicate);
return Wrap<S, E>(this);
@@ -750,7 +750,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasKey step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasKey (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasKey (P predicate)
{
Bytecode.AddStep("hasKey", predicate);
return Wrap<S, E>(this);
@@ -770,7 +770,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasLabel step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasLabel (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasLabel (P predicate)
{
Bytecode.AddStep("hasLabel", predicate);
return Wrap<S, E>(this);
@@ -810,7 +810,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the hasValue step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> HasValue (TraversalPredicate predicate)
+ public GraphTraversal<S, E> HasValue (P predicate)
{
Bytecode.AddStep("hasValue", predicate);
return Wrap<S, E>(this);
@@ -888,7 +888,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the is step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Is (TraversalPredicate predicate)
+ public GraphTraversal<S, E> Is (P predicate)
{
Bytecode.AddStep("is", predicate);
return Wrap<S, E>(this);
@@ -1660,7 +1660,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the where step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Where (TraversalPredicate predicate)
+ public GraphTraversal<S, E> Where (P predicate)
{
Bytecode.AddStep("where", predicate);
return Wrap<S, E>(this);
@@ -1669,7 +1669,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Adds the where step to this <see cref="GraphTraversal{SType, EType}" />.
/// </summary>
- public GraphTraversal<S, E> Where (string startKey, TraversalPredicate predicate)
+ public GraphTraversal<S, E> Where (string startKey, P predicate)
{
Bytecode.AddStep("where", startKey, predicate);
return Wrap<S, E>(this);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
index 0a7809f..e3a1e76 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
@@ -30,85 +30,137 @@ namespace Gremlin.Net.Process.Traversal
/// A <see cref="P" /> is a predicate of the form Func<object, bool>.
/// That is, given some object, return true or false.
/// </summary>
- public class P
+ public class P : IPredicate
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="P" /> class.
+ /// </summary>
+ /// <param name="operatorName">The name of the predicate.</param>
+ /// <param name="value">The value of the predicate.</param>
+ /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
+ public P(string operatorName, dynamic value, P other = null)
+ {
+ OperatorName = operatorName;
+ Value = value;
+ Other = other;
+ }
+
+ /// <summary>
+ /// Gets the name of the predicate.
+ /// </summary>
+ public string OperatorName { get; }
+
+ /// <summary>
+ /// Gets the value of the predicate.
+ /// </summary>
+ public dynamic Value { get; }
+
+ /// <summary>
+ /// Gets an optional other predicate that is used as an argument for this predicate.
+ /// </summary>
+ public P Other { get; }
+
+ /// <summary>
+ /// Returns a composed predicate that represents a logical AND of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P And(P otherPredicate)
+ {
+ return new P("and", this, otherPredicate);
+ }
- public static TraversalPredicate Between(params object[] args)
+ /// <summary>
+ /// Returns a composed predicate that represents a logical OR of this predicate and another.
+ /// </summary>
+ /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
+ /// <returns>The composed predicate.</returns>
+ public P Or(P otherPredicate)
+ {
+ return new P("or", this, otherPredicate);
+ }
+
+ public static P Between(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("between", value);
+ return new P("between", value);
}
- public static TraversalPredicate Eq(params object[] args)
+ public static P Eq(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("eq", value);
+ return new P("eq", value);
}
- public static TraversalPredicate Gt(params object[] args)
+ public static P Gt(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("gt", value);
+ return new P("gt", value);
}
- public static TraversalPredicate Gte(params object[] args)
+ public static P Gte(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("gte", value);
+ return new P("gte", value);
}
- public static TraversalPredicate Inside(params object[] args)
+ public static P Inside(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("inside", value);
+ return new P("inside", value);
}
- public static TraversalPredicate Lt(params object[] args)
+ public static P Lt(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("lt", value);
+ return new P("lt", value);
}
- public static TraversalPredicate Lte(params object[] args)
+ public static P Lte(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("lte", value);
+ return new P("lte", value);
}
- public static TraversalPredicate Neq(params object[] args)
+ public static P Neq(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("neq", value);
+ return new P("neq", value);
}
- public static TraversalPredicate Not(params object[] args)
+ public static P Not(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("not", value);
+ return new P("not", value);
}
- public static TraversalPredicate Outside(params object[] args)
+ public static P Outside(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("outside", value);
+ return new P("outside", value);
}
- public static TraversalPredicate Test(params object[] args)
+ public static P Test(params object[] args)
{
var value = args.Length == 1 ? args[0] : args;
- return new TraversalPredicate("test", value);
+ return new P("test", value);
}
- public static TraversalPredicate Within(params object[] args)
+ public static P Within(params object[] args)
{
- return new TraversalPredicate("within", args);
+ return new P("within", args);
}
- public static TraversalPredicate Without(params object[] args)
+ public static P Without(params object[] args)
{
- return new TraversalPredicate("without", args);
+ return new P("without", args);
}
+ /// <inheritdoc />
+ public override string ToString()
+ {
+ return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})";
+ }
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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
deleted file mode 100644
index e8b5be8..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/TraversalPredicate.cs
+++ /dev/null
@@ -1,85 +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
-
-namespace Gremlin.Net.Process.Traversal
-{
- /// <summary>
- /// Represents a predicate (boolean-valued function) used in a <see cref="ITraversal" />.
- /// </summary>
- public class TraversalPredicate : IPredicate
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="TraversalPredicate" /> class.
- /// </summary>
- /// <param name="operatorName">The name of the predicate.</param>
- /// <param name="value">The value of the predicate.</param>
- /// <param name="other">An optional other predicate that is used as an argument for this predicate.</param>
- public TraversalPredicate(string operatorName, dynamic value, TraversalPredicate other = null)
- {
- OperatorName = operatorName;
- Value = value;
- Other = other;
- }
-
- /// <summary>
- /// Gets the name of the predicate.
- /// </summary>
- public string OperatorName { get; }
-
- /// <summary>
- /// Gets the value of the predicate.
- /// </summary>
- public dynamic Value { get; }
-
- /// <summary>
- /// Gets an optional other predicate that is used as an argument for this predicate.
- /// </summary>
- public TraversalPredicate Other { get; }
-
- /// <summary>
- /// Returns a composed predicate that represents a logical AND of this predicate and another.
- /// </summary>
- /// <param name="otherPredicate">A predicate that will be logically-ANDed with this predicate.</param>
- /// <returns>The composed predicate.</returns>
- public TraversalPredicate And(TraversalPredicate otherPredicate)
- {
- return new TraversalPredicate("and", this, otherPredicate);
- }
-
- /// <summary>
- /// Returns a composed predicate that represents a logical OR of this predicate and another.
- /// </summary>
- /// <param name="otherPredicate">A predicate that will be logically-ORed with this predicate.</param>
- /// <returns>The composed predicate.</returns>
- public TraversalPredicate Or(TraversalPredicate otherPredicate)
- {
- return new TraversalPredicate("or", this, otherPredicate);
- }
-
- /// <inheritdoc />
- public override string ToString()
- {
- return Other == null ? $"{OperatorName}({Value})" : $"{OperatorName}({Value},{Other})";
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 9620e7f..46f510a 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
@@ -485,7 +485,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string propertyKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(string propertyKey, P predicate)
{
return new GraphTraversal<object, object>().Has(propertyKey, predicate);
}
@@ -501,7 +501,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(string label, string propertyKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(string label, string propertyKey, P predicate)
{
return new GraphTraversal<object, object>().Has(label, propertyKey, predicate);
}
@@ -525,7 +525,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the has step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Has(T accessor, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Has(T accessor, P predicate)
{
return new GraphTraversal<object, object>().Has(accessor, predicate);
}
@@ -551,7 +551,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasId step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasId(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasId(P predicate)
{
return new GraphTraversal<object, object>().HasId(predicate);
}
@@ -559,7 +559,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasKey step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasKey(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasKey(P predicate)
{
return new GraphTraversal<object, object>().HasKey(predicate);
}
@@ -577,7 +577,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasLabel step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasLabel(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasLabel(P predicate)
{
return new GraphTraversal<object, object>().HasLabel(predicate);
}
@@ -613,7 +613,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the hasValue step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> HasValue(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> HasValue(P predicate)
{
return new GraphTraversal<object, object>().HasValue(predicate);
}
@@ -683,7 +683,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the is step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Is(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Is(P predicate)
{
return new GraphTraversal<object, object>().Is(predicate);
}
@@ -1293,7 +1293,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the where step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Where(TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Where(P predicate)
{
return new GraphTraversal<object, object>().Where(predicate);
}
@@ -1301,7 +1301,7 @@ namespace Gremlin.Net.Process.Traversal
/// <summary>
/// Spawns a <see cref="GraphTraversal{SType, EType}" /> and adds the where step to that traversal.
/// </summary>
- public static GraphTraversal<object, object> Where(string startKey, TraversalPredicate predicate)
+ public static GraphTraversal<object, object> Where(string startKey, P predicate)
{
return new GraphTraversal<object, object>().Where(startKey, predicate);
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/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 d5b7acc..f23d80d 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -54,7 +54,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
{typeof(DateTimeOffset), new DateSerializer()},
{typeof(Type), new ClassSerializer()},
{typeof(EnumWrapper), new EnumSerializer()},
- {typeof(TraversalPredicate), new TraversalPredicateSerializer()},
+ {typeof(P), new PSerializer()},
{typeof(Vertex), new VertexSerializer()},
{typeof(Edge), new EdgeSerializer()},
{typeof(Property), new PropertySerializer()},
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
new file mode 100644
index 0000000..46facda
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/PSerializer.cs
@@ -0,0 +1,45 @@
+#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;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.Structure.IO.GraphSON
+{
+ internal class PSerializer : IGraphSONSerializer
+ {
+ public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer)
+ {
+ P p = predicate;
+ var value = p.Other == null
+ ? writer.ToDict(p.Value)
+ : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)};
+ var dict = new Dictionary<string, dynamic>
+ {
+ {"predicate", p.OperatorName},
+ {"value", value}
+ };
+ return GraphSONUtil.ToTypedValue("P", dict);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
deleted file mode 100644
index 937cb90..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/TraversalPredicateSerializer.cs
+++ /dev/null
@@ -1,45 +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;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Structure.IO.GraphSON
-{
- internal class TraversalPredicateSerializer : IGraphSONSerializer
- {
- public Dictionary<string, dynamic> Dictify(dynamic predicate, GraphSONWriter writer)
- {
- TraversalPredicate p = predicate;
- var value = p.Other == null
- ? writer.ToDict(p.Value)
- : new List<dynamic> {writer.ToDict(p.Value), writer.ToDict(p.Other)};
- var dict = new Dictionary<string, dynamic>
- {
- {"predicate", p.OperatorName},
- {"value", value}
- };
- return GraphSONUtil.ToTypedValue("P", dict);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
index d906357..c3819fe 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
@@ -43,23 +43,15 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_hasIdXwithinXemptyXX_count", IgnoreReason.PWithinWrapsArgumentsInArray},
{"g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX", IgnoreReason.PWithinWrapsArgumentsInArray},
{
- "g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
- },
- {
- "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
- },
- {
- "g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_whereXa_gtXbX_orXeqXbXXX_byXageX_byXweightX_byXweightX_selectXa_cX_byXnameX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
+ "g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX",
+ IgnoreReason.PNotDeserializationProblem
},
{
- "g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_inXcreatedX_asXdX_whereXa_ltXbX_orXgtXcXX_andXneqXdXXX_byXageX_byXweightX_byXinXcreatedX_valuesXageX_minX_selectXa_c_dX",
- IgnoreReason.PNotCreatedCorrectlyByGherkinRunner
+ "g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name",
+ IgnoreReason.PNotDeserializationProblem
},
{
- "g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX",
+ "g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX",
IgnoreReason.PNotDeserializationProblem
}
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
index dae2ced..fd226bf 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/IgnoreException.cs
@@ -43,10 +43,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
case IgnoreReason.LambdaNotSupported:
reasonSuffix = " because lambdas are not supported in Gremlin.NET (TINKERPOP-1854)";
break;
- case IgnoreReason.PNotCreatedCorrectlyByGherkinRunner:
- reasonSuffix =
- " because the Gherkin runner can't call methods in TraversalPredicate class (TINKERPOP-1919)";
- break;
case IgnoreReason.PWithinWrapsArgumentsInArray:
reasonSuffix = " because P.Within() arguments are incorrectly wrapped in an array (TINKERPOP-1920)";
break;
@@ -61,7 +57,6 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
public enum IgnoreReason
{
LambdaNotSupported,
- PNotCreatedCorrectlyByGherkinRunner,
PWithinWrapsArgumentsInArray,
PNotDeserializationProblem
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
new file mode 100644
index 0000000..b25faef
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/PParameter.cs
@@ -0,0 +1,97 @@
+#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;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Reflection;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
+{
+ /// <summary>
+ /// Represents a parameter for a traversal predicate (ie: P.gt())
+ /// </summary>
+ internal class PParameter : ITokenParameter, IEquatable<PParameter>
+ {
+ private IDictionary<string, object> _contextParameterValues;
+ public IList<Token> Tokens { get; }
+
+ public PParameter(IList<Token> tokens)
+ {
+ Tokens = tokens;
+ }
+
+ public bool Equals(PParameter other)
+ {
+ return Tokens.SequenceEqual(other.Tokens);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((PParameter) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Tokens != null ? Tokens.GetHashCode() : 0;
+ }
+
+ public object GetValue()
+ {
+ var type = typeof(P);
+ object instance = null;
+ for (var i = 1; i < Tokens.Count; i++)
+ {
+ var token = Tokens[i];
+ token.SetContextParameterValues(_contextParameterValues);
+ var method = type.GetMethod(TraversalParser.GetCsharpName(token.Name),
+ BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
+ if (method == null)
+ {
+ throw new InvalidOperationException($"Predicate (P) method '{token}' not found for testing");
+ }
+
+ var parameters = method.IsStatic
+ ? new object[] {token.Parameters.Select(p => p.GetValue()).ToArray()}
+ : token.Parameters.Select(p => p.GetValue()).ToArray();
+ instance = method.Invoke(instance, parameters);
+ }
+ return instance;
+ }
+
+ public Type GetParameterType()
+ {
+ return typeof(P);
+ }
+
+ public void SetContextParameterValues(IDictionary<string, object> parameterValues)
+ {
+ _contextParameterValues = parameterValues;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
index 94a8c99..4e2bfff 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalEvaluationTests.cs
@@ -55,7 +55,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
new[] {new Token("__"), new Token("in", new StringParameter("knows"))}, "__.in(\"knows\")")})}),
Tuple.Create("g.V().has(\"age\",P.gt(27))",
new[] {new Token("has", new ITokenParameter[] { new StringParameter("age"),
- new TraversalPredicateParameter(
+ new PParameter(
new[] { new Token("P"), new Token("gt", LiteralParameter.Create(27)) }) })}),
Tuple.Create("g.V().count(Scope.local)",
new[] { new Token("count", new TraversalEnumParameter("Scope.local"))}),
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index 118fcea..11145da 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -406,7 +406,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
}
if (text.Substring(i, 2).StartsWith("P."))
{
- return new TraversalPredicateParameter(ParseTokens(text, ref i));
+ return new PParameter(ParseTokens(text, ref i));
}
var parameterText = text.Substring(i, text.IndexOf(')', i) - i);
var separatorIndex = parameterText.IndexOf(',');
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
deleted file mode 100644
index 57262c1..0000000
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalPredicateParameter.cs
+++ /dev/null
@@ -1,93 +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;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
-{
- /// <summary>
- /// Represents a parameter for a traversal predicate (ie: P.gt())
- /// </summary>
- internal class TraversalPredicateParameter : ITokenParameter, IEquatable<TraversalPredicateParameter>
- {
- private IDictionary<string, object> _contextParameterValues;
- public IList<Token> Tokens { get; }
-
- public TraversalPredicateParameter(IList<Token> tokens)
- {
- Tokens = tokens;
- }
-
- public bool Equals(TraversalPredicateParameter other)
- {
- return Tokens.SequenceEqual(other.Tokens);
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != GetType()) return false;
- return Equals((TraversalPredicateParameter) obj);
- }
-
- public override int GetHashCode()
- {
- return Tokens != null ? Tokens.GetHashCode() : 0;
- }
-
- public object GetValue()
- {
- var type = typeof(P);
- object instance = null;
- for (var i = 1; i < Tokens.Count; i++)
- {
- var token = Tokens[i];
- token.SetContextParameterValues(_contextParameterValues);
- var method = type.GetMethod(TraversalParser.GetCsharpName(token.Name),
- BindingFlags.Static | BindingFlags.Public);
- if (method == null)
- {
- throw new InvalidOperationException($"Predicate (P) method '{token}' not found for testing");
- }
- instance = method.Invoke(instance,
- new object[] {token.Parameters.Select(p => p.GetValue()).ToArray()});
- }
- return instance;
- }
-
- public Type GetParameterType()
- {
- return typeof(TraversalPredicate);
- }
-
- public void SetContextParameterValues(IDictionary<string, object> parameterValues)
- {
- _contextParameterValues = parameterValues;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
index 8ed7a3d..568b970 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/BytecodeGraphSONSerializerTests.cs
@@ -118,7 +118,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
bytecode.AddSource("withSideEffect", "a", new List<string> {"josh", "peter"});
bytecode.AddStep("V", 1);
bytecode.AddStep("values", "name");
- bytecode.AddStep("where", new TraversalPredicate("within", "a"));
+ bytecode.AddStep("where", new P("within", "a"));
var graphsonWriter = CreateGraphSONWriter();
var graphSON = graphsonWriter.WriteObject(bytecode);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/359b08cc/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
index 3d02533..3e2d307 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@ -222,7 +222,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
public void ShouldSerializePredicateWithTwoValues()
{
var writer = CreateStandardGraphSONWriter();
- var predicate = new TraversalPredicate("within", new List<int> {1, 2});
+ var predicate = new P("within", new List<int> {1, 2});
var serializedPredicate = writer.WriteObject(predicate);
@@ -235,7 +235,7 @@ namespace Gremlin.Net.UnitTest.Structure.IO.GraphSON
public void ShouldSerializePredicateWithSingleValue()
{
var writer = CreateStandardGraphSONWriter();
- var predicate = new TraversalPredicate("lt", 5);
+ var predicate = new P("lt", 5);
var serializedPredicate = writer.WriteObject(predicate);
[6/8] tinkerpop git commit: Merge branch 'TINKERPOP-1901' into tp32
Posted by fl...@apache.org.
Merge branch 'TINKERPOP-1901' into tp32
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/50493397
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/50493397
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/50493397
Branch: refs/heads/TINKERPOP-1919
Commit: 504933975d2fbbeb61aa724f38aa8b7c888f63ea
Parents: f02f94f df989dc
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 19:27:58 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 19:27:58 2018 +0100
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/reference/gremlin-variants.asciidoc | 2 +-
.../upgrade/release-3.2.x-incubating.asciidoc | 11 +++
gremlin-dotnet/glv/Enum.template | 9 +-
gremlin-dotnet/glv/generate.groovy | 41 ++++-----
.../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/GraphTraversal.cs | 45 ++++++----
.../Process/Traversal/GraphTraversalSource.cs | 14 ++-
.../Process/Traversal/GryoVersion.cs | 9 +-
.../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 +++++++
.../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 ++--
.../Process/Traversal/TraversalPredicate.cs | 2 +-
.../src/Gremlin.Net/Process/Traversal/__.cs | 28 +++---
.../Structure/IO/GraphSON/EnumSerializer.cs | 5 +-
.../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +-
.../TraversalEnumParameter.cs | 5 +-
32 files changed, 457 insertions(+), 213 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/50493397/CHANGELOG.asciidoc
----------------------------------------------------------------------
[3/8] tinkerpop git commit: TINKERPOP-1901 Use spaces to indent enum
values
Posted by fl...@apache.org.
TINKERPOP-1901 Use spaces to indent enum values
Previously, the first enum value used spaces, whereas all following
values used tabs. Now, spaces are used consistently.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4d5768b0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4d5768b0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4d5768b0
Branch: refs/heads/TINKERPOP-1919
Commit: 4d5768b0aa53e06e95738f3faf904d3290a91794
Parents: d012171
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Mon Mar 12 16:37:30 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Mon Mar 12 16:37:30 2018 +0100
----------------------------------------------------------------------
gremlin-dotnet/glv/Enum.template | 4 ++--
gremlin-dotnet/glv/generate.groovy | 2 +-
.../Gremlin.Net/Process/Traversal/Barrier.cs | 2 +-
.../Process/Traversal/Cardinality.cs | 8 +++----
.../src/Gremlin.Net/Process/Traversal/Column.cs | 6 ++---
.../Gremlin.Net/Process/Traversal/Direction.cs | 8 +++----
.../Process/Traversal/GraphSONVersion.cs | 6 ++---
.../Process/Traversal/GryoVersion.cs | 2 +-
.../Gremlin.Net/Process/Traversal/Operator.cs | 24 ++++++++++----------
.../src/Gremlin.Net/Process/Traversal/Order.cs | 16 ++++++-------
.../src/Gremlin.Net/Process/Traversal/Pick.cs | 6 ++---
.../src/Gremlin.Net/Process/Traversal/Pop.cs | 8 +++----
.../src/Gremlin.Net/Process/Traversal/Scope.cs | 6 ++---
.../src/Gremlin.Net/Process/Traversal/T.cs | 10 ++++----
14 files changed, 54 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d5768b0/gremlin-dotnet/glv/Enum.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/Enum.template b/gremlin-dotnet/glv/Enum.template
index 0be23c7..1f11076 100644
--- a/gremlin-dotnet/glv/Enum.template
+++ b/gremlin-dotnet/glv/Enum.template
@@ -32,8 +32,8 @@ namespace Gremlin.Net.Process.Traversal
: base("<%= enumClass.simpleName %>", enumValue)
{
}
-
- <%= constants %>
+<% constants.each { constant -> %>
+ <%= constant %><%}%>
}
#pragma warning restore 1591
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d5768b0/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 6d89b2f..0404307 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -354,7 +354,7 @@ def createEnum = { enumClass ->
collect { value ->
def csharpName = toCSharpName(enumClass, value.name())
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")
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d5768b0/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 0ae4fa2..df6d349 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs
@@ -32,7 +32,7 @@ namespace Gremlin.Net.Process.Traversal
: base("Barrier", enumValue)
{
}
-
+
public static Barrier NormSack => new Barrier("normSack");
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d5768b0/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 f158153..d2cbcf2 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs
@@ -32,10 +32,10 @@ namespace Gremlin.Net.Process.Traversal
: base("Cardinality", enumValue)
{
}
-
- public static Cardinality List => new Cardinality("list");
- public static Cardinality Set => new Cardinality("set");
- public static Cardinality Single => new Cardinality("single");
+
+ 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/4d5768b0/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 9fa2039..9e0451e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs
@@ -32,9 +32,9 @@ namespace Gremlin.Net.Process.Traversal
: base("Column", enumValue)
{
}
-
- public static Column Keys => new Column("keys");
- public static Column Values => new Column("values");
+
+ 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/4d5768b0/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 9566d51..5a93f0a 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs
@@ -32,10 +32,10 @@ namespace Gremlin.Net.Process.Traversal
: base("Direction", enumValue)
{
}
-
- public static Direction Both => new Direction("BOTH");
- public static Direction In => new Direction("IN");
- public static Direction Out => new Direction("OUT");
+
+ 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/4d5768b0/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 ad73ad1..0c92607 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphSONVersion.cs
@@ -32,9 +32,9 @@ namespace Gremlin.Net.Process.Traversal
: base("GraphSONVersion", enumValue)
{
}
-
- public static GraphSONVersion V1_0 => new GraphSONVersion("V1_0");
- public static GraphSONVersion V2_0 => new GraphSONVersion("V2_0");
+
+ 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/4d5768b0/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 45387e2..fcc746e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GryoVersion.cs
@@ -32,7 +32,7 @@ namespace Gremlin.Net.Process.Traversal
: base("GryoVersion", enumValue)
{
}
-
+
public static GryoVersion V1_0 => new GryoVersion("V1_0");
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d5768b0/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 4116197..8f0c9b3 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs
@@ -32,18 +32,18 @@ namespace Gremlin.Net.Process.Traversal
: 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");
+
+ 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/4d5768b0/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 d20906a..44ccb9b 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs
@@ -32,14 +32,14 @@ namespace Gremlin.Net.Process.Traversal
: 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");
+
+ 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/4d5768b0/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 a47d4a6..d4132ea 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs
@@ -32,9 +32,9 @@ namespace Gremlin.Net.Process.Traversal
: base("Pick", enumValue)
{
}
-
- public static Pick Any => new Pick("any");
- public static Pick None => new Pick("none");
+
+ 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/4d5768b0/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 9e97a09..8a157c5 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs
@@ -32,10 +32,10 @@ namespace Gremlin.Net.Process.Traversal
: base("Pop", enumValue)
{
}
-
- public static Pop All => new Pop("all");
- public static Pop First => new Pop("first");
- public static Pop Last => new Pop("last");
+
+ 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/4d5768b0/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 65a6e67..ee67c39 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs
@@ -32,9 +32,9 @@ namespace Gremlin.Net.Process.Traversal
: base("Scope", enumValue)
{
}
-
- public static Scope Global => new Scope("global");
- public static Scope Local => new Scope("local");
+
+ 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/4d5768b0/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 c0e5927..bae1314 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/T.cs
@@ -32,11 +32,11 @@ namespace Gremlin.Net.Process.Traversal
: 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");
+
+ 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
[5/8] tinkerpop git commit: TINKERPOP-1901 Describe improved
Gremlin.Net tokens in upgrade docs
Posted by fl...@apache.org.
TINKERPOP-1901 Describe improved Gremlin.Net tokens in upgrade docs
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/df989dc4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/df989dc4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/df989dc4
Branch: refs/heads/TINKERPOP-1919
Commit: df989dc40ab7cf834b6ed275c453c4bb220315bf
Parents: 4d5768b
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Tue Mar 13 19:26:00 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Tue Mar 13 19:26:00 2018 +0100
----------------------------------------------------------------------
docs/src/upgrade/release-3.2.x-incubating.asciidoc | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/df989dc4/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 7d2a80c..0cb8ddc 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -42,6 +42,17 @@ by clients that might mysteriously disappear without properly closing their conn
See: link:https://issues.apache.org/jira/browse/TINKERPOP-1726[TINKERPOP-1726]
+==== Gremlin.Net Tokens Improved
+
+The various Gremlin tokens (e.g. `T`, `Order`, `Operator`, etc.) that were implemented as Enums before in Gremlin.Net
+are now implemented as classes. This mainly allows them to implement interfaces which their Java counterparts already
+did. `T` for example now implements the new interface `IFunction` which simply mirrors its Java counterpart `Function`.
+Steps that expect objects for those interfaces as arguments now explicitly use the interface. Before, they used just
+`object` as the type for these arguments which made it hard for users to know what kind of `object` they can use.
+However, usage of these tokens themselves shouldn't change at all (e.g. `T.Id` is still `T.Id`).
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1901[TINKERPOP-1901]
+
=== Upgrading for Providers
==== Graph System Providers
[2/8] 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-1919
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);
}
[4/8] tinkerpop git commit: Minor code refactoring in JavaTranslator
CTR
Posted by fl...@apache.org.
Minor code refactoring in JavaTranslator CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f02f94fd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f02f94fd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f02f94fd
Branch: refs/heads/TINKERPOP-1919
Commit: f02f94fd067799e5f532086a762c35abd3a11a93
Parents: b25b976
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 13 08:40:10 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 13 08:40:10 2018 -0400
----------------------------------------------------------------------
.../apache/tinkerpop/gremlin/jsr223/JavaTranslator.java | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f02f94fd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
index df12055..3e0e6da 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
@@ -190,7 +190,7 @@ public final class JavaTranslator<S extends TraversalSource, T extends Traversal
}
}
- private Object invokeMethod(final Object delegate, final Class returnType, final String methodName, final Object... arguments) {
+ private Object invokeMethod(final Object delegate, final Class<?> returnType, final String methodName, final Object... arguments) {
// populate method cache for fast access to methods in subsequent calls
final Map<String, List<Method>> methodCache = GLOBAL_METHOD_CACHE.getOrDefault(delegate.getClass(), new HashMap<>());
if (methodCache.isEmpty()) buildMethodCache(delegate, methodCache);
@@ -222,7 +222,7 @@ public final class JavaTranslator<S extends TraversalSource, T extends Traversal
found = false;
break;
}
- Object[] varArgs = (Object[]) Array.newInstance(parameterClass, argumentsCopy.length - i);
+ final Object[] varArgs = (Object[]) Array.newInstance(parameterClass, argumentsCopy.length - i);
int counter = 0;
for (int j = i; j < argumentsCopy.length; j++) {
varArgs[counter++] = argumentsCopy[j];
@@ -263,11 +263,7 @@ public final class JavaTranslator<S extends TraversalSource, T extends Traversal
if (methodCache.isEmpty()) {
for (final Method method : delegate.getClass().getMethods()) {
if (!(method.getName().equals("addV") && method.getParameterCount() == 1 && method.getParameters()[0].getType().equals(Object[].class))) { // hack cause its hard to tell Object[] vs. String :|
- List<Method> list = methodCache.get(method.getName());
- if (null == list) {
- list = new ArrayList<>();
- methodCache.put(method.getName(), list);
- }
+ final List<Method> list = methodCache.computeIfAbsent(method.getName(), k -> new ArrayList<>());
list.add(method);
}
}