Try using the getter, Java style, rather than the simple field name. -W
On 24/05/2012, radai rosenblatt <[email protected]> wrote: > hello. > > I have the following 2 classes: > > public class ClassWithPayload { > private String key; > private Object payload; > // getters setters etc ommitted > } > > public class PayloadClass { > public String someProp; > //getters setters etc ommitted > } > > and im trying to get the following rule to compile: > > rule "Naive Payload Access" > when > $container : ClassWithPayload(key == "someKey", (payload != null && > payload.someProp == "someValue")) > then > System.err.println("boom"); > end > > which results in the following error: > java.lang.AssertionError: Unable to Analyse Expression payload.someProp: > [Error: unable to resolve method using strict-mode: > java.lang.Object.someProp()] > [Near : {... payload.someProp ....}] > > is there some way for me to cast payload.someProp to the proper class ? > (PayloadClass in this case). > this is a simplification of a bigger migration issue from drools 5.1 to 5.4 > so the payload property has to remain an Object in the general case. > > there's a casting syntax mentioned here > (https://community.jboss.org/wiki/DroolsPatternLanguage) but i take it its > not been implemented yet? (or maybe i just cant understand it properly?) > i've tried this: > > rule "Naive Payload Access" > when > $container : ClassWithPayload(key == "someKey", (payload != null && > payload.#PayloadClass(someProp == "someValue"))) > then > System.err.println("boom"); > end > > but it doesnt compile: > java.lang.AssertionError: [8,51]: [ERR 101] Line 8:51 no viable alternative > at input '(' in rule "Naive Payload Access" > [0,0]: Parser returned a null Package > > and if i cant cast, how can i get this sort of rule to behave as it did in > 5.1.1 ? > > thanks in advance for any assistance, > > Radai. > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/strict-mode-and-nested-object-property-access-in-drools-5-4-0-Final-can-i-cast-tp4013373.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
