title: Drools Number to String Coercion
body: <p>Is there any way to let Drools handle a String, Integer comparison without having to manually do type conversions?</p>
  
  <p>I am having trouble comparing a string to an integer in a rule.  The rule can be simplified to the following where fields is just a <code>Map&lt;String, String&gt;</code>.</p>
  
  <pre><code>rule "Test Rule"
      when
          MapTest(fields["a"] != null, fields["a"] == 10)
      then
          System.out.println( "test succeeded" );
  end
  </code></pre>
  
  <p>The problem is that given this rule, even when a = "10", the consequence is never fired.  According to the documentation at section 4.8.3.3.3 "Coercion is always in favor of the field type and not the value type".  So this rule seems like the 10 should be coerced to "10" and then this comparison should return true, but it doesn't.</p>
  
  <p>If a change the 10 to "10" the rule succeeds.  Also if I do Integer.parseInt(fields["a"]) the rule succeeds.  </p>
  
  <p>The more interesting part is if I change the operator to > or &lt; and change the value of fields["a"] appropriately the rule still succeeds!  Is this because > and &lt; aren't technically valid operators on Strings so the two operands are converted to numeric values and compared? </p>