...
When you build an Ecore model, whether using the tree-based editor, Ecore tools diagram editor or Xcore text editor, you are actually building an object structure, a structure of so-called meta-objects (meta because they are at a conceptual level above the instances of the classes they model). E.g. in the example above, OrgUnit and Person are instances of the EClass, the name attribute is an instance of EAttribute and the workers and works-in references are instances of EReference. The figure below shows the standard class diagram notation (left) and the corresponding object diagram of the meta-objects (right).
There's a lot of detail in such a diagram, and all of them have to be right for the generated code to work as intended. A good editor helps a lot (see Editing Ecore models).
Class diagram | Object diagram of meta-objects |
---|
PlantUML Macro |
---|
abstract class Named {
String name
}
class OrgUnit extends Named {
void fire(Person person)
}
class Person extends Named {
}
OrgUnit "works-in" <--> "workers *" Person |
| PlantUML Macro |
---|
object "~#c1 : EClass" as Named {
name = "Named"
abstract = true
}
object "~#c1 : EAttribute" as nameAttr {
name = "name"
lower = 0
upper = 1
}
object "~#dt1 : EDataType" as EString {
name = "EString"
instanceClassName = "java.lang.String"
}
nameAttr --> "eType" EString
Named *--> "eStructuralFeatures" nameAttr
object "~#c2 : EClass" as OrgUnit {
name = "OrgUnit"
}
OrgUnit --> "eSuperTypes" Named
object "~#c3 : EClass" as Person {
name = "Person"
}
Person --> "eSuperTypes" Named
object "~#m1 : EOperation" as fire {
name = "fire"
}
object "~#p1 : EParameter" as personParam {
name = "person"
}
personParam --> "eType" Person
fire *--> "eParameters" personParam
OrgUnit *--> "eOperations" fire
object "~#r1 : EReference" as worksInRef {
name = "works-in"
lower = 0
upper = 1
}
worksInRef --> "eType" OrgUnit
Person *--> "eStructuralFeatures" worksInRef
object "~#r2 : EReference" as workersRef {
name = "workers"
lower = 0
upper = -1 // unbounded
}
workersRef --> "eType" Person
OrgUnit *--> "eStructuralFeatures" workersRef
workersRef "eOpposite" <--> "eOpposite" worksInRef |
|
There's a lot of detail in such a diagram, and all of them have to be right for the generated code to work as intended. A good editor helps a lot (see Editing Ecore models).