|[Acceleo] Test for an undefined enumeration in OCL [message #869962]
||Sat, 05 May 2012 04:48
| CRASNIER Stéphane
Registered: May 2012
First of all : thanks for the support !|
My problem : I want to simply test if an "enumerated" attribute is defined or not.
Let's say I have :
- an EnumValues enumeration with 2 values VALUE1 and VALUE2
- an EObject object with an optional attribute value of type EnumValues
I would have expected to test the value existence thanks to this expression :
But this expression always returns true as the value attribute seems to be initialized with the first value of the enumeration. The only bypass way I've found is to not declare EnumValues as an Enum but as an EObject. Then the oclIsUndefined() method returns false when the attribute is not set in the model. BTW my model is generated thanks to Xtext.
It seems to be a stupid question but I'm not able to find the answer on Google, in the OCL specification or in the Acceleo resources.
The only material I've found says that the only way to achieve this is to use the isUndefined or the more general isUndefined('value') OCL helper methods. But I'm not able to decline this in the Acceleo environnement.
Do you have any idea ?
Thanks in advance for your reply !
Powered by FUDForum
. Page generated in 0.01637 seconds