-
Notifications
You must be signed in to change notification settings - Fork 0
1. Ecore Model CodeGen
EMF already offers a code generator for the generation of model code from Ecore metamodels. Therefore this part of the Ecorification relies, like the Metamodel extraction itself, heavily on the Ecore API.
To generate the model code, an Ecore GenModel
has to be created for the metamodel. This generator model contains additional information for the model code generation. The creation of a GenModel is implemented in the class GenModelGenerator
, while the API calls for the model code generation are implemented in the class ModelCodeGenerator
.
The class GenModelGenerator
allows creating GenModels with the method generate()
. The method takes a GeneratedEcoreMetamodel
as the parameter. A GenModelGenerator
can be initialized with default values and with custom
values. The values affect the GenModel configuration. The default values are:
complianceLevel = GenJDKLevel.JDK80_LITERAL;
importerID = "org.eclipse.emf.importer.ecore";
rootExtendsClass = "org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container";
xmlEncoding = "UTF-8";
The class ModelCodeGenerator
generates code from an existing GenModel
with the help of the Ecore API class org.eclipse.emf.codegen.ecore.generator.Generator
. To do this, one has to call generate(GenModel genModel)
with a valid GenModel as parameter.
The class utilizes the class MonitorToLoggerAdapter
to feed the output stream of the code generation into a log4j logger. This allows receiving information about the generation process.