The reason is because Drools does not give any special handling for qualified identifiers... i.e., it would work if "name" was a public constant, and in this scenario we don't try to get is as "getName()".

    You may open a JIRA so that we add support for that in the future.

    []s
    Edson


2009/1/9 Gras, Patrick <Patrick.Gras@generali.ch>

Hi,

I'm trying to access to a property of an Enum but I get the following error:

Unable to create restriction '[QualifiedIndentifierRestr: == Direction.S.name ]' for field 'directionAsString' in the rule 'enum test'

Here is the code for my Enum:

public enum Direction {

        N("North"), S("South"), E("East"), W("West");

        private  final String name;

        private Direction(String name) {
                this.name = name;
        }

        public String getName() {
                return this.name;
        }
}

And here is my Rule:

rule "enum test"
        when
                $to : TestObject($ds: directionAsString == Direction.S.name);
        then
                System.err.println("OK");
end


Is there a reason why I cannot do that ?

Thanks for your help
-Patrick

Patrick Gras
GENERALI Assurances
Service Informatique
Avenue Perdtemps 23
1260 Nyon 1
Tél. direct: +41 58 471 05 87
<mailto:patrick.gras@generali.ch>
P Please consider the environment before printing this E-Mail!



_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com