[rules-users] Accessing a property of an Enum (LHS)
Edson Tirelli
tirelli at post.com
Fri Jan 9 09:52:56 EST 2009
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 at 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 at generali.ch <patrick.gras at generali.ch>>*
> P***** Please consider the environment before printing this E-Mail!***
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090109/7ff5fcb2/attachment.html
More information about the rules-users
mailing list