| [news.eclipse.tools.emf] Re: Default Value of an inherited EAttribute or EReference |
|
Guys, Comments below. Michael Mühlberg wrote: No, don't ever populate instance in the constructor. You must start values in their ground state because things like deserialization and the copier expect that.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 :) Yes, though the templates don't change much these days.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. Reference defaults are problematic.I didn't find any way to overwrite defaults only via modeling, one has to modify the generated code or the generation templates :( References don't support defaults at all.Ciao, Michael "John T.E. Timm" <johntimm@xxxxxxxxxx> wrote in message news:9af675507e16f9247052dde7c18e7de5$1@xxxxxxxxxxxxxxx... It's a bad idea though because such a thing will not behave like a proper default. It will appear to be eIsSet true and will be serialized.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. Best avoid it entirely... Or have just an operation on A with a name that is overloaded by the attribute in B...
|