Following on from Raj's suggestion. I have a toolkit of such helper methods that I include into many rule projects.
I find it particularly useful in such use cases as yours to have a 'containsAnyOf' and 'containsNoneOf' as these work very well in Decision Tables. I even have case insensive variations so that I don't miss capitalised words.
The arguments to the helper methods are 'String source' and a 'String[] targetList' and you can pass a list of strings to search for in the BAL rule e.g. {"one", "two", "three"}
and the B2X code for containsAnyOf (Case insensitive variant):
if (source == null || source.equals(""))
return false;
for (int item = 0;item < targetList.length; item=item+1 ) {
if (source.toLowerCase().contains(targetList[item].toLowerCase()) )
return true;
}
return false;
and the B2X code for containsNoneOf (Case insensitive variant):
if (source == null || source.equals(""))
return true;
for (int item = 0;item < targetList.length; item=item+1 ) {
if (source.toLowerCase().contains(targetList[item].toLowerCase()) )
return false;
}
return true;
------------------------------
Andy Macdonald
------------------------------
Original Message:
Sent: Mon March 24, 2025 07:48 AM
From: Jan Andersson
Subject: ODM: "Exists" type of expressions in decision tables?
Hi y'all!
I have a question regarding condition columns in a decision table. I need a rule to check if a document contains strings. If one exists and the other not, then fire the rule. There are many of these string pairs, and several pairs may be in a document.
I thought a decision table would be the obvious choice. But I need to check the non-existence of the other string in the document, and I can't figure out how to do that. I would like to express something like "there exist no string such that this string is <a string>".
Is there even any such syntax for a decision tree condition column?
Any guidance greatly appreciated.
Regards, Jan
------------------------------
Jan Andersson
------------------------------