getFilteredPolicy method
Returns the filtered policy rules of section sec
and policy type ptype
.
sec
is the section, "p" or "g".
ptype
is the policy type, "p", "p2", .. or "g", "g2", ..
fieldIndex
is the policy rule's start index to be matched.
fieldValues
are the field values to be matched, value "" means not to match this field.
Implementation
List<List<String>> getFilteredPolicy(
String sec,
String ptype,
int fieldIndex,
List<String> fieldValues,
) {
var res = <List<String>>[];
for (var rule in model[sec]![ptype]!.policy) {
var matched = true;
for (var i = 0; i < fieldValues.length; i++) {
var fieldValue = fieldValues[i];
if (fieldValue != '' && rule[fieldIndex + i] != fieldValue) {
matched = false;
break;
}
}
if (matched) {
res.add(rule);
}
}
return res;
}