Skip to content

Commit

Permalink
rename PropertyKeys -> Properties (to minify diff and mental context) (
Browse files Browse the repository at this point in the history
…#214)

in odb's codegen these are calles Properties rather than PropertyKeys,
so to minify the diff (and mental context) let's keep it that way
  • Loading branch information
mpollmeier authored Jul 2, 2024
1 parent ad79979 commit 6dfa1cd
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/src/test/scala/flatgraph/GraphTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ class GraphTests extends AnyWordSpec with Matchers {
"node property accessors" in {
val Node0Label = "V0"

// PropertyKeys - these are normally generated by the DomainClassesGenerator based on the schema
// Properties - these are normally generated by the DomainClassesGenerator based on the schema
val propertySingle = new SinglePropertyKey[String](kind = 0, name = "propertySingle", default = "propertySingleDefault")
val propertyOptional = new OptionalPropertyKey[String](kind = 1, name = "propertyOptional")
val propertyMulti = new MultiPropertyKey[String](kind = 2, name = "propertyMulti")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class DomainClassesGenerator(schema: Schema) {
sourceLines.result().mkString("\n")
}

val propertyKeys = {
val properties = {
val sourceLines = Seq.newBuilder[String]
nodeType.properties.map { property =>
propertyKeySource(property, propertyKindByProperty(property))
Expand Down Expand Up @@ -518,8 +518,8 @@ class DomainClassesGenerator(schema: Schema) {
| object PropertyNames {
| $propertyNames
| }
| object PropertyKeys {
| $propertyKeys
| object Properties {
| $properties
| }
| object PropertyDefaults {
| $propertyDefaults
Expand Down Expand Up @@ -1121,12 +1121,12 @@ class DomainClassesGenerator(schema: Schema) {
propertyKeySource(property, propertyKind = kindContexts.propertyKindByProperty(property))
}
}.mkString("\n\n")
val file = outputDir / "PropertyKeys.scala"
val file = outputDir / "Properties.scala"
os.write(
file,
s"""package ${schema.basePackage}
|
|object PropertyKeys {
|object Properties {
|$propertyKeysConstantsSource
|}""".stripMargin
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package testdomains.generic

object PropertyKeys {
object Properties {
val IntList = flatgraph.MultiPropertyKey[Int](kind = 0, name = "int_list")

val IntMandatory = flatgraph.SinglePropertyKey[Int](kind = 1, name = "int_mandatory", default = 42: Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object NodeA {
val StringOptional = "string_optional"
val NodeB = "node_b"
}
object PropertyKeys {
object Properties {
val IntList = flatgraph.MultiPropertyKey[Int](kind = 0, name = "int_list")
val IntMandatory = flatgraph.SinglePropertyKey[Int](kind = 1, name = "int_mandatory", default = 42: Int)
val IntOptional = flatgraph.OptionalPropertyKey[Int](kind = 2, name = "int_optional")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object NodeB {

val StringOptional = "string_optional"
}
object PropertyKeys {
object Properties {
val StringOptional = flatgraph.OptionalPropertyKey[String](kind = 5, name = "string_optional")
}
object PropertyDefaults {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package testdomains.gratefuldead

object PropertyKeys {
object Properties {
val Name = flatgraph.SinglePropertyKey[String](kind = 0, name = "name", default = "")

val Performances = flatgraph.OptionalPropertyKey[Int](kind = 1, name = "performances")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Artist {

val Name = "name"
}
object PropertyKeys {
object Properties {
val Name = flatgraph.SinglePropertyKey[String](kind = 0, name = "name", default = "")
}
object PropertyDefaults {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object Song {

val Songtype = "songType"
}
object PropertyKeys {
object Properties {
val Name = flatgraph.SinglePropertyKey[String](kind = 0, name = "name", default = "")
val Performances = flatgraph.OptionalPropertyKey[Int](kind = 1, name = "performances")
val Songtype = flatgraph.OptionalPropertyKey[String](kind = 2, name = "songType")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package testdomains.hierarchical

object PropertyKeys {
object Properties {
val Name = flatgraph.SinglePropertyKey[String](kind = 0, name = "name", default = "<empty>")
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object NodeX {

val Name = "name"
}
object PropertyKeys {
object Properties {
val Name = flatgraph.SinglePropertyKey[String](kind = 0, name = "name", default = "<empty>")
}
object PropertyDefaults {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object NodeY {

val Name = "name"
}
object PropertyKeys {
object Properties {
val Name = flatgraph.SinglePropertyKey[String](kind = 0, name = "name", default = "<empty>")
}
object PropertyDefaults {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/flatgraph/GraphTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GraphTests extends AnyWordSpec with MockFactory {
val mockSchemaViolationReporter = mock[SchemaViolationReporter]
mockSchemaViolationReporter.illegalNodeProperty.expects(nodeA.nodeKind: Int, "UNKNOWN", schema)
mockSchemaViolationReporter.illegalNodeProperty.expects(nodeA.nodeKind: Int, 999, schema)
mockSchemaViolationReporter.illegalNodeProperty.expects(nodeB.nodeKind: Int, NodeA.PropertyKeys.IntOptional.kind, schema)
mockSchemaViolationReporter.illegalNodeProperty.expects(nodeB.nodeKind: Int, NodeA.Properties.IntOptional.kind, schema)
mockSchemaViolationReporter.illegalNodeProperty.expects(nodeB.nodeKind: Int, 998, schema)

val setProperties = new DiffGraphBuilder(schema, mockSchemaViolationReporter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class PathTraversalTests extends AnyWordSpec with FlatlineGraphFixture {

center.start.enablePathTracking.out
.sideEffectPF {
case node if node.property(NodeA.PropertyKeys.StringMandatory).startsWith("L") =>
case node if node.property(NodeA.Properties.StringMandatory).startsWith("L") =>
sack.addOne(node)
}
.out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import flatgraph.GNode
import flatgraph.TestGraphs.FlatlineGraphFixture
import testdomains.generic.GenericDomain
import testdomains.generic.language.*
import testdomains.generic.PropertyKeys.StringMandatory
import testdomains.generic.Properties.StringMandatory
import testdomains.generic.edges.ConnectedTo
import testdomains.generic.nodes.{NewNodeA, NodeA}
import org.scalatest.matchers.should.Matchers.*
Expand Down

0 comments on commit 6dfa1cd

Please sign in to comment.