You can associate stereotypes with UML metaclasses in custom UML
profiles. After you apply the custom profile to a model and apply the stereotype
to a model element, you can associate that element with model elements that
have the same metaclass as the association.
About this task
Unlike metaclass extensions that are included in the profile,
you cannot apply the stereotype to an element that has the same metaclass
as the association. Associating stereotypes with UML metaclasses in profiles
is helpful because, when you apply custom profiles, you can change which UML
relationships are valid in a specific domain.
For example, in a UML
model, a directed association from an actor to an interface is not a valid
relationship. However, you could create a custom profile that allows this
type of relationship by creating a stereotype such as <<employee>> that
extends the metaclass Actor, and by creating an association relationship from
that stereotype to the metaclass Interface. When you apply the custom profile
to a model, the relationship from actors stereotyped as <<employee>>
to interfaces is valid because the custom profile overrides the default UML
notation with this domain-specific construct.
To add a metaclass association
in a profile:
Procedure
- In the Project Explorer view, expand a project that contains a
custom UML profile that contains one or more stereotypes.
- Expand the Profiles folder, expand the profile, right-click a stereotype;
then click Add UML > Metaclass Association.
- In the Select Element window, select a metaclass for the association
and click OK.
Results
After you create the metaclass association, you can edit it the same
way as a stereotype attribute. To specify details such as visibility
and multiplicity, select the association in the Project Explorer view and
make the changes in the Properties view.
Restriction: After you
create a metaclass association, you cannot change its type to a different
metaclass.
Restriction: The aggregation of a metaclass association
cannot be composite.