Joins together a list of predicates by the 'and' token.
For combining multiple predicate together.
Source
static QueryPredicate andPredicates(Iterable<QueryPredicate> predicates) {
var predicateList = predicates.toList();
if (predicateList == null) {
return null;
}
if (predicateList.length == 0) {
return null;
}
if (predicateList.length == 1) {
return predicateList.first;
}
var predicateFormat =
"(" + predicateList.map((pred) => "${pred.format}").join(" AND ") + ")";
var valueMap = <String, dynamic>{};
predicateList.forEach((p) {
p.parameters?.forEach((k, v) {
if (valueMap.containsKey(k)) {
throw new QueryPredicateException(
"Duplicate keys in and predicate, $k appears in multiple predicates. Make keys more specific.");
}
valueMap[k] = v;
});
});
return new QueryPredicate(predicateFormat, valueMap);
}