Setting Collection Classes

Return to Introduction  Previous page  Next page

Enterprise Architect enables you to define collection classes for generating code from association links where the target role has a multiplicity setting greater than 1. There are two options for doing this:

1.On the Source Code Engineering section of the Options dialog (select the Tools | Options | Source Code Engineering option), on each language page click on the Collection Classes button.
 
CodeLangCollClass
 
The Collection Classes for Association Roles dialog displays
 
AssocRoleContainers
 
On this dialog, you can define:
·The default collection class for 1..* roles
·The ordered collection class to use for 1..* roles
·The qualified collection class to use for 1..* roles.

 

2.On the Detail tab of the Class Properties dialog (accessible from the right-click context menu of any Class), click on the Collection Classes button.
 
AssocRoleClassDetail
 
The Collection Classes for Association Roles dialog again displays, but here you define for when only this Class is used:
·The default collection class for 1..* roles
·The ordered collection class to use for 1..* roles
·The qualified collection class to use for 1..* roles.

When Enterprise Architect generates code for a link that has a multiplicity role >1, the collection class is calculated as follows:

1.If the Qualifier is set use the qualified collection:
·for the Class if set
·else use the code language qualified collection.
2.If the Order option is set use the ordered collection:
·for the Class if set
·else use the code language ordered collection
3.Else use the default collection:
·for the Class if set
·else use the code language default collection.

Note: You can include the marker #TYPE# in the collection name; Enterprise Architect replaces this with the name of the Class being collected at source generation time (eg. Vector<#TYPE#> would become Vector<foo>).

Additionally, on both the Source Role and Target Role tabs of the Association Property dialog (accessible from the right-click context menu of any Association) there is a Member Type field. If you set this, the value you enter overrides all the above options. The example below shows a defined PersonList; when code is generated, because this has a Multiplicity greater than 1 and the Member Type is defined, the variable created is of type PersonList.

AssociationPropertiesDialog