private static AclLineMatchExprWithProvenance<IpAccessListLineIndex> explainWithProvenance(
IpAccessListToBDD ipAccessListToBDD,
IpAccessList acl,
Map<String, IpAccessList> namedAcls,
IdentityHashMap<AclLineMatchExpr, IpAccessListLineIndex> literalsToLines) {
AclLineMatchExpr aclExpr =
AclToAclLineMatchExpr.toAclLineMatchExpr(ipAccessListToBDD, acl, namedAcls);
AclLineMatchExpr aclExprNf = AclLineMatchExprNormalizer.normalize(ipAccessListToBDD, aclExpr);
AclLineMatchExprWithProvenance<AclLineMatchExpr> aclExprNfExplained =
AclExplanation.explainNormalForm(aclExprNf);
IdentityHashMap<AclLineMatchExpr, Set<IpAccessListLineIndex>> conjunctsToLines =
new IdentityHashMap<>();
for (Map.Entry<AclLineMatchExpr, Set<AclLineMatchExpr>> entry :
aclExprNfExplained.getProvenance().entrySet()) {
AclLineMatchExpr conjunct = entry.getKey();
conjunctsToLines.put(
conjunct,
entry.getValue().stream()
.map(literalsToLines::get)
.collect(ImmutableSet.toImmutableSet()));
}
return new AclLineMatchExprWithProvenance<>(
aclExprNfExplained.getMatchExpr(), conjunctsToLines);
}