<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>That rule would work if you added a “name” property to Country.</div><div><br></div><div>As a general tip on working with countries, always work with their ISO codes, not their names.</div><div><br></div><div><a href="http://en.wikipedia.org/wiki/ISO_3166-1">http://en.wikipedia.org/wiki/ISO_3166-1</a></div><div><br></div><div>… ideally the 2-char codes, which are much more commonly used than the 3-char codes.</div><div><br></div><div>Feel free to steal this:</div><div><a href="https://github.com/gratiartis/sctrcd-payment-validation-web/blob/master/src/main/java/com/sctrcd/payments/enums/CountryEnum.java">https://github.com/gratiartis/sctrcd-payment-validation-web/blob/master/src/main/java/com/sctrcd/payments/enums/CountryEnum.java</a></div><div><br></div><div>… which sets up all countries with ISO codes and full-text names as enums. Or at least all countries which were included in the ISO spec at the time of writing.</div><div><br></div><div>Grab it while you can - I’m in the middle of refactoring it into a JPA entity. :)</div><div><br></div><div>Steve</div><div><br></div><br><div><div>On 12 Nov 2013, at 10:20, droolster &lt;<a href="mailto:quant.coder@gmail.com">quant.coder@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hello,<br><br>I would like to use type-safe enums in my rules. At the moment I have<br>situation like this:<br><br>public class Country {<br> &nbsp;&nbsp;&nbsp;private String name;<br><br> &nbsp;&nbsp;&nbsp;// getter/setters<br>}<br><br>rule "Country"<br> &nbsp;&nbsp;&nbsp;when <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Country ( name == "USA" )<br> &nbsp;&nbsp;&nbsp;then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DO SOMETHING<br>end<br><br>I would like to have something like this:<br><br>public enum Country {<br> &nbsp;&nbsp;&nbsp;USA ()<br> &nbsp;&nbsp;&nbsp;// list of all countries in the world<br>}<br><br>and in the rule I would like to do this:<br><br>rule "Country"<br> &nbsp;&nbsp;&nbsp;when <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Country ( name == Country.USA )<br> &nbsp;&nbsp;&nbsp;then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DO SOMETHING<br>end<br><br>Is that possible?<br><br>Thanks in advance for your help.<br><br><br><br><br><br><br>--<br>View this message in context: <a href="http://drools.46999.n3.nabble.com/How-to-use-type-safe-enums-in-rule-condition-tp4026739.html">http://drools.46999.n3.nabble.com/How-to-use-type-safe-enums-in-rule-condition-tp4026739.html</a><br>Sent from the Drools: User forum mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users<br></blockquote></div><br></body></html>