简体   繁体   English

如何在 Xtend 中找出是否使用了 Xtext 语法中的可选功能?

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

I have the following xtext fragments:我有以下 xtext 片段:

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:在生成的 LongDmxColor.java 类中,有以下与白色相关的方法:

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

How can I in xtend find out whether white is selected or not?我如何在 xtend 中找出是否选择了白色?

I found a solution (to help others):我找到了一个解决方案(帮助他人):

Use the eIsSet command, like:使用eIsSet命令,例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM