Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EMF/Recipes
< EMF
Revision as of 19:44, 11 August 2007 by Eclipse.rc.gmail.com (Talk | contribs) (EMF recipes - first recipe)
This topic gathers recipe-style solutions for common needs developers using EMF face.
Code generation
Recipe: Generating EMF-free API
Problem
You want to generate code from an EMF model but you don't want any references to EMF types in your API.
Solution
In your genmodel:
- set the 'Suppress EMF Types' property to 'true' and standard Java types will be used rather than EMF types for all operations;
- clear or set the value of the 'Root Extends Interface' generator model property. If cleared the generated domain API will not depend on anything, or it can be set to an interface of your choosing
- the 'Root Extends Class' and 'Root Implements Interface' properties allow you to control the generation of the implementation. But if you clear the first or set it so the generated implementation is not a subclass of EObjectImpl the generated code will be invalid as it will have unresolved references to inherited methods that will not be available, such as eGet, eSet, eUnset, eIsSet and eIsProxy. Generating an implementation that is EMF-free is not possible with the default templates.
Related recipes
None so far.
References
- Thread on the EMF newsgroup: "Alternative superclass to EObject"