<br>&nbsp;&nbsp; Krishna,<br><br>&nbsp;&nbsp; The problem is not really in Drools, but in the Java &quot;erasure&quot; behavior for Generics.<br>&nbsp;&nbsp; Once you assert a List as an object into the working memory, it loses the generic type information (AFAIK).<br>
<br>&nbsp;&nbsp; So, you can&#39;t really do:<br><br>when<br>&nbsp;&nbsp;&nbsp; List&lt;SomeType&gt;()<br>then<br><br>&nbsp;&nbsp; Because all lists in the working memory would match (even if we supported the &lt;&gt; type syntax).<br>&nbsp;&nbsp; The behavior you saw when using &quot;from&quot; is the correct behavior, since &quot;from&quot; is used to try and match (iterate) each of the elements in a collection.<br>
<br>&nbsp;&nbsp;&nbsp; So,<br><br>genericList : SomeType ( request.getterAttributeName != null ) from request.getterAttributeName<br><br>&nbsp;&nbsp;&nbsp; Will iterate and try to match each of the elements of the &quot;attributeName&quot; collection, and will fire the rule for each match it finds.<br>
<br>&nbsp;&nbsp;&nbsp; Regarding your problem, you don&#39;t need to &quot;change&quot; your object model. You can use it as is in the rules. What you can&#39;t do is use the generic types do constrain your matches. It is exactly the same what you do in java when you mix genericized classes with non-genericized classes.<br>
<br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><br><div><span class="gmail_quote">2008/2/1, 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 have been looking at the postings on the user group and it appears that Java Generics is not supported in the constraint section of the rule.&nbsp; <br>In one of the postings: <a href="http://www.nabble.com/Problem-in-using-genrics-with-drools4.0.1.-td13092212.html#a13092212" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.nabble.com/Problem-in-using-genrics-with-drools4.0.1.-td13092212.html#a13092212</a>, Mark Proctor. has indicated that this cannot be supported. I see other postings where drools team has indicated that generics is not supported.<br>

<br>Given the following would be invalid:<br>rule &quot;Generic Test&quot;<br>&nbsp;&nbsp; request : InputRequest()<br>&nbsp;&nbsp; genericList : List&lt;SomeType&gt; ( request.getterAttributeName != null ) from request.getterAttributeName<br>

then<br>end<br><br>what are the alternatives/workaround to using a model object that has getters that return say a collection of generic types.&nbsp; Our object model uses generics pretty heavily and it would be bad alternative to replicate these model objects without generic signatures just for the sake of Drools.&nbsp; Curiosity got the better of me and I tried to modify the above rule to see what Drools would let me get away with.&nbsp; I cannot have a rule that has any Generic semantics, so I had to drop &lt;SomeType&gt;.&nbsp; I tried <br>

<br>Approach 1 - &nbsp; genericList : List ( request.getterAttributeName != null ) from request.getterAttributeName<br><br>Approach 2 - &nbsp; genericList : SomeType ( request.getterAttributeName != null ) from request.getterAttributeName (forced to do this to avoid run time exception from approach 1)<br>

<br>Here is what I observe:<br>Approach 1 - I tried to see if Drools would give me a reference to a List Type object.&nbsp; The rule compiled but I was getting a classcast exception during runtime when I tried to use the reference in the consequence. Looking at what the root cause for the class cast shows that Drools actually was creating a reference to &quot;SomeType&quot; object which is the type of the object contained in the list.&nbsp;&nbsp; <br>

Approach 2 - I modified the rule to avoid the class cast exception from approach 1.&nbsp; The rule compiled and executed.&nbsp; But the rule was getting fired as many times as the number of objects in the list. <br><br>Both of the above observations are neither intuitive nor typically desired.&nbsp; I understand the rule definition was exploratory.<br>

<br>Questions I have : <br>- Is the above observation a result of a bug in drools?&nbsp; Can the observation be explained.<br>- What is the approach recommended to using an object model that has generic signatures ?<br><br>Hoping some one will weigh in on this subject.<br>

Thanks a lot. <br><span class="sg">- Krishna<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>