EMF and final filed initialization [message #478910] |
Fri, 07 August 2009 13:00 |
Manuel Selva Messages: 189 Registered: July 2009 Location: Grenoble, France |
Senior Member |
|
|
Hi all,
I am modeling a class with two final (regarding Java) fields, i.e two fields that can't be modified after object's creation.
I saw a changeable attribute in EMF code generator allowing me to not generate setter for these fields.
It works but i am not able to set these fields ....
How should I work witn non changeable fields ? Can you point me to the documention about that ?
Thanks in advance
Manu
http://manuelselva.wordpress.com/
|
|
|
|
|
Re: EMF and final filed initialization [message #478933 is a reply to message #478917] |
Fri, 07 August 2009 14:37 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Manu,
Comments below.
Manuel Selva wrote:
> Hi Ed,
>
> Once again, thanks for your quick and clear answer.
>
> I guess I will not set the changeable attribute to false and carefully
> ALWAYS set this two ("final") attributes after creating them using the
> generated factory.
Yes. You might add a factory method where the two feature's values are
specified as arguments as a convenience...
>
> Is it the "right" way to do ?
Yes.
>
> Note: I was reviewing some part of my code after reading the excellent
> "Effective Java" book and was trying to apply it. Here it concerns the
> item 15 "Minimize mutability" but it seems, as you said, this item is
> not compatible with EMF framewrok.
Yes, not so much.
>
> Regards,
>
> Manu
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03543 seconds