|
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 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.02958 seconds