diff --git a/README.md b/README.md index 57108a3e..9a7c0719 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ val Distance = Key[Int]("distance") val paris = graph + "Paris" // create vertex with typed properties -val london = graph + ("London", Founded → "43 AD") +val london = graph + ("London", Founded -> "43 AD") // create labelled edges paris --- "OneWayRoad" --> london @@ -84,7 +84,7 @@ paris <-- "OtherWayAround" --- london paris <-- "Eurostar" --> london // create edge with typed properties -paris --- ("Eurostar", Distance → 495) --> london +paris --- ("Eurostar", Distance -> 495) --> london // type safe access to properties paris.out("Eurostar").value(Founded).head //43 AD @@ -100,8 +100,8 @@ val v1 = graph + ("person", Name -> "marko", Age -> 29) asScala v1.keys // Set(Key("name"), Key("age")) v1.property(Name) // "marko" -v1.valueMap // Map("name" → "marko", "age" → 29) -v1.valueMap("name", "age") // Map("name" → "marko", "age" → 29) +v1.valueMap // Map("name" -> "marko", "age" -> 29) +v1.valueMap("name", "age") // Map("name" -> "marko", "age" -> 29) ``` More working examples in [SchemaSpec](https://github.com/mpollmeier/gremlin-scala/blob/master/gremlin-scala/src/test/scala/gremlin/scala/SchemaSpec.scala), [ArrowSyntaxSpec](https://github.com/mpollmeier/gremlin-scala/blob/master/gremlin-scala/src/test/scala/gremlin/scala/ArrowSyntaxSpec.scala) and [ElementSpec](https://github.com/mpollmeier/gremlin-scala/blob/master/gremlin-scala/src/test/scala/gremlin/scala/ElementSpec.scala). diff --git a/gremlin-scala/src/main/scala/gremlin/scala/ScalaVertex.scala b/gremlin-scala/src/main/scala/gremlin/scala/ScalaVertex.scala index c5afe72d..5f3955da 100644 --- a/gremlin-scala/src/main/scala/gremlin/scala/ScalaVertex.scala +++ b/gremlin-scala/src/main/scala/gremlin/scala/ScalaVertex.scala @@ -77,7 +77,7 @@ case class ScalaVertex(vertex: Vertex) extends ScalaElement[Vertex] { se.from.asScala.addEdge(se.label, vertex, se.properties) def <--(de: SemiDoubleEdge): (Edge, Edge) = - addEdge(de.label, de.right, de.properties) → de.right.asScala + addEdge(de.label, de.right, de.properties) -> de.right.asScala .addEdge(de.label, vertex, de.properties) def ---(label: String): SemiEdge = SemiEdge(vertex, label) @@ -87,13 +87,13 @@ case class ScalaVertex(vertex: Vertex) extends ScalaElement[Vertex] { def ---(label: String, properties: Map[String, Any]): SemiEdge = SemiEdge(vertex, label, properties.map { - case (key, value) => Key[Any](key) → value + case (key, value) => Key[Any](key) -> value }.toSeq) def ---[CC <: Product: Marshallable](cc: CC): SemiEdge = { val fromCC = implicitly[Marshallable[CC]].fromCC(cc) SemiEdge(vertex, fromCC.label, fromCC.valueMap.map { r => - Key[Any](r._1) → r._2 + Key[Any](r._1) -> r._2 }.toSeq) } diff --git a/gremlin-scala/src/main/scala/gremlin/scala/Schema.scala b/gremlin-scala/src/main/scala/gremlin/scala/Schema.scala index 8b7456cf..077934c2 100644 --- a/gremlin-scala/src/main/scala/gremlin/scala/Schema.scala +++ b/gremlin-scala/src/main/scala/gremlin/scala/Schema.scala @@ -2,8 +2,6 @@ package gremlin.scala // a type safe key for a property of vertices or edges case class Key[A](name: String) { - def →(value: A): KeyValue[A] = KeyValue(this, value) - def ->(value: A): KeyValue[A] = KeyValue(this, value) def of(value: A): KeyValue[A] = KeyValue(this, value) diff --git a/gremlin-scala/src/test/scala/gremlin/scala/ArrowSyntaxSpec.scala b/gremlin-scala/src/test/scala/gremlin/scala/ArrowSyntaxSpec.scala index c8519e8b..504bccca 100644 --- a/gremlin-scala/src/test/scala/gremlin/scala/ArrowSyntaxSpec.scala +++ b/gremlin-scala/src/test/scala/gremlin/scala/ArrowSyntaxSpec.scala @@ -14,14 +14,14 @@ class ArrowSyntaxSpec extends WordSpec with Matchers { } "has a label and one property" in new Fixture { - paris --- (Eurostar, Name → "alpha") --> london + paris --- (Eurostar, Name -> "alpha") --> london paris.out(Eurostar).head shouldBe london paris.outE(Eurostar).value(Name).head shouldBe "alpha" } "has a label and multiple properties" in new Fixture { - paris --- (Eurostar, Name → "alpha", Length → 100) --> london + paris --- (Eurostar, Name -> "alpha", Length -> 100) --> london paris.out(Eurostar).head shouldBe london paris.outE(Eurostar).value(Name).head shouldBe "alpha" @@ -43,13 +43,13 @@ class ArrowSyntaxSpec extends WordSpec with Matchers { } "has a label and one property" in new Fixture { - paris <-- (Eurostar, Name → "alpha") --- london + paris <-- (Eurostar, Name -> "alpha") --- london paris.in(Eurostar).head shouldBe london paris.inE(Eurostar).value(Name).head shouldBe "alpha" } "has a label and multiple properties" in new Fixture { - paris <-- (Eurostar, Name → "alpha", Length -> 100) --- london + paris <-- (Eurostar, Name -> "alpha", Length -> 100) --- london paris.in(Eurostar).head shouldBe london paris.inE(Eurostar).value(Name).head shouldBe "alpha" @@ -74,7 +74,7 @@ class ArrowSyntaxSpec extends WordSpec with Matchers { } "have labels and one property" in new Fixture { - paris <-- (Eurostar, Name → "alpha") --> london + paris <-- (Eurostar, Name -> "alpha") --> london paris.out(Eurostar).head shouldBe london paris.outE(Eurostar).value(Name).head shouldBe "alpha" @@ -83,7 +83,7 @@ class ArrowSyntaxSpec extends WordSpec with Matchers { } "have labels and multiple properties" in new Fixture { - paris <-- (Eurostar, Name → "alpha", Length → 100) --> london + paris <-- (Eurostar, Name -> "alpha", Length -> 100) --> london paris.out(Eurostar).head shouldBe london paris.outE(Eurostar).value(Name).head shouldBe "alpha" @@ -118,7 +118,7 @@ class ArrowSyntaxSpec extends WordSpec with Matchers { // Long.MaxValue, // Some("option type"), // Seq("test1", "test2"), - // Map("key1" → "value1", "key2" → "value2"), + // Map("key1" -> "value1", "key2" -> "value2"), // NestedClass("nested") // ) --> london @@ -137,7 +137,7 @@ class ArrowSyntaxSpec extends WordSpec with Matchers { // Long.MaxValue, // Some("option type"), // Seq("test1", "test2"), - // Map("key1" → "value1", "key2" → "value2"), + // Map("key1" -> "value1", "key2" -> "value2"), // NestedClass("nested") // ) --> london @@ -160,7 +160,7 @@ class ArrowSyntaxSpec extends WordSpec with Matchers { // Long.MaxValue, // Some("option type"), // Seq("test1", "test2"), - // Map("key1" → "value1", "key2" → "value2"), + // Map("key1" -> "value1", "key2" -> "value2"), // NestedClass("nested") // ) --- london diff --git a/gremlin-scala/src/test/scala/gremlin/scala/ElementSpec.scala b/gremlin-scala/src/test/scala/gremlin/scala/ElementSpec.scala index a1518b48..153d853a 100644 --- a/gremlin-scala/src/test/scala/gremlin/scala/ElementSpec.scala +++ b/gremlin-scala/src/test/scala/gremlin/scala/ElementSpec.scala @@ -14,15 +14,15 @@ class ElementSpec extends TestBase { v1.keys shouldBe Set(Key("name"), Key("age")) v1.property(Name).value shouldBe "marko" v1.property(DoesNotExist).isPresent shouldBe false - v1.valueMap shouldBe Map("name" → "marko", "age" → 29) - v1.valueMap("name", "age") shouldBe Map("name" → "marko", "age" → 29) + v1.valueMap shouldBe Map("name" -> "marko", "age" -> 29) + v1.valueMap("name", "age") shouldBe Map("name" -> "marko", "age" -> 29) v1.properties("name", "age").length shouldBe 2 v1.properties.length shouldBe 2 e7.keys shouldBe Set(Key("weight")) e7.property(Weight).value shouldBe 0.5 e7.property(DoesNotExist).isPresent shouldBe false - e7.valueMap("weight") shouldBe Map("weight" → 0.5) + e7.valueMap("weight") shouldBe Map("weight" -> 0.5) } it("maps properties to scala.Option") { @@ -128,7 +128,7 @@ class ElementSpec extends TestBase { val label1 = "label1" val label2 = "label2" val v1 = graph.addVertex(label1) - val v2 = graph.addVertex(label2, Map(TestProperty.name → "testValue")) + val v2 = graph.addVertex(label2, Map(TestProperty.name -> "testValue")) graph.V.has(T.label, label1).head shouldBe v1.vertex graph.V.has(T.label, label2).head shouldBe v2.vertex @@ -141,7 +141,7 @@ class ElementSpec extends TestBase { val label2 = "label2" val v1 = graph + label1 - val v2 = graph + (label2, TestProperty → "testValue") + val v2 = graph + (label2, TestProperty -> "testValue") graph.V.hasLabel(label1).head shouldBe v1.vertex graph.V.hasLabel(label2).head shouldBe v2.vertex @@ -167,10 +167,10 @@ class ElementSpec extends TestBase { val v2 = graph.addVertex() val e = - v1.asScala.addEdge("testLabel", v2, Seq(TestProperty → "testValue")) + v1.asScala.addEdge("testLabel", v2, Seq(TestProperty -> "testValue")) e.label shouldBe "testLabel" e.value2(TestProperty) shouldBe "testValue" - e.valueMap(TestProperty.name) shouldBe Map(TestProperty.name → "testValue") + e.valueMap(TestProperty.name) shouldBe Map(TestProperty.name -> "testValue") v1.outE().head shouldBe e.edge v1.out("testLabel").head shouldBe v2.vertex } diff --git a/gremlin-scala/src/test/scala/gremlin/scala/FilterSpec.scala b/gremlin-scala/src/test/scala/gremlin/scala/FilterSpec.scala index fd724a2f..5c2c9db9 100644 --- a/gremlin-scala/src/test/scala/gremlin/scala/FilterSpec.scala +++ b/gremlin-scala/src/test/scala/gremlin/scala/FilterSpec.scala @@ -35,17 +35,17 @@ class FilterSpec extends WordSpec with Matchers { "has - sugar" in new Fixture { val g = TinkerGraph.open.asScala - g + ("software", Name → "blueprints", Created → 2010) + g + ("software", Name -> "blueprints", Created -> 2010) g.V - .has(Name → "blueprints") - .head <-- "dependsOn" --- (g + ("software", Name → "gremlin", Created → 2009)) + .has(Name -> "blueprints") + .head <-- "dependsOn" --- (g + ("software", Name -> "gremlin", Created -> 2009)) g.V - .has(Name → "gremlin") - .head <-- "dependsOn" --- (g + ("software", Name → "gremlinScala")) + .has(Name -> "gremlin") + .head <-- "dependsOn" --- (g + ("software", Name -> "gremlinScala")) g.V - .has(Name → "gremlinScala") - .head <-- "createdBy" --- (g + ("person", Name → "mpollmeier")) + .has(Name -> "gremlinScala") + .head <-- "createdBy" --- (g + ("person", Name -> "mpollmeier")) g.V.toList().size shouldBe 4 g.V.hasLabel("software").toList().size shouldBe 3 diff --git a/gremlin-scala/src/test/scala/gremlin/scala/MarshallableSpec.scala b/gremlin-scala/src/test/scala/gremlin/scala/MarshallableSpec.scala index ea2b793b..a9161483 100644 --- a/gremlin-scala/src/test/scala/gremlin/scala/MarshallableSpec.scala +++ b/gremlin-scala/src/test/scala/gremlin/scala/MarshallableSpec.scala @@ -44,8 +44,8 @@ class MarshallableSpec extends WordSpec with Matchers { val vl = graph.V(v.id).head vl.label shouldBe cc.getClass.getSimpleName - vl.valueMap should contain("s" → cc.s) - vl.valueMap should contain("i" → cc.i) + vl.valueMap should contain("s" -> cc.s) + vl.valueMap should contain("i" -> cc.i) } "contain options" should { @@ -80,8 +80,8 @@ class MarshallableSpec extends WordSpec with Matchers { val vl = graph.V(v.id).head vl.label shouldBe cc.getClass.getSimpleName - vl.valueMap should contain("s" → cc.s) - vl.valueMap should contain("i" → cc.i.value) + vl.valueMap should contain("s" -> cc.s) + vl.valueMap should contain("i" -> cc.i.value) vl.toCC[CCWithValueClass] shouldBe cc } @@ -91,8 +91,8 @@ class MarshallableSpec extends WordSpec with Matchers { val vl = graph.V(v.id).head vl.label shouldBe cc.getClass.getSimpleName - vl.valueMap should contain("s" → cc.s) - vl.valueMap should contain("i" → cc.i.get.value) + vl.valueMap should contain("s" -> cc.s) + vl.valueMap should contain("i" -> cc.i.get.value) vl.toCC[CCWithOptionValueClass] shouldBe cc } @@ -102,7 +102,7 @@ class MarshallableSpec extends WordSpec with Matchers { val vl = graph.V(v.id).head vl.label shouldBe cc.getClass.getSimpleName - vl.valueMap should contain("s" → cc.s) + vl.valueMap should contain("s" -> cc.s) vl.valueMap.keySet should not contain ("i") vl.toCC[CCWithOptionValueClass] shouldBe cc } @@ -113,7 +113,7 @@ class MarshallableSpec extends WordSpec with Matchers { val marshaller = new Marshallable[CCWithOption] { def fromCC(cc: CCWithOption) = - FromCC(None, "CCWithOption", Map("i" -> cc.i, "s" → cc.s.getOrElse("undefined"))) + FromCC(None, "CCWithOption", Map("i" -> cc.i, "s" -> cc.s.getOrElse("undefined"))) def toCC(id: AnyRef, valueMap: Map[String, Any]): CCWithOption = CCWithOption(i = valueMap("i").asInstanceOf[Int], @@ -131,7 +131,7 @@ class MarshallableSpec extends WordSpec with Matchers { Long.MaxValue, Some("option type"), Seq("test1", "test2"), - Map("key1" → "value1", "key2" → "value2"), + Map("key1" -> "value1", "key2" -> "value2"), NestedClass("nested") ) @@ -142,12 +142,12 @@ class MarshallableSpec extends WordSpec with Matchers { val vl = graph.V(v.id).head() vl.label shouldBe "the_label" vl.id shouldBe ccWithLabelAndId.id - vl.valueMap should contain("s" → ccWithLabelAndId.s) - vl.valueMap should contain("l" → ccWithLabelAndId.l) - vl.valueMap should contain("o" → ccWithLabelAndId.o.get) - vl.valueMap should contain("seq" → ccWithLabelAndId.seq) - vl.valueMap should contain("map" → ccWithLabelAndId.map) - vl.valueMap should contain("nested" → ccWithLabelAndId.nested) + vl.valueMap should contain("s" -> ccWithLabelAndId.s) + vl.valueMap should contain("l" -> ccWithLabelAndId.l) + vl.valueMap should contain("o" -> ccWithLabelAndId.o.get) + vl.valueMap should contain("seq" -> ccWithLabelAndId.seq) + vl.valueMap should contain("map" -> ccWithLabelAndId.map) + vl.valueMap should contain("nested" -> ccWithLabelAndId.nested) } "have an Option @id annotation" in new Fixture { @@ -159,7 +159,7 @@ class MarshallableSpec extends WordSpec with Matchers { val vl = graph.V(v.id).head() vl.label shouldBe cc.getClass.getSimpleName vl.id shouldBe cc.id.get - vl.valueMap should contain("s" → cc.s) + vl.valueMap should contain("s" -> cc.s) } } diff --git a/gremlin-scala/src/test/scala/gremlin/scala/SchemaSpec.scala b/gremlin-scala/src/test/scala/gremlin/scala/SchemaSpec.scala index 9dcc86ef..243c5190 100644 --- a/gremlin-scala/src/test/scala/gremlin/scala/SchemaSpec.scala +++ b/gremlin-scala/src/test/scala/gremlin/scala/SchemaSpec.scala @@ -20,10 +20,10 @@ class SchemaSpec extends WordSpec with Matchers { "create vertices" in { val g = TinkerGraph.open.asScala - val v0 = g + (Software, Name → "blueprints", Created → 2010) - val v1 = g + (Software, Created → 2009, Name → "gremlin") - val v2 = g + (Software, Name → "gremlinScala") - val v3 = g + (Person, Name → "mpollmeier") + val v0 = g + (Software, Name -> "blueprints", Created -> 2010) + val v1 = g + (Software, Created -> 2009, Name -> "gremlin") + val v2 = g + (Software, Name -> "gremlinScala") + val v3 = g + (Person, Name -> "mpollmeier") g.V.toList().size shouldBe 4 g.V.hasLabel(Software).toList().size shouldBe 3 @@ -95,9 +95,9 @@ class SchemaSpec extends WordSpec with Matchers { object Distance extends Key[Int]("distance") val g = TinkerGraph.open.asScala - val paris = g + (City, Name → "paris") - val london = g + (City, Name → "london") - val rail = paris --- (EuroStar, Distance → 495) --> london + val paris = g + (City, Name -> "paris") + val london = g + (City, Name -> "london") + val rail = paris --- (EuroStar, Distance -> 495) --> london } } } diff --git a/gremlin-scala/src/test/scala/gremlin/scala/TraversalSpec.scala b/gremlin-scala/src/test/scala/gremlin/scala/TraversalSpec.scala index d867ecb8..c1da3343 100644 --- a/gremlin-scala/src/test/scala/gremlin/scala/TraversalSpec.scala +++ b/gremlin-scala/src/test/scala/gremlin/scala/TraversalSpec.scala @@ -223,8 +223,8 @@ class TraversalSpec extends WordSpec with Matchers { } yield (software.value2(Name), meanAge) softwareAndDevAges.toSet shouldBe Set( - "lop" → 32d, - "ripple" → 32d + "lop" -> 32d, + "ripple" -> 32d ) } } @@ -264,13 +264,13 @@ class TraversalSpec extends WordSpec with Matchers { val scala = graph + "scala" val groovy = graph + "groovy" - val michael = graph + (Person, Name → "michael") - val marko = graph + (Person, Name → "marko") + val michael = graph + (Person, Name -> "michael") + val marko = graph + (Person, Name -> "marko") - michael --- (Likes, Weight → 3) --> groovy - michael --- (Likes, Weight → 5) --> scala - marko --- (Likes, Weight → 4) --> groovy - marko --- (Likes, Weight → 3) --> scala + michael --- (Likes, Weight -> 3) --> groovy + michael --- (Likes, Weight -> 5) --> scala + marko --- (Likes, Weight -> 4) --> groovy + marko --- (Likes, Weight -> 3) --> scala val traversal = for { person <- graph.V.hasLabel(Person) @@ -278,8 +278,8 @@ class TraversalSpec extends WordSpec with Matchers { } yield (person.value2(Name), favorite.label) traversal.toMap shouldBe Map( - "michael" → "scala", - "marko" → "groovy" + "michael" -> "scala", + "marko" -> "groovy" ) } @@ -713,7 +713,7 @@ class TraversalSpec extends WordSpec with Matchers { .property(NewProperty, "someValue") .iterate() graph.V.hasLabel("newLabel").count.head shouldBe 2 - graph.V.has(NewProperty → "someValue").count.head shouldBe 2 + graph.V.has(NewProperty -> "someValue").count.head shouldBe 2 } }