Book a Demo

Author Topic: Generate Source Code: Association: Java  (Read 3097 times)

Rafael Santini

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Generate Source Code: Association: Java
« on: July 15, 2012, 12:45:06 am »
For the following class diagram I would like to generate the code of association as a property (JavaBeans convention -- getter and setter methods for access attribute). For example:



public class Class1 {

  private Class2 foo;

  public Class2 getFoo() {
    return foo;
  }

  public void setFoo(Class2 foo) {
    this.foo = foo;
  }

}

public Class2 {

}


How can I do?
« Last Edit: July 15, 2012, 01:20:46 am by rafaelsantini »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Generate Source Code: Association: Java
« Reply #1 on: July 16, 2012, 09:21:42 am »
If foo were an attribute instead of (or as well as) an association end, then you would find a "Property" option in its Properties dialog that does what you need. If you select Class1 and press F11 to generate code then select Class1 and F7 to synchronize, EA will create the attribute.
The Sparx Team
[email protected]

Rafael Santini

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Generate Source Code: Association: Java
« Reply #2 on: July 16, 2012, 11:50:04 am »
Foo is an association. An association can't be coded as a property?