Add New Stereotyped Templates

Sometimes it is useful to define a specific code generation template for use with elements of a given stereotype. This enables different code to be generated for elements, depending on their stereotype. Enterprise Architect provides some default templates, which have been specialized for commonly used stereotypes in supported languages. For example the Operation Body template for C# has been specialized for the property stereotype, so that it automatically generates its constituent get and set methods. Users can override the default stereotyped templates as described in the previous topic. Additionally users can define templates for their own stereotypes, as described below.

To add a new stereotyped template, follow the steps below:



See Also


Select the Configuration | Code Generation Templates menu option to open the Code Templates Editor.



Select the appropriate language, from the Language list.



Select one of the base templates, from the Templates list.



Click on the Add New Stereotyped Override button. The New Template Override dialog displays.



Select the required Feature and/or Class stereotype and click on the OK button.



The new stereotyped template override displays in Stereotype Overrides list, marked as modified.



Make the required modifications in the Code Templates Editor.



Click on the Save button. This stores the new stereotyped template in the .EAP file.


Enterprise Architect can now use the stereotyped template, when generating code for elements of that stereotype.

Note that Class and feature stereotypes can be combined to provide a further level of specialization for features. For example, if properties should be generated differently when the Class has a stereotype MyStereotype, then both property and MyStereotype should be specified in the New Template Override dialog.