Duplicate overloaded property [message #901935] |
Wed, 15 August 2012 03:35  |
Eclipse User |
|
|
|
Hi!
I have an ecore model A which shall describe some common abstract classes for other concretized ecore models. Here I have a class
* Identifier with an attribute "id" of type EString
* AbstrClass with a reference called "name" to an Identifier
In a concretized ecore model B I have a class
* ExtendedIdentifier which extends Identifier from A
* ConcrClass which extends AbstrClass.
Now I want also to assure, that the "name" attribute shall be a reference to ExtendedIdentifier. If I add such a reference, then I get a validation error, since I have two "name" attributes.
In order to overcome this I could of course write two operations "getName" and "setName(ExtendedIdentifier)" with according explicit casts. There extra operations will of course pollute my metamodel, since I would need them very often.
Is there a better (or another) way to solve this (expectively common) problem?
Thank you in advance!
Best regards,
Alex.
|
|
|
Re: Duplicate overloaded property [message #901956 is a reply to message #901935] |
Wed, 15 August 2012 05:58   |
Eclipse User |
|
|
|
Alex,
There are several possibilities. You can hand modify the implementation
classes or interfaces with what you need. You can define operations to
do the equivalent; it's possible to suppress their visibility in the API
(see EcoreUtil.setSuppressedVisibility for how the annotation looks). Or
you could use generics, e.g., AbstClass has a parameter <T extends
Identifier> and make the reference of type T; then in ConcrClass you can
specify AbstrClass<ExtendedIdentifier>.
On 15/08/2012 9:35 AM, Alex G wrote:
> Hi!
>
> I have an ecore model A which shall describe some common abstract
> classes for other concretized ecore models. Here I have a class
> * Identifier with an attribute "id" of type EString
> * AbstrClass with a reference called "name" to an Identifier
>
> In a concretized ecore model B I have a class
> * ExtendedIdentifier which extends Identifier from A
> * ConcrClass which extends AbstrClass.
>
> Now I want also to assure, that the "name" attribute shall be a
> reference to ExtendedIdentifier. If I add such a reference, then I get
> a validation error, since I have two "name" attributes.
> In order to overcome this I could of course write two operations
> "getName" and "setName(ExtendedIdentifier)" with according explicit
> casts. There extra operations will of course pollute my metamodel,
> since I would need them very often.
> Is there a better (or another) way to solve this (expectively common)
> problem?
>
> Thank you in advance!
> Best regards,
> Alex.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04835 seconds