|
|
|
Re: Implementing Setters for Derived references [message #425170 is a reply to message #425165] |
Tue, 18 November 2008 06:54 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Andrew,
It's not quite ready yet...
Andrew H wrote:
> Thanks Tristan
>
> I thought that bugzilla was still a bit of an R&D project, not ready
> for general use.
>
> Are you saying that some part of it is ready for use?
>
> thanks
>
> Andrew
>
> Tristan FAURE wrote:
>
>> Hi !
>> maybe you should use mechanism described in this bug :
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=216701
>
>> for more information Ed merks or Christian W Damus will more capable
>
>
>> Andrew H a écrit :
>>> I have a base class which contains a list of products (0 to many)
>>>
>>> I have a whole sub set of these which always take 2 products and
>>> these products are a sub type of Product. For convenience
>>> (particularly for ocl) I want to add two derived references for these
>>>
>>> i.e.
>>>
>>> class Base
>>> EList<Product> products
>>>
>>> class TwoFooProducts extends Base
>>> FooProduct p1; // derived from products.get(0)
>>> FooProduct p2; // derived from products.get(1)
>>>
>>> To implement this I set p1 & p2 as derived, transient and volatile.
>>> I then need to provide implementations of getP1(), basicSetP1() and
>>> setP1 & similar for p2. Not entirely sure what I should be doing in
>>> the setters in regards to the NotificationChain?
The list implements InternalEList which has the methods you need. One
problem though is you can't use inverseAdd/inverseRemove with a position
and of course you can't set the second item of the list if the first
doesn't exist yet.
>>>
>>> e.g. I've so far implemented basicSetP1 as follows but suspect this
>>> is not correct.
>>>
>>> public NotificationChain basicSetP1(FooProduct newP1,
>>> NotificationChain msgs)
>>> {
>>> if (getProduct().size() == 0)
>>> getProduct().add(newP1);
>>> else
>>> getProduct().set(0, newP1);
>>> return msgs;
>>> }
>>>
>>> public void setP1(FooProduct newP1)
>>> {
>>> basicSetP1(newP1, null);
>>> }
>>>
>>>
>>> How should I have implemented these?
>>>
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04460 seconds