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/12 19:53:23 UTC
tinkerpop git commit: TINKERPOP-1919 Merge classes P and
TraversalPredicate
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1919 [created] c7d434af4
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/c7d434af
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c7d434af
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c7d434af
Branch: refs/heads/TINKERPOP-1919
Commit: c7d434af40f4caaad3c6ae8bda3cdd3b120dfd29
Parents: b25b976
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Mon Mar 12 20:53:09 2018 +0100
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Mon Mar 12 20:53:09 2018 +0100
----------------------------------------------------------------------
gremlin-dotnet/glv/P.template | 60 ++++++++++-
gremlin-dotnet/glv/generate.groovy | 4 +-
.../Process/Traversal/GraphTraversal.cs | 30 +++---
.../src/Gremlin.Net/Process/Traversal/P.cs | 104 ++++++++++++++-----
.../Process/Traversal/TraversalPredicate.cs | 85 ---------------
.../src/Gremlin.Net/Process/Traversal/__.cs | 30 +++---
.../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 +-
17 files changed, 319 insertions(+), 309 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c7d434af/gremlin-dotnet/glv/P.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template
index f337127..61673cf 100644
--- a/gremlin-dotnet/glv/P.template
+++ b/gremlin-dotnet/glv/P.template
@@ -32,18 +32,70 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public class P
{
+ /// <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/c7d434af/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 12cfa88..f525a5b 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -48,8 +48,8 @@ def toCSharpTypeMap = ["Long": "long",
"TraversalMetrics": "E2",
"Traversal": "ITraversal",
"Traversal[]": "ITraversal[]",
- "Predicate": "TraversalPredicate",
- "P": "TraversalPredicate",
+ "Predicate": "P",
+ "P": "P",
"TraversalStrategy": "ITraversalStrategy",
"TraversalStrategy[]": "ITraversalStrategy[]",
"Function": "object",
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c7d434af/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..5c227f9 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -355,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> (TraversalPredicate choosePredicate, ITraversal trueChoice)
+ public GraphTraversal<S, E2> Choose<E2> (P choosePredicate, ITraversal trueChoice)
{
Bytecode.AddStep("choose", choosePredicate, trueChoice);
return Wrap<S, E2>(this);
@@ -364,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, ITraversal falseChoice)
+ public GraphTraversal<S, E2> Choose<E2> (P choosePredicate, ITraversal trueChoice, ITraversal falseChoice)
{
Bytecode.AddStep("choose", choosePredicate, trueChoice, falseChoice);
return Wrap<S, E2>(this);
@@ -496,7 +496,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 (P emitPredicate)
{
Bytecode.AddStep("emit", emitPredicate);
return Wrap<S, E>(this);
@@ -514,7 +514,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 (P predicate)
{
Bytecode.AddStep("filter", predicate);
return Wrap<S, E>(this);
@@ -658,7 +658,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);
@@ -676,7 +676,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);
@@ -703,7 +703,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);
@@ -732,7 +732,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);
@@ -741,7 +741,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);
@@ -761,7 +761,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);
@@ -801,7 +801,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);
@@ -879,7 +879,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);
@@ -1591,7 +1591,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 (P untilPredicate)
{
Bytecode.AddStep("until", untilPredicate);
return Wrap<S, E>(this);
@@ -1651,7 +1651,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);
@@ -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 (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/c7d434af/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..cb2b2b9 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
@@ -32,83 +32,135 @@ namespace Gremlin.Net.Process.Traversal
/// </summary>
public class P
{
+ /// <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/c7d434af/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 b854213..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
- {
- /// <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/c7d434af/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..757e476 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/__.cs
@@ -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>(P 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>(P 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(P 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(P predicate)
{
return new GraphTraversal<object, object>().Filter(predicate);
}
@@ -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);
}
@@ -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(P untilPredicate)
{
return new GraphTraversal<object, object>().Until(untilPredicate);
}
@@ -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/c7d434af/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..dc05221 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(Enum), 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/c7d434af/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/c7d434af/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/c7d434af/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/c7d434af/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/c7d434af/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/c7d434af/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/c7d434af/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/c7d434af/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/c7d434af/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/c7d434af/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);