<br> Ideal IMO would be a compile time error, since getLikes() returns a Cheese instance, but as we use MVEL to resolve the expression, I'm not 100% sure we are able to cover all possible scenarios at compile time. I guess we can, but need to double check that.
<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2007/9/27, Chris Woodrow <<a href="mailto:woodrow.chris@gmail.com">woodrow.chris@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks.<br>I was supposing so...<br>Do you think test 3 should throw a ClassCastException or just not match?<br>Chris<br><br><div><span class="gmail_quote">2007/9/27, Edson Tirelli <<a href="mailto:tirelli@post.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
tirelli@post.com
</a>>:</span><div><span class="e" id="q_11547c7c4b537813_1"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br> Yes, drools is deferring the type verification until it is needed (in your example, to check the constraint). May I ask you please to open a JIRA... I will fix that.
<br><br> []s<br> Edson<br><br><div><div><span><span class="gmail_quote">
2007/9/27, Chris Woodrow <<a href="mailto:woodrow.chris@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">woodrow.chris@gmail.com</a>>:</span></span></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><span>
I am sorry I didn't mean 'for' but 'from'.<br>:D<br><br><div><span class="gmail_quote">2007/9/27, Chris Woodrow <<a href="mailto:woodrow.chris@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
woodrow.chris@gmail.com</a>>:</span><div><span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>I recently find out a few issues using for, and I wanted to share it with you. I made a simple exemple to illustrate my purpose.<br><br>My classes are (I did not represent accessors & constructors):<br><br><div style="margin-left: 40px;">
public class Cheese {<br> protected String name;<br>}<br><br>public class FrenchCheese extends Cheese{<br> private String smell;<br>}<br><br>public class Person {<br> private Cheese likes;<br>}<br></div><br>Here is my rule set :
<br><br><div style="margin-left: 40px;">package rules<br><br>rule "likes cheese"<br> when<br> $person : Person ()<br> Cheese( ) from $person.getLikes()<br> then <br> System.out.println
("likes cheese");<br>end<br><br><br>rule "likes french cheese"<br> when<br> $person : Person ()<br> FrenchCheese( ) from $person.getLikes()<br> then <br> System.out.println
("likes french cheese");
<br>end<br></div><br>First test :<br> Cheese cheese = new FrenchCheese("good", "camembert");<br> Person person = new Person();<br> person.setLikes(cheese);<br><br>Output :<br><div style="margin-left: 40px;">
likes french cheese<br>likes cheese<br></div><br>Wich is expected...<br><br>Second test : <br> Cheese cheese = new Cheese();<br> Person person = new Person();<br> person.setLikes(cheese);<br><br>Output :
<br><div style="margin-left: 40px;">likes french cheese<br>likes cheese<br></div><br>That's the first strange thing. As far as I am concerned, rule "likes french cheese" should not match (since a Cheese is not a FrenchCheese).
<br><br>I made a change to the second rule :<br><div style="margin-left: 40px;">rule "likes french cheese"<br>
when<br>
$person : Person ()<br>
FrenchCheese( smell == "good" ) from $person.getLikes()<br>
then <br>
System.out.println("likes french cheese");<br>
end<br></div><br>Third test :<br> Cheese cheese = new Cheese();<br>
Person person = new Person();<br>
person.setLikes(cheese);<br><br>output : <br>It throwed an exception : Exception in thread "main" java.lang.ClassCastException: rules.Cheese<br>I am not saying the ClassCastException is not to expect in such a case but I think I would simply expect it not to match (as far as a Cheese is not a FrenchCheese).
<br><span><br>Chris<br>
</span></blockquote></span></div></div><br>
<br></span></div>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org
</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646
<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">www.jboss.com</a>
<br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org
</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></blockquote></span></div></div><br>
<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> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646
<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>