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">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>- Krishna<br><br>