Defining EOpposites on subclasses [message #42751] |
Sun, 04 November 2007 15: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 #42782 is a reply to message #42751] |
Sun, 04 November 2007 15:43 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
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
>
|
|
|
Re: Defining EOpposites on subclasses [message #42844 is a reply to message #42782] |
Mon, 05 November 2007 16:53 |
Eclipse User |
|
|
|
Originally posted by: marco.pantel.unibw.de
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.02941 seconds