Set Collection Classes

Enterprise Architect enables you to define Collection Classes for generating code from Association connectors 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.
  1. 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 connector 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.
  1. If the Order option is set use the ordered collection:
  • for the Class if set
  • else use the code language ordered collection.
  1. 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 (for example, 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.

AssocPropDlg