<div dir="ltr">We use drools for validation rules in our application. Some of these rules are dependent on which CRUD operation is being performed at the time, so as part of our validation aspect we insert a CrudMode enum with the current action (by annotating the advised method). e.g.<div>
<span class=""><br></span></div><div><span class="">@Validate</span>(validators = BusinessRulesValidator.<span class="">class</span>, mode = <span class="">CREATE</span>)</div><div>public void create(@DTO SomeDTO incomingDto)<div>
<div><br></div><div>In our rules we can then go:<div>
<br></div><div>CrudMode(this == CrudMode.CREATE)</div><div><br></div><div>The second way we use it (and this one I don&#39;t like so much) is that our validation aspect runs both before and after a method (PRE and POST). We use an agenda-group to to indicate which phase a rule should be included which works fine, however we were finding that some conditions were relatively expensive which had performance implications. Our solution was to also include a ValidationPhase enum as a fact and use that to short-circuit the rules. I reckon there is probably a better way to achieve this however we didn&#39;t spend a lot of time thinking about it.</div>
<div><br></div><div>cheers</div><div>Steve  </div>
</div></div></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">-------------------------------------------------------------------<br>Steven Williams<div><br></div></div></div>
<br><br><div class="gmail_quote">On Thu, Nov 14, 2013 at 12:40 AM, Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Just curiosity.<br>
<div class="im"><br>
On 13/11/2013, Steven Williams &lt;<a href="mailto:stevearoonie@gmail.com">stevearoonie@gmail.com</a>&gt; wrote:<br>
&gt; I use something like the following in rules to good effect:<br>
&gt;<br>
&gt; Country( this == Country.USA )<br>
<br>
</div>Granted, you can add any number of attributes to an enum so that it&#39;s<br>
just another way of writing a static set of bean objects. But is there<br>
a &quot;good effect&quot; to be had from a pattern that merely ascertains the<br>
presence of an enum instance<br>
in the Working Memory?<br>
<br>
Other than this, a pattern like<br>
   City( country == Country.USA )<br>
doesn&#39;t require the insertion of the Country enums.<br>
<br>
Cheers<br>
<span class="HOEnZb"><font color="#888888">Wolfgang<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><br></div>