A pattern usually has at least one parameter although this is not
a requirement. Parameters define the targeted argument's UML 2.0 type and
the acceptable multiplicity values. Each parameter is represented by a Java™ class
and contains the code instructions to perform the work accomplished by pattern
expansion.
You must create a pattern before you can perform these steps.
You can specify dependencies between parameters. When you assign
another parameter as a client or supplier parameter, it dynamically adds the
reciprocal assignment to the parameter you are adding. Thus, moving an existing
parameter into the Supplier Parameter field assigns
the role of client to the parameter you are adding.
To add a parameter
to a pattern:
- In the Pattern Authoring view, right-click
the pattern and click New Parameter. The New
Pattern Parameter wizard opens.
- Type a name for the parameter in the Name field. The class name is automatically derived from the parameter name.
- Accept the class name as generated, or modify it in the Class
Name field.
- Type a short description of the parameter that can assist the pattern
applier to specify arguments for the pattern. The short description
is displayed on the Short Description page of the Pattern
Explorer view and as hover help when the pattern applier hovers
over the template parameter on the diagram view.
- In the Type field, accept the UML 2.0 type
of Class for the parameter's type or click Browse and
select another UML 2.0 type.
- If the Allowable Subtypes field is enabled,
do one of the following:
- Go on to the next step. All subtypes will be available to the pattern
applier as possible kinds of arguments.
- Click Browse and select the subtypes that you
allow the pattern applier to choose as arguments for this parameter. For example,
for a classifier type, you can choose the subtypes of interface, class, activity,
and collaboration.
- Accept or clear the Allow text entry of argument value check
box that permits the applier to specify an existing argument or create new
argument elements by typing an argument name.
Note: For parameters
that you create with multiple subtype options, the subtype that
is created from the pattern applier's text entry is controlled by the code
you supply in the parameter's update method. If you do not supply this code,
a default subtype from your allowable subtypes list is selected.
- To add a parameter dependency, complete the following steps:
- Click the Parameter Dependency tab to
open the Parameter Dependency page.
- In the Existing Parameters field, click
one or more parameter names.
- Click a right-arrow button to move the parameter name into the Client
Parameter field or the Supplier Parameter field.
- Click the General tab to return to the
parameter definition or OK to close the wizard.
The parameter is added to the pattern. As you develop the pattern,
you can modify the parameter properties by using the Properties view.