[rules-users] Is there a better way to write this rule?
Bharadwaj N
bharadwaj2012 at gmail.com
Wed Apr 23 04:46:02 EDT 2014
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 <leonardlindenau at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140423/1eedd48e/attachment.html
More information about the rules-users
mailing list