Book a Demo

Author Topic: How to disable member generation for iterfaces?  (Read 3109 times)

ebeb

  • EA User
  • **
  • Posts: 169
  • Karma: +0/-0
    • View Profile
How to disable member generation for iterfaces?
« on: March 31, 2010, 02:26:28 am »
Hi,

I'm still struggeling with code generation. Since now the transformation works (as far as I can see), I ran the code generation and imported it in NetBeans.

I saw that EA generates private member variables like e.g...
Code: [Select]
private ProtocolListener m_ProtocolListener;...if you have a directed association in the current class to (in this case) an interface called ProtocolListener.

But obviously, private methods are not allowed in interfaces. Actually, I don't want them at all.

So how can I disable it. I only found a way to do so for undirected associations.

Thanks,

Jan
« Last Edit: March 31, 2010, 02:27:40 am by ebeb »

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: How to disable member generation for iterfaces
« Reply #1 on: March 31, 2010, 09:02:40 am »
In "Linked Attribute" Transformation Template(Java), add

%if linkAttAccess == "private"%
%endTemplate%

before
%Properties($name,$type)% call,

 which will avoid any get/set operation generation for associations with "private" scope.


if you'd just like to avoid them in the generated code,
in "Linked Attribute Declaration" code generation template (Ctrl + Shift + P)

replace
%CONVERT_SCOPE(linkAttAccess)%

with

$sAccess = %CONVERT_SCOPE(linkAttAccess)%
%if $sAccess == "private"%
%endTemplate%

or force "public" scope instead.('cos the getter and setters will refer to m_#VAR#, if generated through transformation)

HTH
« Last Edit: March 31, 2010, 09:33:09 am by nizammohamed »