Following the UML rules, the pattern type determines the allowable target element types in pattern application. For example, you can successfully apply a package type of pattern to a UML package or to a UML model (a model is a type of package).
The following list shows the allowable target types based on the pattern type:
During design, the pattern author can limit the allowable target types by clearing the options in the New Pattern wizard. For example, the default targets for a collaboration type pattern can be limited to classes.
In addition to following UML rules, one of two default behaviors occurs in pattern application. A pattern instance is added to the target element as a child node or the target element is modified to become the pattern instance. The behavior depends on the pattern author's design and the UML type of the target element.
The following table shows the default application behaviors based on the pattern type.
| Pattern type | ||||
|---|---|---|---|---|
| Package type | Collaboration type | Class type | ||
Target element in UML model |
Package target | Adds a package type pattern instance to the target. | Adds a collaboration type pattern instance to the target. | Adds a class type pattern instance to the target. |
| Collaboration target | Not allowed. | Changes the target collaboration into a pattern instance of type collaboration; adds pattern parameters to the instance. | Not allowed. | |
| Class target | Not allowed. | Adds a collaboration type pattern instance to the target. | Modifies the target class by adding a pattern stereotype. Does not add any of the pattern's parameters. | |
A pattern definition reference model is created when the pattern author, using the Pattern Authoring view, adds a pattern and its pattern parameters to a pattern library. Each pattern in the pattern library has its own pattern definition reference model. The pattern definition reference model is a represented by a UML element with a keyword of Pattern Definition. Depending on the pattern type, it is a parameterized collaboration, class, or package. The pattern author should not directly modify the pattern definition reference model. A new pattern definition reference model can be regenerated if it gets out of sync with the pattern's Java™ code.
In the pattern application process, the pattern definition reference model provides essential model information. Although not readily visible to the pattern applier, the pattern definition reference model is bound to all generated pattern instances.