Defining EOpposites on subclasses [message #42751] |
Sun, 04 November 2007 10:08  |
Eclipse User |
|
|
|
Originally posted by: marco.pantel.unibw.de
Hi everyone!
I have an abstract superclass and three subclasses of it.
Each of the subclasses has got two EReferences to the superclass.
I declared an EReference "container : superclass" in the superclass.
But now the ecore-editor won't let me choose this container-reference as
an EOpposite to one of the subclasses' references. It says "The opposite
must be a feature of the reference's type".
How can I solve this problem?
Do I have to declare three different types of container-references, one
for each subclass?
Regards, Marco
|
|
|
|
|
Re: Defining EOpposites on subclasses [message #43672 is a reply to message #42844] |
Tue, 20 November 2007 06:22  |
Eclipse User |
|
|
|
By having the class explicitly inherit from EObject in the model
(see my eContainer() posts)
Best, Philipp
Marco Pantel wrote:
> Hi Ed,
>
> sorry for posting the original question in the wrong list.
> But now that you mentioned the eContainer() method my questions turns
> into an OCL question. ;-)
> eContainer() is obviously a Java method. How can I use this method in
> any OCL query?
>
> Regards, Marco
>
>
> Ed Merks schrieb:
>> Marco,
>>
>> This doesn't really sound like an OCL question. Opposites must be
>> properly paired. You could define "container" to be a derived volatile
>> unchangeable reference in the base and implement it by reusing
>> EObject.eContainer(), which is the implicit opposite of all containment
>> references; the subclass references would then be unidirectional. Or
>> you could define three separate bidirectional references in the derived
>> classes and provide EOperations in the base that have the same matching
>> signature as the feature accessors, taking advantage of Java 5.0's
>> support for covariant return types.
>>
>>
>> Marco Pantel wrote:
>>> Hi everyone!
>>>
>>> I have an abstract superclass and three subclasses of it.
>>> Each of the subclasses has got two EReferences to the superclass.
>>> I declared an EReference "container : superclass" in the superclass.
>>> But now the ecore-editor won't let me choose this container-reference as
>>> an EOpposite to one of the subclasses' references. It says "The opposite
>>> must be a feature of the reference's type".
>>>
>>> How can I solve this problem?
>>> Do I have to declare three different types of container-references, one
>>> for each subclass?
>>>
>>>
>>> Regards, Marco
>>>
|
|
|
Powered by
FUDForum. Page generated in 0.22028 seconds