TINKERPOP-1854 Make Lambda implementation internal

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/11351a82
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/11351a82
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/11351a82

Branch: refs/heads/TINKERPOP-1854
Commit: 11351a8284c7bac6c63f06152fb882d5e9faae34
Parents: 0cdaa3a
Author: Florian Hockmann <f...@florian-hockmann.de>
Authored: Thu Mar 15 18:15:53 2018 +0100
Committer: Florian Hockmann <f...@florian-hockmann.de>
Committed: Thu Mar 15 18:16:05 2018 +0100

----------------------------------------------------------------------
 .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 45 +++++++-------------
 .../Process/Traversal/StringBasedLambda.cs      | 42 ++++++++++++++++++
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  2 +-
 .../Structure/IO/GraphSON/LambdaSerializer.cs   |  2 +-
 4 files changed, 60 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/11351a82/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs 
b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
index 21849ef..12eb016 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs
@@ -26,47 +26,34 @@ namespace Gremlin.Net.Process.Traversal
     /// <summary>
     ///     Represents a lambda.
     /// </summary>
-    public class Lambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, 
IBinaryOperator, IComparator, IConsumer,
-        ISupplier
+    public interface ILambda : IFunction, IBiFunction, IPredicate, 
IUnaryOperator, IBinaryOperator, IComparator,
+        IConsumer, ISupplier
     {
-        private const int DefaultArgument = -1;
-
-        private Lambda(string expression, string language)
-        {
-            LambdaExpression = expression;
-            Language = language;
-        }
-
-        /// <summary>
-        ///     Gets the lambda expression.
-        /// </summary>
-        public string LambdaExpression { get; }
-
-        /// <summary>
-        ///     Gets the language of this lambda.
-        /// </summary>
-        public string Language { get; }
-
-        internal object Arguments => DefaultArgument;
+    }
 
+    /// <summary>
+    ///     Provides methods to create lambdas.
+    /// </summary>
+    public static class Lambda
+    {
         /// <summary>
-        ///     Creates a new Groovy <see cref="Lambda"/>.
+        ///     Creates a new Groovy lambda.
         /// </summary>
         /// <param name="expression">The lambda expression.</param>
-        /// <returns>The created <see cref="Lambda"/>.</returns>
-        public static Lambda Groovy(string expression)
+        /// <returns>The created lambda.</returns>
+        public static ILambda Groovy(string expression)
         {
-            return new Lambda(expression, "gremlin-groovy");
+            return new StringBasedLambda(expression, "gremlin-groovy");
         }
 
         /// <summary>
-        ///     Creates a new Python <see cref="Lambda"/>.
+        ///     Creates a new Python lambda.
         /// </summary>
         /// <param name="expression">The lambda expression.</param>
-        /// <returns>The created <see cref="Lambda"/>.</returns>
-        public static Lambda Python(string expression)
+        /// <returns>The created lambda.</returns>
+        public static ILambda Python(string expression)
         {
-            return new Lambda(expression, "gremlin-python");
+            return new StringBasedLambda(expression, "gremlin-python");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/11351a82/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
----------------------------------------------------------------------
diff --git 
a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs 
b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
new file mode 100644
index 0000000..e27b474
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/StringBasedLambda.cs
@@ -0,0 +1,42 @@
+#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
+{
+    internal class StringBasedLambda : ILambda
+    {
+        private const int DefaultArgument = -1;
+
+        public StringBasedLambda(string expression, string language)
+        {
+            LambdaExpression = expression;
+            Language = language;
+        }
+
+        public string LambdaExpression { get; }
+
+        public string Language { get; }
+
+        public object Arguments => DefaultArgument;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/11351a82/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 826d608..7185868 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
@@ -60,7 +60,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
                 {typeof(Property), new PropertySerializer()},
                 {typeof(VertexProperty), new VertexPropertySerializer()},
                 {typeof(AbstractTraversalStrategy), new 
TraversalStrategySerializer()},
-                {typeof(Lambda), new LambdaSerializer()}
+                {typeof(ILambda), new LambdaSerializer()}
             };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/11351a82/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
----------------------------------------------------------------------
diff --git 
a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs 
b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
index fa739fd..180253e 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs
@@ -30,7 +30,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON
     {
         public Dictionary<string, dynamic> Dictify(dynamic objectData, 
GraphSONWriter writer)
         {
-            Lambda lambda = objectData;
+            StringBasedLambda lambda = objectData;
             var valueDict = new Dictionary<string, dynamic>
             {
                 {"script", lambda.LambdaExpression},

Reply via email to