Comparing integers in drools causes cast exception
<p>I have a simple Drools rule where I am converting a string to an integer and then comparing it with another integer. Like so:</p>

<pre><code>when
    $list : List(size &gt; 0 )
    $m1 : Map() from $list.get(0)
    $var1 : Map(stringToInt(this["number"]) &lt;= 0) from $list.get(0)
</code></pre>

<p>This should check if the string value of "number" in my map is less than or equal to 0 after being converted. stringToInt is just a helper function I wrote that calls Integer.parseInt and catches exceptions.</p>

<p>I get this error though when I try to run the rule:</p>

<pre><code>java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
    at org.mvel2.ast.Negation.getReducedValueAccelerated(Negation.java:48)
</code></pre>

<p>The dialect is set to java and my version of drools is 6.4.0. How do I get around this error?</p>

<p>EDIT: string to int:</p>

<pre><code>public static int stringToInt(String s) {
    try {
        int num = Integer.parseInt(s);
        return num;
    } catch (Exception e) {
        return -1;
    }
}
</code></pre>