With DSL customization, you can modify a model element to act according to your needs depending on the stereotype you apply.
Default values
Tags have default values. Use the default values when you create the tag, making sure its definition has multiplicity greater than zero. In this case it is automatically created when applying a stereotype.
Stereotypes on relationship ends
At times, DSL requires applying stereotypes to some elements after DSL relationship connection to those elements.
Use the following properties for this purpose:
Property | Description |
---|---|
Apply to Source | Specifies stereotypes that must be applied to the source element of this relationship after connection. |
Apply to Target | Specifies stereotypes that must be applied to the target element of this relationship after connection. |
Source and Target in an example
“Source” and “Target” are respectively the “source” and “target” of a directed relationship.
The first connected element acts as a“source” for a non-directed relationship.
Example:
- Create a stereotype «serve» and select the Dependency metaclass.
- Create two stereotypes «main» and «servant» and select the Element metaclass.
- Create a customization element.
- In the customization Specification window, specify the following property values:
- for the Customization Target property, select the «serve» stereotype,
- for the Apply To Source property, select the «main» stereotype,
- for the Apply To Target property, select the «servant» stereotype.
- Reopen the project. Draw the «serve» dependency from one element to another. The «main» and «servant» stereotypes are applied to these elements.
Required Generalization or Interface Realization
Sometimes DSL requires elements to be subtypes of a general abstract class or interface. Use the Super Types property for this purpose. The Super Types property specifies types to be super types of the DSL element. The Generalization or InterfaceRealization (if using an interface) will be created in the model after applying the customized stereotype.
Example
The following is an example of customization. Every JAVA class will be a subclass of the Object class. In other words, every Class marked with the «JAVAClass» stereotype is inherited from the Object.
Create a customization element.
In the customization Specification window, specify the Customization Target property as the «JAVAClass» stereotype.
In the customization Specification window, specify the Super Types property as the Object class.