Skip to main content


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 15:11 Go to next message
Wernke zur Borg is currently offline Wernke zur BorgFriend
Messages: 42
Registered: December 2011
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 15:14]

Report message to a moderator

Re: Overriding attributes of EStructuralFeature [message #1256613 is a reply to message #1256562] Tue, 25 February 2014 16:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
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
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Overriding attributes of EStructuralFeature [message #1257513 is a reply to message #1256613] Wed, 26 February 2014 14:13 Go to previous messageGo to next message
Wernke zur Borg is currently offline Wernke zur BorgFriend
Messages: 42
Registered: December 2011
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 17:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Overriding attributes of EStructuralFeature [message #1258278 is a reply to message #1257690] Thu, 27 February 2014 08:25 Go to previous message
Wernke zur Borg is currently offline Wernke zur BorgFriend
Messages: 42
Registered: December 2011
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: Tue Mar 19 07:00:03 GMT 2024

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

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

Back to the top