Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Defining EOpposites on subclasses
Defining EOpposites on subclasses [message #42751] Sun, 04 November 2007 15:08 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
>>
Re: Defining EOpposites on subclasses [message #43672 is a reply to message #42844] Tue, 20 November 2007 11:22 Go to previous message
Philipp Kutter is currently offline Philipp KutterFriend
Messages: 306
Registered: July 2009
Senior Member
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
>>>
Previous Topic:accessing dynamic eobject api + function libraries
Next Topic:eContainer()
Goto Forum:
  


Current Time: Thu Apr 25 17:12:25 GMT 2024

Powered by FUDForum. Page generated in 0.03320 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top