Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Inheritance of EOperations
Inheritance of EOperations [message #431434] Thu, 09 July 2009 11:32 Go to next message
Ralf Grossklaus is currently offline Ralf GrossklausFriend
Messages: 20
Registered: July 2009
Location: Stuttgart, Germany
Junior Member
Hello,

I've modeled 2 classes, ClassA and ClassB, in a small EMF model. ClassA
is set as the super type of ClassB. Both classes have an EOperation
called "doSomething()". When i generate the model code, i noticed that
doSomething() is contained in both interfaces, but only the impl class
of the super type (ClassAImpl.java) has an implementation of the method.

I know, since ClassBImpl extends ClassAImpl it inherits it's
implementation. But the reason why added doSomething to both classes is
because i'd like to override the implementation of ClassA. So my
question is, why does the generator create an operation in the interface
(The ClassB interface extends ClassA, so it inherits the method anyway),
and why doesn't it create one in the implementation classes.

Maybe a second question: Is there a way to generate the method in both
implementation classes?

thanks, Ralf
Re: Inheritance of EOperations [message #431437 is a reply to message #431434] Thu, 09 July 2009 13:31 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
Ralf,

Comments below.


Ralf Grossklaus wrote:
> Hello,
>
> I've modeled 2 classes, ClassA and ClassB, in a small EMF model.
> ClassA is set as the super type of ClassB. Both classes have an
> EOperation called "doSomething()". When i generate the model code, i
> noticed that doSomething() is contained in both interfaces, but only
> the impl class of the super type (ClassAImpl.java) has an
> implementation of the method.
Yes, I would expect that.
>
> I know, since ClassBImpl extends ClassAImpl it inherits it's
> implementation. But the reason why added doSomething to both classes
> is because i'd like to override the implementation of ClassA.
You can still do that.
> So my question is, why does the generator create an operation in the
> interface (The ClassB interface extends ClassA, so it inherits the
> method anyway),
Because you told it to by declaring it explicitly when there's no need.
> and why doesn't it create one in the implementation classes.
Given you've not defined a body, it would generate a stub that throws an
exception, which doesn't seem at all useful.
>
> Maybe a second question: Is there a way to generate the method in both
> implementation classes?
You can defined a body annotation (GenModel.eNS_URI as source and body
key with a body value) and you can suppress the operation from the
interface as produced by (EcoreUtil.setSuppressedVisibility).
>
> thanks, Ralf
Previous Topic:Bug in validation with ecore model in 3.5 : "containment or bidirectionnal reference must be un
Next Topic:[Teneo] No longer need EMFTupelizer override?
Goto Forum:
  


Current Time: Thu Dec 12 18:23:51 GMT 2019

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

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

Back to the top