Skip to main content


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 11:21 Go to next message
leonard.krpan is currently offline leonard.krpanFriend
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 16:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
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...
>
> }
> }
> }
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF Compare] Access EClass name attribute through DiffElement [message #661852 is a reply to message #661444] Mon, 28 March 2011 09:26 Go to previous message
leonard.krpan is currently offline leonard.krpanFriend
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 27 02:54:05 GMT 2024

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

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

Back to the top