Book a Demo

Author Topic: Adding a collection as an attribute to a class  (Read 2194 times)

pwyss2

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Adding a collection as an attribute to a class
« on: November 01, 2012, 09:01:26 pm »
Hy

I've a class diagram with two classes (Class 'A' and Class 'B'). They've associated with each other (*..*).

How can I do the following:
- Adding an attribute to Class 'A' of type Collection<B> (I'm using Java, so in the generated code I need List<B>)
- Adding an attribute to Class 'B' of type Collection<A> (I'm using Java, so in the generated code I need List<A>)
- Use this two attributes for connecting the two classes

When I'm adding an attribute, for example List<B> to the Class 'A', in the Type-Field i can write a string like List<B> and when I generate the java-classes, all seems to be fine. But when I change for example the Name of the Class 'B' in the model to Class 'B1' -> the type of the attribute is not changed to List<B1> and remains List<B>, which is wrong...

Thanks for your help,
Peter

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding a collection as an attribute to a class
« Reply #1 on: November 01, 2012, 09:22:35 pm »
Try reverse engineering an existing class.

q.

pwyss2

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Adding a collection as an attribute to a class
« Reply #2 on: November 01, 2012, 11:40:23 pm »
When I do reverse engineering, I've the same behaviour:
- After importing the classes into EA -> When I change for example the Name of the Class 'B' in the model to Class 'B1' -> the type of the attribute on Class'A' is not changed to List<B1> and remains List<B>.

Any other suggestions or is this "by design"?

Kind regards,
Peter