Page tree

MagicDraw 19.0 LTR SP4 Documentation


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:

  1. Create a stereotype «serve» and select the Dependency metaclass.
  2. Create two stereotypes «main» and «servant» and select the Element metaclass. 
  3. Create a customization element.
  4. In the customization Specification window, specify the following property values: 
    1. for the Customization Target property, select the «serve» stereotype, 
    2. for the Apply To Source property, select the «main» stereotype, 
    3. for the Apply To Target property, select the «servant» stereotype. 
  5. 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.

  1. Create a customization element.

  2. In the customization Specification window, specify the Customization Target property as the «JAVAClass» stereotype.

  3. In the customization Specification window, specify the Super Types property as the Object class. 

  • No labels