<br>&nbsp;&nbsp; Krishna,<br><br>&nbsp;&nbsp; &quot;this&quot; is a special field that always refers to the fact itself, instead of an attribute. Your use of &quot;this&quot; is fine.<br>&nbsp;&nbsp; == used as a top level constraint evaluator always calls for the equals() method on the object in question, or the appropriate comparator when dealing with primitives.<br>
<br>&nbsp; []s<br>&nbsp; Edson<br><br><div><span class="gmail_quote">2008/1/31, Krishna Satya &lt;<a href="mailto:krishna.ksatya@gmail.com">krishna.ksatya@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Greetings.<br>I am trying to find the correct approach to defining and using Java5 Enum&#39;s in Drools constraints.<br><br><b>Psudo code:</b><br>Class RuleRequest {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ... other attributes ...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // RequestType is an enum type.<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RequestType type ;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public RequestType getRequestType() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return type;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br><br>public enum RequestType {<br>&nbsp;&nbsp; INTERNAL(&quot;internal&quot;), EXTERNAL(&quot;external&quot;);<br>

}<br><br><b>Drools Rule:</b><br># 1st Constraint - I could have listed the type in the constraint for RuleRequest but say I want that to be in a separate constraint<br># 2nd Constraint - on the nested RequestType enum<br>

<b>req: RuleRequest(..some match not based on the RequestType but other attributes of RuleRequest...)<br>type: RequestType( ??? == RequestType.INTERNAL ) from req.requestType<br></b><br>What should be plugged in ??? to be able to match the requestType.&nbsp; Interestingly, if I say <br>

<b>type: RequestType( this == RequestType.INTERNAL ) from req.requestType&nbsp; </b>when the ruleRequest has an RequestType of INTERNAL, the matching works.&nbsp; But I do not see any examples/reference in the Drools documentation on the usage of &quot;this&quot; in constraints. I saw a posting from Edson T. using this which is why I tried it in the first place.<br>

<br><b>Question<br></b>- What is the expectation for the Enum.&nbsp; Should it have methods (getters) that return the Enum type itself or methods that return the strigified value of the Enum?<br>- What is syntax and usage practices for the usage of the &quot;this&quot; keyword<br>

- What really happens when the Drools engine does the == comparison on Enum&#39;s.&nbsp; Does it convert to the string value of the enum and then compare that or is there something else in play.&nbsp; <br><br>I hope I have asked valid questions as I see many questions relating to Enum but maybe a definitive/suggested approach and explanation from the drools dream team may serve as a good reference on this subject.<br>

<br>Thanks.<br><span class="sg">- Krishna<br><br><br><br><br><br>
</span><br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></blockquote></div><br>
<br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;JBoss Drools Core Development<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>