[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Default Value of an inherited EAttribute or EReference

Hello John,

I would suggest to change the constructor of the generated impl class for B 
and set the value there. Take into account that the attribute can be 
unsettable. In this case you also have to change the generated change 
tracking variable from which I currently don't know the name :)

As far as I know there is no generator include template foreseen for 
changing the generation of constructor code. Taking the original templates 
and modifying them is problematic because in this case you have to merge all 
future changes therein.

I didn't find any way to overwrite defaults only via modeling, one has to 
modify the generated code or the generation templates :(

Ciao, Michael



"John T.E. Timm" <johntimm@xxxxxxxxxx> wrote in message 
news:9af675507e16f9247052dde7c18e7de5$1@xxxxxxxxxxxxxxxxxx
>I have two classes A and B. B is a subclass of A. B inherits an attribute 
>from A and I want to default the value of this attribute when B is 
>constructed.
>
> A : EClass
>  attr : EAttribute
>
> B -> A : EClass
>  attr := 'someDefaultValue' : EAttribute
>
> What is the best way to set the default value of an inherited EAttribute 
> or EReference? My guess is that I need to extend code generation to pick 
> up an annotation attached to an EClass and generate some initialization 
> code in the constructor. Does such an annotation already exist? Is there a 
> more automated way of accomplishing this?
>
> Thanks,
>
> JT
>