/** Reduce an entire {@link IpAccessList} to a single {@link AclLineMatchExpr}. */ public static AclLineMatchExpr toAclLineMatchExpr( @Nonnull IpAccessListToBDD ipAccessListToBDD, IpAccessList acl, Map<String, IpAccessList> namedAcls) { return new AclToAclLineMatchExpr(ipAccessListToBDD, namedAcls).toAclLineMatchExpr(acl); }
private Map<String, Supplier<AclLineMatchExpr>> createThunks( Map<String, IpAccessList> namedAcls) { ImmutableMap.Builder<String, Supplier<AclLineMatchExpr>> thunks = ImmutableMap.builder(); namedAcls.forEach( (name, acl) -> thunks.put(name, new NonRecursiveSupplier<>(() -> this.toAclLineMatchExpr(acl)))); return thunks.build(); }
private static AclLineMatchExprWithProvenance<IpAccessListLineIndex> explainWithProvenance( IpAccessListToBDD ipAccessListToBDD, IpAccessList acl, Map<String, IpAccessList> namedAcls, IdentityHashMap<AclLineMatchExpr, IpAccessListLineIndex> literalsToLines) { // Convert acl to a single expression. AclLineMatchExpr aclExpr = AclToAclLineMatchExpr.toAclLineMatchExpr(ipAccessListToBDD, acl, namedAcls); // Reduce that expression to normal form. AclLineMatchExpr aclExprNf = AclLineMatchExprNormalizer.normalize(ipAccessListToBDD, aclExpr); // Simplify the normal form AclLineMatchExprWithProvenance<AclLineMatchExpr> aclExprNfExplained = AclExplanation.explainNormalForm(aclExprNf); // join the provenance information from the normal form with the literalsToLines mapping // above to obtain provenance back to the original acl lines 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); }