Skip to main content


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 07:53 Go to next message
Aleksandar Toshovski is currently offline Aleksandar ToshovskiFriend
Messages: 78
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 13:17 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
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 15:22 Go to previous message
Aleksandar Toshovski is currently offline Aleksandar ToshovskiFriend
Messages: 78
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: Tue Mar 19 03:46:13 GMT 2024

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

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

Back to the top