EMF and final filed initialization [message #478910] |
Fri, 07 August 2009 09:00  |
Eclipse User |
|
|
|
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
|
|
|
|
|
Re: EMF and final filed initialization [message #478933 is a reply to message #478917] |
Fri, 07 August 2009 10:37  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.10355 seconds