Hello everybody:
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,
rule
when
Fact1($intAttr : attrInt1)
Fact2(attrString == $intAttr)
....
the rule seems to behave OK, whereas when I compare them from String to int,
rule
when
Fact1($stringAttr : attrString1)
Fact2(attrInt == $stringAttr)
....
I get a RuntimeDroolsException( "Conversion to long not supported from java.lang.String").
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.
...
if ( value instanceof Number ) {
return ((Number) value).longValue();
} else if ( value instanceof Date ) {
return ((Date) value).getTime();
}
...
Is it possible to add String to long conversion via Long.parseLong(str) or is there any reason not to allow this conversion?.
Thank you again for your time.
Best regards,
Manuel Ortiz.