Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » [EMF Compare] Retrieve original value of AttributeChange
[EMF Compare] Retrieve original value of AttributeChange [message #1049734] Fri, 26 April 2013 03:53 Go to next message
Aleksandar Toshovski is currently offline Aleksandar Toshovski
Messages: 38
Registered: December 2011
Member
How can I retrieve the old value of AttributeChange? With
 diff.getValue() 
I can retrieve the new value of the Attribute, but I don't find a way to retrieve the old one.
Re: [EMF Compare] Retrieve original value of AttributeChange [message #1049931 is a reply to message #1049734] Fri, 26 April 2013 09:17 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1621
Registered: July 2009
Senior Member
Aleksandar,

You need to look the "old" value up yourself. Note that the following is only true for differences of type "CHANGE" (single-valued attribute). For diffs of type "ADD" or "DELETE" (multi-valued attribute), there is no old value.

In two-way :
Object oldAttributeValue = null;
Match match = diff.getMatch();
if (match.getRight() != null) {
  value = match.getRight().eGet(diff.getAttribute());
} else {
  // this item didn't exist previously
}


In three-way:
Match match = diff.getMatch();
if (match.getOrigin() != null) {
  value = match.getOrigin().eGet(diff.getAttribute());
} else {
  // this item didn't exist previously
}


as you can see, there is no real sense to "old" value : it could have been null, or the object where we detected a change didn't previously exist.

Laurent Goubet
Obeo
Re: [EMF Compare] Retrieve original value of AttributeChange [message #1052961 is a reply to message #1049931] Wed, 01 May 2013 11:22 Go to previous message
Aleksandar Toshovski is currently offline Aleksandar Toshovski
Messages: 38
Registered: December 2011
Member
Thanks again for your help Laurent.
Previous Topic:MOVE DifferenceKind semantics
Next Topic:[EMFCompare] Diff: Deleted attribute from a class
Goto Forum:
  


Current Time: Thu Jul 24 19:03:14 EDT 2014

Powered by FUDForum. Page generated in 0.03618 seconds