How to find out in Xtend if an optional feature from an Xtext grammar is used or not?

181 Views Asked by At

I have the following xtext fragments:

LongDmxColor:
    intensity=DmxValue red=DmxValue green=DmxValue blue=DmxValue (white=DmxValue)?;

and

DmxValue returns INT:
    value=INT;

In the generated LongDmxColor.java class, there are the following methods related to white:

INT getWhite();
void setWhite(INT value);

How can I in xtend find out whether white is selected or not?

1

There are 1 best solutions below

0
On

I found a solution (to help others):

Use the eIsSet command, like:

if (colorItem.eIsSet(DmxLightShowPackage.Literals.LONG_DMX_COLOR__WHITE))