On Tue, Sep 29, 2009 at 12:43 AM, Dave Schweisguth <span dir="ltr"><<a href="mailto:dave@schweisguth.org">dave@schweisguth.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Greetings fellow Droolers,<br>
<br>
I've just begun using Drools and am very happy with it so far as it seems to<br>
be a great fit for what we want to do. My left hand sides are not quite<br>
beautiful enough, however, and I wondered if anyone could suggest<br>
improvements.<br>
<br>
1) One of my facts' properties is a set of strings. The goal is to "grep"<br>
them for some search string. The most convenient syntax I've come up with<br>
so far is to give the fact a method anyTextContains which loops over the<br>
set and calls contains(searchString) on each member, and then use<br>
<br>
fact: Fact() eval(fact.anyTextContains("searchString"))<br>
<br>
in my LHS. It's compact enough, but I wondered whether it could be done<br>
without a custom method or eval. "from" seems not to be a possibility since<br>
the collection is of strings, not objects. Any suggestions?<br></blockquote><div><br>But any java.lang.String is an Object, although without a field (in the usual sense),<br>Nevertheless, try<br><br>rule "Match John"<br>
when<br> Vote( $names : names ) // Set<String> names<br> String( this matches "John" ) from $names<br> then <br> System.out.println( "Hi John" );<br>end<br>
</div>-W<br><br></div><br>