|Re: EMF Compare get ModelElementChangeLeftTarget/ModelElementChangeRightTarget Attributes [message #1123316 is a reply to message #1121500]
||Wed, 02 October 2013 12:40
| Laurent Goubet
Registered: July 2009
You will have to get a good understanding of both the diff metamodel of EMF Compare 1 and EMF itself before properly navigating to the elment you need.
First of all, a "ModelElementChange" diff means that an EObject, as a whole, has been added or deleted. "value" is no more than one of the attribute of the EObject that's been added or removed from the model. As such, retrieving only the value of this changed element doesn't make sense wrt. EMF Compare; what you have is a pure EMF question.
In this case, you are trying to retrieve the value of a particular feature for a given EObject. Since you do not know said EObjet's type, you need to use the reflexive APIs of EMF (as you did, through "eGet"). The "particular feature", you have to find for yourself since EMF Compare does not know about it either (the diff is not on that feature).
If you know that the feature you need will always be called "value", you can use a code such as this :
ModelElementChangeLeftTarget diff = (ModelElementChangeLeftTarget)obj;
EObject changedEObject = diff.getLeftElement();
EStructuralFeature valueFeature = changedEObject.eClass().getEStructuralFeature("value");
Object featureValue = changedEObject.eGet(valueFeature);
Powered by FUDForum
. Page generated in 0.10792 seconds