rule "Discount Egypt" salience 0 when $T : TripRequest ( destination == "Egypt" ) $dest: DiscountResult() then $dest=$T.getResult(); $dest.setDiscount(5); end
On Wed, Apr 23, 2014 at 2:07 PM, Leonard93 <leonardlinde...@hotmail.com>wrote: > When I have the following rule: > > rule "Discount Egypt" > salience 0 > when > $T : TripRequest ( destination == "Egypt" ) > then > ((DiscountResult) $T.getResult()).setDiscount(5); > end > > > Is there a better way to do the 'then' part of the rule (when it comes to > formatting, but still executes the same thing)? > My request object has a result object that has a method called setDiscount > that needs to be called. > > The setDiscount cannot be in the request object because there are multiple > kinds of Result Objects, thus the casting to its type. > > This rule works fine, I was just wondering if there are any easier ways to > do it. I already found out you can do 'destination' instead of > 'getDestination()' which helps make the rules more readable. > > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Is-there-a-better-way-to-write-this-rule-tp4029327.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 >
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users