Search code examples
exceljbossdrools

How to write a rule for alphanumeric ranges in Drools using excel file


I'm new to Drools, so pardon me if the question seems stupid. I have written rules for values which have ranges in numeric format. Can someone please let me know how can we write rules for alphanumeric ranges.

Below is the rule I've written for numeric ranges.

claim.Medicalcare.get("CLM07-00").Value >= $1,
claim.Medicalcare.get("CLM07-01").Value <= $2

The above rule is for values ranging 1-9.

I need to write a rule which has values G0129-G2341,M9867,99234-99350.
I'm writting these rules in excel spreadsheet.


Solution

  • Assuming that the field is a java.lang.String, you can use >, >= etc. for these values as well and write a range for String ranges the same way you do for numeric values.

    If you have several ranges, use one line for each range. (You may also use the forall construct as described in the documentation.)

    For several individual values you can use the operator in or, again, the forall construct.

    There is no simple way of testing for an arbitrary combination of ranges and individual values. You'll have to split testing for G0129-G2341, M9867, 99234-99350 into two or three rules.

    (You didn't provide any code describing the fact - this is why I don't provide any code either.)