Generated collection access [message #652190] |
Wed, 02 February 2011 18:05  |
Eclipse User |
|
|
|
Hi,
Just wondering why, when a multiplicity-many reference is declared on an
entity, that to add an entry to the collection on the generated source
model class you have to call <sourceclass>.get<collection>.add(element); as
opposed to <sourceclass>.addTo<collection>(element); ?
Is there something that outweighs the possible downside of having direct
references to the mutable "internals" of the containing class?
Thanks,
Dan
|
|
|
Re: Generated collection access [message #652197 is a reply to message #652190] |
Wed, 02 February 2011 19:40  |
Eclipse User |
|
|
|
Dan,
Comments below.
Dan Pollitt wrote:
> Hi,
>
> Just wondering why, when a multiplicity-many reference is declared on an
> entity, that to add an entry to the collection on the generated source
> model class you have to call <sourceclass>.get<collection>.add(element); as
> opposed to <sourceclass>.addTo<collection>(element); ?
>
No doubt you'd need a remove method too. Also, you might need to add it
to a specific position in the list (e.g., suppose you were modeling the
parameters of a method), so you'd need another overloaded add method
with an index. As you discovered more and more things you kind of need,
you'd end up with the flattened out list API with clear(), removeAll,
addAll(), and so on.
> Is there something that outweighs the possible downside of having direct
> references to the mutable "internals" of the containing class?
>
You don't have access to internals, you're only using the public list
API with no knowledge of implementation internals.
> Thanks,
> Dan
>
|
|
|
Powered by
FUDForum. Page generated in 0.03709 seconds