[rules-users] Clarification needed in writing DSL function mapping
Wolfgang Laun
wolfgang.laun at gmail.com
Mon May 30 12:47:36 EDT 2011
On 30 May 2011 16:09, Bala <bala.ganesh at accenture.com> wrote:
>
> Is there a simplified way of mapping than what i have done???
>
> Java function :
> function boolean checkIfVia(Route route, String locationCode)
> {
> if(route != null)
> {
> Via[] viaArr = route.getViaArray();
> for(int i=1; i < viaArr.length; i++)
> {
> if(viaArr[i].getLocation().equalsIgnoreCase(locationCode))
> return true;
> else
> return false;
> }
> }
> return false;
> }
>
> I don't think that
else
return false;
is correct, because then the result would only depend on viaArr[1], and that
ought to be written differently.
>
>
>
> Dsl Mapping:
>
> [keyword][][Ff][Uu][Nn][Cc]
> [Cc][Hh][Ee][Cc][Kk][Ii][Ff][Vv][Ii][Aa]=function boolean checkIfVia(Route
> route, String locationCode)\n{checkIfViaBody}
>
Do you mean that you can write in the DSLR:
func checkIfVia
A keyword must be a single token.
There's no need to split this into several definitions. Put it all in one
keyword definition.
Never mind the \n.
> [keyword][]checkIfViaBody=\nif(route != null)\n{checkIfViaIfBlock}\nreturn
> false;\n
> [keyword][]checkIfViaIfBlock=\nVia[] viaArr = route.getViaArray();\nfor(int
> i=1; i < viaArr.length; i++)\n{checkIfViaForBlock}\n
>
> [keyword][]checkIfViaForBlock=\nif(viaArr[i].getLocationCode().equalsIgnoreCase(locationCode))\n
> return true; \nelse \nreturn false;\n
>
>
But it would be much simpler to import a Java function.
-W
>
>
>
> -----
> Thanks,
> Bala
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Clarification-needed-in-writing-DSL-function-mapping-tp3002064p3002064.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110530/8a5873b5/attachment.html
More information about the rules-users
mailing list