Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Is a class type possible to extends A class type and implements B interface type?
Is a class type possible to extends A class type and implements B interface type? [message #787117] Tue, 31 January 2012 07:10 Go to next message
David BY Chan is currently offline David BY ChanFriend
Messages: 40
Registered: July 2009
Member
hi, I'm developing a visualized tool using EMF as its model. The ecore
model was generated by a XSD file.

Now I want to a class which can extends one class and implements another
interface. According to EMF definition, a class can only extends one via
super type, No multiple extension like C++ and no option to let it
implements an interface like Java.

For example:

ecore class IdentifiedObject, abstract:true, interface:true.
ecore operation: String getId()

ecore class Foo, abstract true
ecore attribute: String foo

ecore class Bar, super type: Foo
ecore attribute: String id;
ecore attribute: String bar;

I hope classes will be generated like below:

public interface IdentifiedObject extends EObject{
public String getId();
}

public interface Foo extends EObject{
...
}

public interface Bar extends Foo, IdentifiedObject{
.....
}
public abstract class FooImpl extends EObjectImpl{
...
}
public class BarImpl extends FooImpl implements IdentifiedObject{
...
}

I guess EMF annotation can help but it means changing a lot of JET
templates.

Need you help! Thank you!
Re: Is a class type possible to extends A class type and implements B interface type? [message #787125 is a reply to message #787117] Tue, 31 January 2012 07:22 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
David,

Comments below.

On 31/01/2012 8:10 AM, David Chan wrote:
> hi, I'm developing a visualized tool using EMF as its model. The ecore
> model was generated by a XSD file.
>
> Now I want to a class which can extends one class and implements
> another interface. According to EMF definition, a class can only
> extends one via super type,
No, EClass.eSuperTypes is multi-valued. Of course the generated Java
implementation class can only extend one other implementation class.
> No multiple extension like C++ and no option to let it implements an
> interface like Java.
No, you can define an EClass that wraps an existing Java interface and
then add it to the eSuperTypes of some other EClass.

Of course XSD itself supports only single inheritance but with
annotations like ecore:implements for multiple inheritance and
ecore:instanceType for defining complex types that act as wrappers you
could accomplish what you need.
>
> For example:
>
> ecore class IdentifiedObject, abstract:true, interface:true.
> ecore operation: String getId()
>
> ecore class Foo, abstract true
> ecore attribute: String foo
>
> ecore class Bar, super type: Foo
> ecore attribute: String id;
> ecore attribute: String bar;
>
> I hope classes will be generated like below:
>
> public interface IdentifiedObject extends EObject{
> public String getId();
> }
>
> public interface Foo extends EObject{
> ...
> }
>
> public interface Bar extends Foo, IdentifiedObject{
> .....
> }
> public abstract class FooImpl extends EObjectImpl{
> ...
> }
> public class BarImpl extends FooImpl implements IdentifiedObject{
> ...
> }
>
> I guess EMF annotation can help but it means changing a lot of JET
> templates.
I'd suggest working with Ecore directly to create the structure you want
and the exporting (from the *.genmodel) to XSD to see what annotations
are needed to produce from XSD the model you want in Ecore.
>
> Need you help! Thank you!
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Arithmetic Operations on EObjects / ELists
Next Topic:[CDO] stale reference during invalidation process
Goto Forum:
  


Current Time: Fri Apr 26 04:28:15 GMT 2024

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

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

Back to the top