That rule would work if you added a “name” property to Country.
As a general tip on working with countries, always work with their ISO codes, not their names.
… ideally the 2-char codes, which are much more commonly used than the 3-char codes.
Feel free to steal this:
… 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.
Grab it while you can - I’m in the middle of refactoring it into a JPA entity. :)
Steve
Hello,
I would like to use type-safe enums in my rules. At the moment I have
situation like this:
public class Country {
private String name;
// getter/setters
}
rule "Country"
when
Country ( name == "USA" )
then
DO SOMETHING
end
I would like to have something like this:
public enum Country {
USA ()
// list of all countries in the world
}
and in the rule I would like to do this:
rule "Country"
when
Country ( name == Country.USA )
then
DO SOMETHING
end
Is that possible?
Thanks in advance for your help.
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-use-type-safe-enums-in-rule-condition-tp4026739.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users