|
Re: EReference Overloading and genmodel [message #420868 is a reply to message #420866] |
Tue, 15 July 2008 11:35 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Olivier,
Comments below.
Olivier PATRY wrote:
> Hi,
>
> I'm currently working on a project which uses code generation from an
> Ecore meta model.
>
> Typically, I want to put EReference overloading and make a genmodel on
> it but it fails.
>
> Let's see an example:
>
> A---bs->B A associates with B with an EReference named "bs"
> A<|----A1 A1 herits from A
> A<|----A2 A2 herits from A
> B<|----B1 B1 herits from B
> B<|----B2 B2 herits from B
> A1---bs->B1 A1 associates with B1 with an EReference named "bs",
> hiding the A---bs->B EReference for specialization.
Think of an EReference like a field in Java, not like a method in Java.
Defining a reference in a derived class is like defining a field in a
derived class, i.e., it introduce a new field and you'd need differently
named methods if you wanted to be able to access each of the two fields
you've defined.
>
> So, when creating a genmodel on it, I get the error:
>
> There may not be two features named "bs"
>
>
> How could I use EReference overloading/hiding?
You can't. If you want, you can define an EOperation in A1 to
specialize the signature, but keep in mind that EList<B1> getBS() from
A1 cannot override EList<B> getBS from A so what you're trying to do
can't be expressed in Java. You'd need to have EList<? extends B> getBS
in A to be able to do EList<B> getBS in A1 and if you did that, you
wouldn't be able to add a B to A's getBS.
So the bottom line is that you use operations to do overloading and
features (references and attributes) to declare fields with associated
accessors. If you want to do fancy overloading, you'll need to resort
to using operations.
>
> Thanks, bye
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.07728 seconds