Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Duplicate overloaded property
Duplicate overloaded property [message #901935] Wed, 15 August 2012 07:35 Go to next message
Alex G is currently offline Alex G
Messages: 96
Registered: January 2012
Member
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 09:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26014
Registered: July 2009
Senior Member
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.
Re: Duplicate overloaded property [message #902217 is a reply to message #901956] Thu, 16 August 2012 12:10 Go to previous message
Alex G is currently offline Alex G
Messages: 96
Registered: January 2012
Member
Thank you very much. Didn't know that ecore is able to define generics.
Previous Topic:[EMF-Databinding] Observe addition/removal changes in multi-value feature of a multi-value feature
Next Topic:EMF Compare - CompareServices?
Goto Forum:
  


Current Time: Wed Sep 03 04:56:03 GMT 2014

Powered by FUDForum. Page generated in 0.01524 seconds