<div dir="ltr">If your matcher doesn't equate to a boolean value, I don't think that condition will evaluate as you suspect it will. Functions in your conditions isn't going to be as clean or easy as you suspect. Consider inserting the user-supplied values into your session and matching with a rule:<div>
<br></div><div>...</div><div style>public class Transaction {</div><div style><br></div><div style> private String field;</div><div style><br></div><div style> // ... getter and setter for field, as well as all your other methods in transaction, just showing this to say I'm assuming 'field' to be of type String</div>
<div style>}</div><div style><br></div><div style>...</div><div><br></div><div><div><font face="arial, sans-serif">public class Value {</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>private String value;</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>public String getValue() {</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>return value;</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>public void setValue(String value) {</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>this.value = value;</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif">}</font></div>
</div><div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">...</span></div><div style><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">rule "find value substring match"</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">when</span></div><div>
Value ( $v : value )<br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> $t : Transaction( field.contains($v) </span><span style="font-family:arial,sans-serif;font-size:13px">)</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">then</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> sendAlert("Transaction " + $t.getName() + "matches criteria</span><span style="font-family:arial,sans-serif;font-size:13px">: " + $v);</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">end</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">...</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">session.insert(transaction);</span></div><div style><font face="arial, sans-serif">for (int i = 0; i < listOfUserValues.length; i++) {</font></div>
<div style><font face="arial, sans-serif"> session.insert(listOfUserValues[i];</font></div><div style><font face="arial, sans-serif">}</font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jan 5, 2013 at 12:29 PM, bdolbeare <span dir="ltr"><<a href="mailto:bdolbeare@yahoo.com" target="_blank">bdolbeare@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Suppose we have a Transaction object with a String field. Users want to<br>
create a rule through our application that says alert me whenever the value<br>
of that field contains a value in a list of values provided in the rule.<br>
It's easy enough to write this type of rule and send an alert; however, it<br>
would be helpful to include the value from the list that matched.<br>
<br>
The only way I can think to do this type of thing is to create a function<br>
somewhere that checks if the field contains any of the values in the user<br>
list and if so return that value. Then call that function in the rule<br>
condition and bind the result. Something like what follows:<br>
<br>
<br>
public class ExternalMatcher<br>
{<br>
public static String contains(String field, String...list)<br>
{<br>
// return the first string that satisfies the contains logic or null if no<br>
strings succeed<br>
}<br>
}<br>
<br>
rule "test"<br>
when<br>
Transaction( $matchedValue : ExternalMatcher.contains(field, "value1",<br>
"value2", "value3") != null)<br>
then<br>
sendAlert("I found a transaction that matched your criteria because field<br>
foo equals: " + $matchedValue);<br>
end<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Finding-matching-values-in-composite-constraint-tp4021343p4021346.html" target="_blank">http://drools.46999.n3.nabble.com/Finding-matching-values-in-composite-constraint-tp4021343p4021346.html</a><br>
<div class="HOEnZb"><div class="h5">Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<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>