Description
Stereotype is a kind of Class that extends Classes through Extensions.
Just like a class, a stereotype may have properties, which may be referred to as tag definitions. When a stereotype is
applied to a model element, the values of the properties may be referred to as tagged values.
Attributes
No additional attributes.
Associations
No additional associations.
Constraints
self.generalization.general->forAll(e | e.oclIsKindOf(Stereotype)) and
self.specialization.specific->forAll(e | e.oclIsKindOf(Stereotype))
not self.isAbstract implies self.extensionEnd->union(self.parents.extensionEnd)->notEmpty()
Semantics
A stereotype is a limited kind of metaclass that cannot be used by itself, but must always be used in conjunction with one
of the metaclasses it extends. Each stereotype may extend one or more classes through extensions as part of a profile.
Similarly, a class may be extended by one or more stereotypes.
An instance of a stereotype is linked to an instance of an extended metaclass (or stereotype) by virtue of the extension
between their types.
Notation
A Stereotype uses the same notation as a Class, with the addition that the keyword «stereotype» is shown before or above
the name of the Class.
When a stereotype is applied to a model element (an instance of a stereotype is linked to an instance of a metaclass), the
name of the stereotype is shown within a pair of guillemets above or before the name of the Stereotype. If multiple
stereotypes are applied, the names of the applied stereotypes is shown as a comma-separated list with a pair of guillemets.
Presentation Options
If multiple stereotypes are applied to an element, it is possible to show this by enclosing each stereotype name within a
pair of guillemets and list them after each other.
The values of a stereotype that has been applied to a model element can be shown as part of a comment symbol tied to
the model element. The values from a specific stereotype are optionally preceded with the name of the applied stereotype
within a pair of guillemets, which is useful if values of more than one applied stereotype should be shown.
If the extension end is given a name, this name can be used in lieu of the stereotype name within the pair of guillemets
when the stereotype is applied to a model element.
It is possible to attach a specific notation to a stereotype that can be used in lieu of the notation of a model element to
which the stereotype is applied.
Style Guidelines
The first letter of an applied stereotype should not be capitalized. The values of an applied stereotype are normally not
shown.
Examples
In Figure 117, a simple stereotype Clock is defined to be applicable at will (dynamically) to instances of the metaclass
Class.
Note that in order to be able to write constraints on the stereotype Clock that should be applied to the metaclass Class or
any of its relationships, it is necessary to give the end typed by the metaclass a name for navigation purposes. A typical
such name would be for example base.
In Figure 118, an instance specification of the example in Figure 117 is shown. Note that the extension must be
composite, and that the the derived required attribute in this case is false.
In Figure 119, it is shown how the same stereotype Clock can extend either the metaclass Component or the metaclass
Class. It is also shown how different stereotypes can extend the same metaclass.
Figure 120 shows how the stereotype Clock, as defined in Figure 119, is applied to a class called StopWatch.
Figure 121 shows an example instance model for when the stereotype Clock is applied to a class called StopWatch. The
extension between the stereotype and the metaclass results in a link between the instance of stereotype Clock and the
(user-defined) class StopWatch.
Next, two stereotypes, Clock and Creator, are applied to the same model element, as is shown in Figure 122. Note that the
attribute values of each of the applied stereotypes can be shown in a comment symbol attached to the model element.