Hello everybody:<div><br></div><div>I'm trying to write rules in which fact int attributes and fact String attributes should be compared in condition elements. When I compare them, let's say from int to String,</div>
<div><br></div><div>rule</div><div> when</div><div> Fact1($intAttr : attrInt1)</div><div> Fact2(attrString == $intAttr)</div><div>....</div><div><br></div><div>the rule seems to behave OK, whereas when I compare them from String to int,</div>
<div><br></div><div><div>rule</div><div> when</div><div> Fact1($stringAttr : attrString1)</div><div> Fact2(attrInt == $stringAttr)</div><div>....</div></div><div><br></div><div>I get a RuntimeDroolsException( "Conversion to long not supported from java.lang.String").</div>
<div><br></div><div>I've taken a look at the code which throws the exception, BaseObjectClassField.getLongValue() and found that it only accepts Number and Date objects to be converted to long.</div><div><br></div><div>
...</div><div><div> if ( value instanceof Number ) {</div><div> return ((Number) value).longValue();</div><div> } else if ( value instanceof Date ) {</div><div> return ((Date) value).getTime();</div>
<div> }</div></div><div>...</div><div><br></div><div>Is it possible to add String to long conversion via Long.parseLong(str) or is there any reason not to allow this conversion?.</div><div><br></div><div>Thank you again for your time.</div>
<div><br></div><div>Best regards,</div><div><br></div><div>Manuel Ortiz.</div>