The job of the FilteringStrategy is to take the list of rules that were found by the FindingStrategy and filter out the rules that should not be fired. There are three sets of filtering strategies used in TriggerPoint:
A different strategy can be used for each of these scenarios, along with different strategies for classifier and non-classifier rules. The zero rules strategy is invoked if no rules are found by the finding strategy, the one rule strategy is invoked if exactly one rule is found and the multiple rules strategy is invoked if more than one rule is found.
Business Rule Beans (BRBeans) provides the following filtering strategies that can be used:
As an example, here is one common way to use filtering strategies. You want to ensure that exactly one rule is found on a TriggerPoint call. Thus, set all three strategies (zero rules, one rule, and multiple rules) for this TriggerPoint to FilteringStrategy.ACCEPT_ONE. This strategy throws an exception if the number of rules is not exactly one. The following sequence of method calls accomplishes this for TriggerPoint tp:
tp.setNoRulesFilteringStrategy(FilteringStrategy.ACCEPT_ONE, TriggerPoint.ALL_RULES); tp.setOneRuleFilteringStrategy(FilteringStrategy.ACCEPT_ONE, TriggerPoint.ALL_RULES); tp.setMultipleRulesFilteringStrategy(FilteringStrategy.ACCEPT_ONE, TriggerPoint.ALL_RULES);