<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">rule &quot;Discount Egypt&quot;</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">        salience 0</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">    when</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">        $T : TripRequest ( destination == &quot;Egypt&quot; )</span><div>
        $dest: <span style="font-family:arial,sans-serif;font-size:13px">DiscountResult()</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">    then</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">        </span>$dest=<span style="font-family:arial,sans-serif;font-size:13px">$T.getResult();</span></div><div>       $dest<span style="font-family:arial,sans-serif;font-size:13px">.setDiscount(5)</span><span style="font-family:arial,sans-serif;font-size:13px">;</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">end</span><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 23, 2014 at 2:07 PM, Leonard93 <span dir="ltr">&lt;<a href="mailto:leonardlindenau@hotmail.com" target="_blank">leonardlindenau@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When I have the following rule:<br>
<br>
rule &quot;Discount Egypt&quot;<br>
        salience 0<br>
    when<br>
        $T : TripRequest ( destination == &quot;Egypt&quot; )<br>
    then<br>
        ((DiscountResult) $T.getResult()).setDiscount(5);<br>
end<br>
<br>
<br>
Is there a better way to do the &#39;then&#39; part of the rule (when it comes to<br>
formatting, but still executes the same thing)?<br>
My request object has a result object that has a method called setDiscount<br>
that needs to be called.<br>
<br>
The setDiscount cannot be in the request object because there are multiple<br>
kinds of Result Objects, thus the casting to its type.<br>
<br>
This rule works fine, I was just wondering if there are any easier ways to<br>
do it. I already found out you can do &#39;destination&#39; instead of<br>
&#39;getDestination()&#39; which helps make the rules more readable.<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Is-there-a-better-way-to-write-this-rule-tp4029327.html" target="_blank">http://drools.46999.n3.nabble.com/Is-there-a-better-way-to-write-this-rule-tp4029327.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>