The Eclipse UML2 project provides an implementation of the Unified Modeling Language (UML) 2.1 metamodel in Java. The fact that the underlying technology is the Eclipse Modeling Framework (EMF) makes it possible to use the EMFBuilder with the UML2 metamodel.
We use the UMLFactory for the EMFBuilder.
We create a model as the root node and then we create two primitive types and store them in Groovy variables because we have to reference them later on.
We define an enumeration OrderStatus with three literals.
The following code snippet shows the definition of the classes Address and USAddress. All the attributes are defined as a Property. The primitive types stringPrimitiveType and intPrimitiveType defined above are used. The class USAddress is a subclass of the abstract class Address. This is expressed with the Generalization object.
Compare this code to the original code in the article! The code is much more concise and is a direct representation of the UML2 diagram. No auxiliary methods are needed.
See the homepage of the UML2 Builder for further details.