On 30 May 2011 16:09, Bala <bala.ganesh(a)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-fun...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users