|Previous||UML Classes||Table of Contents||UML Packages||Next|
A stereotype defines how an existing metaclass may be extended, and enables the use of platform or domain specific terminology
or notation in place of, or in addition to, the ones used for the extended metaclass.
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.
No additional attributes
• icon : Image [*] Stereotype can change the graphical appearance of the extended model element by using attached icons. When
this association is not null, it references the location of the icon content to be displayed within diagrams presenting the
extended model elements.
 A Stereotype may only generalize or specialize another Stereotype .
generalization.general->forAll(e | e.oclIsKindOf(Stereotype )) and
generalization.specific->forAll(e | e.oclIsKindOf(Stereotype ))
 Stereotype names should not clash with keyword names for the extended model element.
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.
Issue 7909 - Updating references to figures.
An instance S of Stereotype is a kind of (meta) class. Relating it to a metaclass C from the reference metamodel (typically
UML) using an Extension (which is a specific kind of association), signifies that model elements of type C
can be extended by an instance of S (see example Figure 18.13). At the model level (such as in Figure 18.18) instances
of S are related to C model elements (instances of C) by links (occurrences of the association/extension from S’ to C).
Any model element from the reference metamodel (any UML model element) can be extended by a stereotype. For example in UML,
States, Transitions, Activities, Use cases, Components, Attributes, Dependencies , etc. can all be extended with stereotypes.
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 model element. If multiple stereotypes
are applied, the names of the applied stereotypes are shown as a comma-separated list with a pair of guillemets. When the
extended model element has a keyword, then the stereotype name will be displayed close to the keyword, within separate guillemets
(example: «interface» «Clock»).
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 listing them after each other. A tool can choose whether it will display stereotypes or not. In particular,
some tools can choose not to display required stereotypes, but to display only their attributes (tagged values) if any.
Issue 8846 - discuss options of showing values for stereotype attributes
The values of a stereotyped element can be shown in one of the following three ways:
• As part of a comment symbol connected to the graphic node representing the model element
• In separate compartments of a graphic node representing that model element.
• Above the name string within the graphic node or, else, before the name string
In the case where a compartment or comment symbol is used, the stereotype name may shown in guillemets before the name string in addition to being included in the compartment or comment.The values are displayed as name-value pairs:
<namestring> ‘=’ <valuestring>
If a stereotype property is multi-valued then the <valuestring> is displayed as a comma-separated list:
<valuestring> ::= <value> [‘,’ <value>]*
Certain values have special display rules:
• As an alternative to a name-value pair, when displaying the values of Boolean properties, diagrams may use the convention that if the <namestring> is displayed then the value is True, otherwise the value is False;
• If the value is the name of a NamedElement then, optionally, its qualifiedName can be used.
If compartments are used to display stereotype values, then an additional compartment is required for each applied stereotype
whose values are to be displayed. Each such compartment is headed by the name of the applied stereotype in guillemets. Any
graphic node may have these compartments.
Within a comment symbol, or, if displayed before or above the symbols's <namestring>, the values from a specific stereotype
are optionally preceded with the name of the applied stereotype within a pair of guillemets. This is useful if values of more
than one applied stereotype should be shown.
When displayed in compartments or in a comment symbol, at most one name-value pair can appear on a single line. When displayed
above or before a <namestring>, the name-value pairs are separated by semicolons and all pairs for a given stereotype are
enclosed in braces.
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.
When a stereotype includes the definition of an icon, this icon can be graphically attached to the model elements extended
by the stereotype. Every model element that has a graphical presentation can have an attached icon. When model elements are
graphically expressed as:
Figure 18.14 on page 703): the box can be replaced by the icon, and the name of the model element appears
below the icon. This presentation option can be used only when a model element is extended by one single stereotype and when
properties of the model element (i.e., attributes, operations of a class) are not presented. As another option, the icon can
be presented in a reduced shape, inside and on top of the box representing the model element. When several stereotypes are
applied, several icons can be presented within the box.
Links: the icon can be placed close to the link.
Textual notation: the icon can be presented to the left of the textual notation.
Several icons can be attached to a stereotype. The interpretation of the different attached icons in that case is a semantic
variation point. Some tools may use different images for the icon replacing the box, for the reduced icon inside the box,
for icons within explorers, etc. Depending on the image format, other tools may choose to display one single icon into different
Some model elements are already using an icon for their default presentation. A typical example of this is the Actor model
element, which uses the stickman icon. In that case, when a model element is extended by a stereotype with an icon, the stereotype’s
icon replaces the default presentation icon within diagrams.
Issue 8735 - remove last sentence to allow values to be included
The first letter of an applied stereotype should not be capitalized.
In Figure 18.13, a simple stereotype
Clock is defined to be applicable at will (dynamically) to instances of the metaclass Class.
Issue 8847 - replace diagram adding more tags
Figure 18.13 - Defining a stereotype
Issue 8603 - add word ‘end’ after ‘extension’
, an instance specification of the example in Figure 18.13 is shown. Note that the extension
end must be
composite, and that the derived isRequired attribute in this case is false. Figure 18.15 shows the repository schema of the
clock defined in Figure 18.13.
In this schema, the extended instance (:Class; name = Class) is defined in the UML2.0 (reference metamodel) repository. In
a UML modeling tool these extended instances referring to the UML2.0 standard would typically be in a read only form, or presented
as proxies to the metaclass being extended.
(It is therefore still at the same meta-level as UML, and does not show the instance model of a model extended by the
stereotype. An example of this is provided in Figure 18.17 and Figure 18.18.) The Semantics sub section of the Extension
concept explains the MOF equivalent, and how constraints can be attached to stereotypes.
Issue 8848 -replace diagram to reflect changed example
ownedEnd, memberEnd memberEnd
Figure 18.15 - An instance specification when defining a stereotype
Figure 18.16 shows how
the same stereotype Clock can extend either the metaclass Component or the metaclass Class. It also shows how different stereotypes
can extend the same metaclass.
Issue 8849 -replace diagram to reflect changed example
Figure 18.16 - Defining multiple stereotypes on multiple stereotypes
Figure 18.17 shows
how the stereotype Clock, as
defined in Figure 18.16, is applied to a class called
Figure 18.17 - Using a stereotype
Figure 18.18 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.
Issue 8851 - replace figure to reflect updated example
Next, two stereotypes, Clock and Creator
, are applied to the same model element, as shown in Figure 18.19. Note that the
attribute values of each of the applied stereotypes can be shown in a comment symbol attached to the model element.
Issue 8851 - replace figure to reflect updated example
Figure 18.19 - Using stereotypes and showing values
Issue 8852 -add new example
Finally, two more alternative notational forms are shown in Figure 18.20.
«clock» OSVersion="1.1" startOperation=Start POSIXCompliant
Figure 18.20 - Other notational forms for depicting stereotype values
Changes from previous UML
In UML 1.3, tagged values could extend a model element without requiring the presence of a stereotype. In UML 1.4, this capability,
although still supported, was deprecated, to be used only for backward compatibility reasons. In UML 2.0, a tagged value can
only be represented as an attribute defined on a stereotype. Therefore, a model element must be extended by a stereotype in
order to be extended by tagged values. However, the required extension mechanism can, in effect, provide the 1.3 capability,
since a tool can in those circumstances automatically define a stereotype to which unattached attributes (tagged values) would