Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Compare] Access EClass name attribute through DiffElement
[EMF Compare] Access EClass name attribute through DiffElement [message #661359] Thu, 24 March 2011 07:21 Go to next message
leonard.krpan is currently offline leonard.krpan
Messages: 20
Registered: March 2011
Junior Member
Hello,

I'm trying to process a DiffOperation on an EClass in order to find out if it was the name of the EClass instance that's changed (and not some other attribute of the EClass).

Is there perhaps a better way to do it than this (is there a constant for the "name" String somehwere)?

for (DiffElement diffElement : operations) {

    if ( diffElement instanceof UpdateAttribute ) {  						
							
	 UpdateAttribute changeObject = (UpdateAttribute)diffElement;
							
	if (changeObject.getAttribute().getName() == "name" ) {
								
	    // process changeObject's left and right EClasses...
								
	}
     }
}
Re: [EMF Compare] Access EClass name attribute through DiffElement [message #661444 is a reply to message #661359] Thu, 24 March 2011 12:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25746
Registered: July 2009
Senior Member
You'd be better to use XyzPackage.Literals.CLASS_NAME__FEATURE_NAME to
compare the actual EAttribute. (You can use == for comparing
EAttributes but with Strings you generally should use .equals.)


lk_muc wrote:
> Hello,
>
> I'm trying to process a DiffOperation on an EClass in order to find
> out if it was the name of the EClass instance that's changed (and not
> some other attribute of the EClass).
>
> Is there perhaps a better way to do it than this (is there a constant
> for the "name" String somehwere)?
>
>
> for (DiffElement diffElement : operations) {
>
> if ( diffElement instanceof UpdateAttribute )
> {
>
> UpdateAttribute changeObject = (UpdateAttribute)diffElement;
>
> if (changeObject.getAttribute().getName() == "name" ) {
>
> // process changeObject's left and right EClasses...
>
> }
> }
> }
>
Re: [EMF Compare] Access EClass name attribute through DiffElement [message #661852 is a reply to message #661444] Mon, 28 March 2011 05:26 Go to previous message
leonard.krpan is currently offline leonard.krpan
Messages: 20
Registered: March 2011
Junior Member
Thanks Ed, that's exactly what I was looking for. I'm using the following now:

if ( changeObject.getAttribute() == EcorePackage.Literals.ENAMED_ELEMENT__NAME ) {


Also thanks for the string tip - I totally didn't register I wasn't using equals!
Previous Topic:[EMF Search] Missing sources in 0.7.0 Ganymede release (2008/06/13)
Next Topic:Recursive method deleting empty packages in a model issue
Goto Forum:
  


Current Time: Sat Apr 19 13:16:40 EDT 2014

Powered by FUDForum. Page generated in 0.02023 seconds