Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Overriding attributes of EStructuralFeature
Overriding attributes of EStructuralFeature [message #1256562] Tue, 25 February 2014 10:11 Go to next message
Wernke zur Borg is currently offline Wernke zur Borg
Messages: 9
Registered: December 2011
Junior Member
Dear all,

I am faced with a situation where I need to override the 'transient' attribute of an EReference in a derived class.

http://opa1.de/files/container.png

Here, I want the contained objects to be non-transient in general, but I want to have them transient for the class SomeContainer only.

Is there a way to achieve that?

Thanks in advance
Wernke

[Updated on: Tue, 25 February 2014 10:14]

Report message to a moderator

Re: Overriding attributes of EStructuralFeature [message #1256613 is a reply to message #1256562] Tue, 25 February 2014 11:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
Wernke,

Comments below.

On 25/02/2014 4:11 PM, Wernke zur Borg wrote:
> Dear all,
>
> I am faced with a situation where I would need to override the
> 'transient' attribute of an EReference in a derived class.
That's not possible.
>
>
>
>
> Here, I want the contained objects to be non-transient in general, but
> I want to have them transient for the class SomeContainer only.
Where do they come from in that case?
>
> Is there a way to achieve that?
The only way to achieve something like that is to make the feature
unsettable and to specialize the implementation of that specific derived
class to make the feature look like eIsSet is false. Serializes will
generally not serialize such features.
>
> Thanks in advance
> Wernke
>
Re: Overriding attributes of EStructuralFeature [message #1257513 is a reply to message #1256613] Wed, 26 February 2014 09:13 Go to previous messageGo to next message
Wernke zur Borg is currently offline Wernke zur Borg
Messages: 9
Registered: December 2011
Junior Member
Thanks, Ed.

I found another solution. I just duplicated the containment feature in the derived class, made it transient there, and forward the call of getContained() in the derived class to return the duplicated list.

http://opa1.de/files/container2.png

SomeContainerImpl:
/*
 * @generated NOT
 */
public EList<IContained> getContained() {
      return getTransientContained();
}


It works! Smile

Wernke
Re: Overriding attributes of EStructuralFeature [message #1257690 is a reply to message #1257513] Wed, 26 February 2014 12:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
Wernke,

Comments below.

On 26/02/2014 3:13 PM, Wernke zur Borg wrote:
> Thanks, Ed.
>
> I found another solution. I just duplicated the containment feature in
> the derived class, made it transient there, and forward the call of
> getContained() in the derived class to return the duplicated list.
This creates a reflective inconsistency in the instances. E.g., the
list returned for a multi-valued feature must implement InternalEList
and EStructuralFeature.Setting; in this case x.eGet(f) returns a list
that when cast to a Setting and queries for the structural feature it
wraps, will not return f.
>
>
>
> SomeContainerImpl:
>
> /*
> * @generated NOT
> */
> public EList<IContained> getContained() {
> return getTransientContained();
> }
>
>
> It works! :)
Don't count on things like a ChangeRecorder or cross references
returning consistent results though...
> Wernke
Re: Overriding attributes of EStructuralFeature [message #1258278 is a reply to message #1257690] Thu, 27 February 2014 03:25 Go to previous message
Wernke zur Borg is currently offline Wernke zur Borg
Messages: 9
Registered: December 2011
Junior Member
Thanks for the warning, point taken! Smile
Previous Topic:[Texo] parent/child relations are not persisted
Next Topic:[Solved]How to generate an ecore metamodel diagram from an .ecore file?
Goto Forum:
  


Current Time: Wed Jul 30 21:19:17 EDT 2014

Powered by FUDForum. Page generated in 0.02320 seconds