Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Extend EAttributeImpl
Extend EAttributeImpl [message #1775600] Thu, 02 November 2017 06:11 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 25
Registered: January 2016
Junior Member
Hi there,

I have a use case where attributes not only have a value but an additional status field with an enum and maybe even more properties (for example two values and the status determines which value is the actual one).
Of course, my custom attribute would require to serialize all this information to XML.

It's a little odd usecase, but I was interested if there is some extension mechanism in EMF to achieve that.

I.e. for classes I could add a different Implementation of EObjectImpl in the "Root Extends Class" field. However, this is only a single setting for the whole model and cannot be done per class.
Still, for EAttributes there seems no option to change the implementation of the EAttribute, neither for the whole model nor for a single attribute.

Is an EDataType suitable for that? Does it make sense to create custom Data Types that are similar to Attributes with my additional behaviour/structure? Seems quite effort prone/brittle.

Cheers,
Hauke

Re: Extend EAttributeImpl [message #1775612 is a reply to message #1775600] Thu, 02 November 2017 08:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29327
Registered: July 2009
Senior Member
Hauke Fuhrmann wrote on Thu, 02 November 2017 07:11
Hi there,

I have a use case where attributes not only have a value but an additional status field with an enum and maybe even more properties (for example two values and the status determines which value is the actual one).
This to me begs the question: how is all this not simply a complex value?Quote:

Of course, my custom attribute would require to serialize all this information to XML.
Also suggesting that all this is just a value.Quote:


It's a little odd usecase, but I was interested if there is some extension mechanism in EMF to achieve that.
This use case somehow being distinct from simply using an EClass to describe all the state or using a hand written class wrapped as an EDataType to represent the state just isn't clear to me.Quote:


I.e. for classes I could add a different Implementation of EObjectImpl in the "Root Extends Class" field. However, this is only a single setting for the whole model and cannot be done per class.
This part isn't clear either.Quote:

Still, for EAttributes there seems no option to change the implementation of the EAttribute, neither for the whole model nor for a single attribute.
Event the terminology is confusing me. You can annotate an EAttribute but extending it seems inappopriate because clearly anything you add to an extended EAttribute will have no impact on serialization of instances and generally will have no impact on the representation of instances, both dynamic and generated. So it's just not the right direction in which to go...Quote:


Is an EDataType suitable for that? Does it make sense to create custom Data Types that are similar to Attributes with my additional behaviour/structure? Seems quite effort prone/brittle.
This confuses me too. How can an EDataType be similar to an EAttribute? Of course whatever value you want to represent you must model either using an EClass or using something hand written wrapped in an EDataType, keeping in mind that data values should generally be immutable because you will not get notification about changes other than changes to the value has a whole.Quote:


Cheers,
Hauke


Re: Extend EAttributeImpl [message #1775623 is a reply to message #1775612] Thu, 02 November 2017 09:31 Go to previous message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 25
Registered: January 2016
Junior Member
Hi Ed,

thanks for your insights and sorry not to be very clear. Now you say it, I might agree that my use case is just about complex values and not about attributes at all. So maybe I'll experiment with custom data Types.

BTW: Thanks for your introductory EMF talk last week. The style was very refreshing :)

Cheers,
Hauke
Previous Topic:Displaying frequently changing lists of eObjects
Next Topic:[xcore] generated code should implements an existing interface
Goto Forum:
  


Current Time: Tue Apr 24 23:26:21 GMT 2018

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

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