|[Acceleo] A switch in an Acceleo query [message #1244594]
||Wed, 12 February 2014 15:18
| Tatiana Fesenko
Registered: July 2009
I have to implement an Acceleo query which should return a string value based on the input. It can be implemented using an equivalent of a Java switch statement. Unfortunately, I didn't find anything similar to the switch in the specification. Acceleo/OCL doesn't support the elseif statement that's why this simple code contains many nested 'if's and its readability suffers:
if aResponseCode = 200 then 'OK'
else if aResponseCode = 403 then 'Forbidden'
else if aResponseCode = 500 then 'Internal Server Error'
A good way to implement it would be using an associative array (table), but again, it wasn't mentioned anywhere in the specification. Therefore, the only alternative to multiple nested 'if's that I can see is to use a Java service which delegates this functionality to a Java method.
Is there an equivalent of a switch or associative array in Acceleo? Can you suggest better alternatives to using nested ifs or a java helper?
Powered by FUDForum
. Page generated in 0.13590 seconds