A collection association relationship is suitable to illustrate that a class property is a collection of some kind. For example, in the diagram below, the property colors of the class ColorBox is a list of colors. This type is defined in this case as an enumeration; however, it may also be another class or even an interface.
Before you can create collection associations, the UModel project must contain the collection templates for the project language you want to use (such as Java, C#, or VB.NET). Otherwise, a tooltip with the text "No collections defined for this language" appears when you attempt to create the collection association.
If your project is UML only (without support for a specific code engineering language), you can define collection templates from the menu Tools | Options | Diagram Editing | Collection Templates | UML tab.
If your project already contains a language namespace (such as Java, C#, VB.NET), the collection templates are predefined from the profile of that language. Additional templates can be added from the menu Tools | Options | Diagram Editing | Collection Templates.
To create a collection association (between two classes, for example):
|1.||Add two classes to the diagram.|
|2.||Click the Collection Association toolbar button.|
|3.||Drag from the first class and drop it onto the second class. The collection templates defined for the project appear in the context menu, and you can select the required one.|
Collection associations and code engineering
If you import program code into the model, collection associations are created automatically by default, based on predefined collection templates. To enable or disable this option:
|1.||On the Tools menu, click Options.|
|2.||Click the Diagram Editing tab.|
|3.||Select or clear, as necessary, the check box Resolve collections.|
The collection associations are resolved by default based on a list of built-in collection templates. To view or modify the built-in collection templates, click Collection Templates.
To to insert custom collection types, use the Append, Insert, or Delete buttons available in the dialog box below. The column Par.Pos. denotes the position of the parameter which contains the value type of the collection.
Collection Templates dialog box
To reset the collection templates to their default values, click Set default.
© 2019 Altova GmbH