Search code examples
arrayscode-generationclass-diagramenterprise-architectobject-composition

Enterprise Architect code generation - compose - membervariable as array


I've this class diagram class diagram compose

and the multiplicity 1 : 0..*

The generated code from this model:

public class TestKlasseB {
    public TestKlasseB(){
    }
    ~TestKlasseB(){
    }
}//end TestKlasseB

public class TestKlasseA {
    public TestNameSpace.TestKlasseB m_TestKlasseB;    //this line
    public TestKlasseA(){
    }
    ~TestKlasseA(){
    }
}//end TestKlasseA

I would like the member variable in TestKlasseA as an array ( m_TestKlasseB )

public TestNameSpace.TestKlasseB[] m_TestKlasseB;

What I need to change?

--

Regards raiserle


Solution

  • You have two ways to do that.

    Either you define your association as an attribute (member variable) and got to its detail properties and select Attribute is a Collection with [] as type.

    Attribute as Collection

    Or you go to source code engineering options and add a default collection class (e.g. List<#TYPE#> ) there under your language (Ctrl + F9, Source code Engineering -> Java -> Default Collection Class). Default Collection class