Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtend2] Accessing enumeration defined in the metamodel
[Xtend2] Accessing enumeration defined in the metamodel [message #677737] Thu, 09 June 2011 09:13 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
In my metamodel, I defined a "ReadWriteMode" enumeration with the following values:
- ReadOnly
- WriteOnly
- ReadWrite

I have an EClass "Property" having a member of type ReadWriteMode.

In my XTend file, I am trying to write something like this:

def isRead(Property prop) {
		(prop.readWriteMode == ReadWriteMode.ReadOnly);
	}


Unfortunately Xtend doesn't accept that and says:
Couldn't resolve reference to JvmIdentifiableElement 'ReadWriteMode'

How can I manipulate enumerations in Xtend2 ?
Re: [Xtend2] Accessing enumeration defined in the metamodel [message #677781 is a reply to message #677737] Thu, 09 June 2011 11:19 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Cedric,

you have to use ReadWriteMode::ReadOnly to access the static field (enum
value) 'ReadOnly'.

Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 09.06.11 11:13, schrieb Cedric Moonen:
> In my metamodel, I defined a "ReadWriteMode" enumeration with the
> following values:
> - ReadOnly
> - WriteOnly
> - ReadWrite
>
> I have an EClass "Property" having a member of type ReadWriteMode.
>
> In my XTend file, I am trying to write something like this:
>
> def isRead(Property prop) {
> (prop.readWriteMode == ReadWriteMode.ReadOnly);
> }
>
> Unfortunately Xtend doesn't accept that and says:
> Couldn't resolve reference to JvmIdentifiableElement 'ReadWriteMode'
>
> How can I manipulate enumerations in Xtend2 ?
Re: [Xtend2] Accessing enumeration defined in the metamodel [message #677792 is a reply to message #677781] Thu, 09 June 2011 12:02 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hi Sebastian,

In fact I already tried that and it didn't work. I now checked again and indeed you have to write it this way:
def isRead(Property prop) {
   (prop.readWriteMode == ReadWriteMode::READ_ONLY);
   }


Looking at the EMF generated code for the enumeration, the fields are in fact named: READ_ONLY, WRITE_ONLY and READ_WRITE (but the litteral values are kept identical to the ones specified in the enumeration).
Previous Topic:EClasses and EAttributes from external ecore models
Next Topic:Use imported objects in generator
Goto Forum:
  


Current Time: Thu Mar 28 14:14:17 GMT 2024

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

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

Back to the top