Sparx Systems Forum

Enterprise Architect => Uml Process => Topic started by: SPars on August 14, 2008, 06:51:18 am

Title: Code Generation
Post by: SPars on August 14, 2008, 06:51:18 am
I've created the basic class with some attributes.  However, I want the system to generate my getters and setters.  The help file talks about going to tools-options-generate ... there is no such menu option.

Going to project - transform doesn't generate any get/set methods.

thoughts?
Title: Re: Code Generation
Post by: Eve on August 14, 2008, 08:28:48 am
The built-in C# and Java transformations take a public attribute, and convert it into a private attribute and public properties.  Other than this, you can click on the 'Property' checkbox in the attributes dialog for each attribute.
Title: Re: Code Generation
Post by: RoyC on August 14, 2008, 09:11:37 am
What release are you using? Whereabouts in the Help is this reference to the Tool | Options | Generate menu option? You are right, it doesn't exist, and there shouldn't be a reference to it. I can't find it, but it might be in an older version of the Help.
Title: Re: Code Generation
Post by: SPars on August 14, 2008, 11:22:05 pm
Think I actually found it on your site, not in the help menu.

I did find the answer with the property check box - thanks.

The next question I have is that the getters/setters are not cased out correctly.

String someValue;

String getsomeValue();

A member variable's name can be any legal Java identifier and by convention begins with a lower case letter.  However, the set/get methods should be:

getSomeValue();

Is there somewhere to set this?
Title: Re: Code Generation
Post by: «Midnight» on August 15, 2008, 05:12:37 am
Take a look at the Tools | Options | Source Code Generation dialog. Near the bottom you'll see an option for Capitalized Attribute Name for Properties. I think that's what you need to set.

I'm not sure whether EA stores this globally - in the registry - or on a per-model basis. If it is the latter case you'll need to set up a base project, edit EABase.EAP in your EA installation directory, or tweak the option for each relevant project.

David
Title: Re: Code Generation
Post by: SPars on August 15, 2008, 05:23:58 am
That is perfect - thanks for the help!