Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Tue Jul 01 15:35:42 EDT 2025

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

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

Back to the top