Book a Demo

Author Topic: Aggregate Relationship -> Java Code  (Read 6014 times)

ea1844

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Aggregate Relationship -> Java Code
« on: July 16, 2008, 06:26:09 pm »
Hello,

I'm trying to generate Java source from a class diagram where Class1 has a collection of Class2 represented as an aggregate relationship (non-composite). I would like Class1 to contain a private array of Class2 but the aggregate indicating this relationship seems to only create a private member variable of type Class2 not Class2[].

When I force it by updating Class1.java to contain an array of Class2 and synchronize back to the model, a simple association is created and an attribute of type Class2[] is added to Class1 (this is reflected in the project browser). However, I now have both an aggregate and associate line between Class1 and Class2 but I only want the aggregate.

In the project browser, when I double click on the Class2 attribute in Class1, the attribute properties box is displayed. In the details tab I see that 'Attribute is a Collection' is checked and 'Container Type' is []. This is all very well and nice, but I would like this information to be associated with the aggregate notation not the association notation.

Cannot find any information on how to do this. Does anyone have any ideas?

Thanks,

Matthew

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Aggregate Relationship -> Java Code
« Reply #1 on: July 17, 2008, 08:30:23 am »
Look at Collection Classes and set one to '#TYPE#[]'.

ea1844

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Aggregate Relationship -> Java Code
« Reply #2 on: July 17, 2008, 10:03:03 am »
Quote
Look at Collection Classes and set one to '#TYPE#[]'.
Hello Simon,

Thanks for the reply. It now generates the correct Java private member attribute (i.e. an array of type Class2 is now generated in Class1 which is good). However, when I click on Class2 in the class diagram and pull up the right-click menu and select the 'Synchronize with Code' option, the class diagram is still updated with a new associate relationship line whereas there is already an aggregate relationship line present (between Class1 and Class2). This new associate line seems redundant as I want this relationship to be described only by the aggregate line. Am I doing something wrong?

Thanks,

Matthew
« Last Edit: July 17, 2008, 10:07:07 am by ea1844 »