Book a Demo

Author Topic: get/set method creation in Java code generation  (Read 11692 times)

Bruce Thomason

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
get/set method creation in Java code generation
« on: July 10, 2009, 05:15:07 am »
I am a fairly new EA user - so sorry if this is a lame question - am trying to generate code from a class model defined as Java with attributes - am assuming there is a way to automatically generate get/set methods from attributes.  Have tried to follow the MDA transformation process for Java as example in EA user manual suggests that's one way to accomplish this (to go from a PIM to a PSM).  Following this procedure does not yield any new get/set methods (or code changes at all) in code or in the model.  Any suggestions on settings to make sure are set or a process to follow?  
TIA, Bruce

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: get/set method creation in Java code generatio
« Reply #1 on: July 10, 2009, 08:42:19 am »
The transform creates properties for public attributes.  If you want it to create properties for all attributes you'll need to modify the transform template.

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: get/set method creation in Java code generatio
« Reply #2 on: July 10, 2009, 06:39:02 pm »
I have raised this before and it has always puzzled me. If the transformation process generates properties for public attributes (which are then private) in the Platform Independent Model, they why is the default scope (visibility) for attributes private when the gen langauge is set to <none>

Using this default prevents the transformation process generating the properties for the attributes. The only solution is to modify the transformation scripts, or laboriously go through all attributes changing their scope from private to public and then re-apply the transformation.

I would have thought it be more logical to set the default scope (visibility) for attributes to public when the gen language is set to <none>

This is especially odd since the default scope for a role (linked attributed) is public
Models are great!
Correct models are even greater!

Bruce Thomason

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: get/set method creation in Java code generatio
« Reply #3 on: July 10, 2009, 10:22:33 pm »
Thanks!

I suggest that Sparx consider adding a note to clarify to this point, e.g. to the page below, as I did study it for clues.  In retrospect, it was there but not so obvious - to me - from the diagrams that only public attributes were shown in the example's source and they were changed to private in the transform result - but words would help too! (just a thought)
http://www.sparxsystems.com.au/resources/mda/java_transformation.html

BTW - I am really impressed with EA overall - keep up the great work!