Entry point rules

Entry point rules defines where the transformation starts execution. It is similar to a Java main.

It may have a context (in the example uml.Model), which defines what metamodel element type that will be the starting point for the execution. Its body contains statements.

uml.Model::main () { 
 
self.ownedMember->forEach(p:uml.Package)
  {
    p.mapPackage()
  }
}


An entry point rule will be executed based on the matching of the context type in the input model (s). In the example below, if the input model contains two classes, the entry point will be executed twice.
uml.Class::main() {
...
}

Entry point rules with no context type

Rules can be specified without context type, so also entry point rules. An entry point with no context type will be executed once.  It is specified using the module keyword or without any keyword. To retrieve model input using this approach, the model parameter to the transformation must be used, combined with the operation 'objectsOfType' to retrive contained model objects.
     
module::main () {
    uml.objectsOfType (uml.Package)
}

or

main () {
    uml.objectsOfType (uml.Package)
}