private static <T> Rule<T> findMatchedRule(Map<String, Comparative> allRuleColumnArgs, List<Rule<T>> rules,
Map<String, Comparative> matchArgs, ComparativeMapChoicer choicer, List<Object> args) {
for (Rule<T> r : rules) {
matchArgs.clear();
for (RuleColumn ruleColumn : r.getRuleColumns().values()) {
Comparative comparative = getComparative(ruleColumn.key, allRuleColumnArgs, choicer, args);
if (comparative == null) {
break;
}
matchArgs.put(ruleColumn.key, comparative);
}
if (matchArgs.size() == r.getRuleColumns().size()) {
return r; //��ȫƥ��
}
}
for (Rule<T> r : rules) {
matchArgs.clear();
int mandatoryColumnCount = 0;
for (RuleColumn ruleColumn : r.getRuleColumns().values()) {
if (!ruleColumn.needAppear) {
continue;
}
mandatoryColumnCount++;
Comparative comparative = getComparative(ruleColumn.key, allRuleColumnArgs, choicer, args);
if (comparative == null) {
break;
}
matchArgs.put(ruleColumn.key, comparative);
}
if (mandatoryColumnCount != 0 && matchArgs.size() == mandatoryColumnCount) {
return r; //��ѡ��ƥ��
}
}
//���û�б�ѡ�еĹ����磺rule=..#a?#..#b?#.. ����ֻ��a����b����sql����
arule: for (Rule<T> r : rules) {
matchArgs.clear();
for (RuleColumn ruleColumn : r.getRuleColumns().values()) {
if (ruleColumn.needAppear)
continue arule; //�����ǰ�����б�ѡ�ֱ������,��Ϊ�ߵ������ѡ���Ѿ���ƥ����
Comparative comparative = getComparative(ruleColumn.key, allRuleColumnArgs, choicer, args);
if (comparative != null) {
matchArgs.put(ruleColumn.key, allRuleColumnArgs.get(ruleColumn.key));
}
}
if (matchArgs.size() != 0) {