private Map<String, Map<String, IntExpr>> computeSourceInterfaceFieldValues() { Field sourceInterfaceField = _sourceInterfaceField; return toImmutableMap( _nodeInterfaces, Entry::getKey, entry -> { ImmutableMap.Builder<String, IntExpr> values = ImmutableMap.builder(); CommonUtil.forEachWithIndex( entry.getValue(), (index, iface) -> values.put(iface, new LitIntExpr(index + 1, sourceInterfaceField.getSize()))); return values.build(); }); }
@Override public String visitAclIpSpace(AclIpSpace aclIpSpace) { String metadataDescription = computeMetadataDescription(aclIpSpace); if (metadataDescription != null) { return metadataDescription; } ImmutableList.Builder<String> lineDescs = ImmutableList.builder(); CommonUtil.<AclIpSpaceLine>forEachWithIndex( aclIpSpace.getLines(), (i, line) -> lineDescs.add(String.format("%d: %s", i, line.getIpSpace().accept(this)))); return lineDescs.build().toString(); }
/** * A packet can enter a router from at most 1 interface, possibly none (if the packet originated * at the router). So for N srcInterfaces, we need N+1 distinct values (0 through N): one for each * interface, and one for "none of them". We use the last value (N) for "none of them". */ private static Map<String, BDD> computeMatchSourceBDDs( BDDInteger sourceVar, Set<String> activeAndReferenced, Set<String> activeButUnreferenced) { int bitsRequired = LongMath.log2( valuesRequired(activeAndReferenced, activeButUnreferenced), RoundingMode.CEILING); checkArgument( bitsRequired <= sourceVar.getBitvec().length, "sourceVar not big enough to track active and referenced sources"); ImmutableMap.Builder<String, BDD> matchSrcBDDs = ImmutableMap.builder(); CommonUtil.forEachWithIndex( activeAndReferenced, (idx, src) -> matchSrcBDDs.put(src, sourceVar.value(idx))); // Get the next unused identifier. This is used for all activeButUnreferenced sources int unreferencedSourceValue = activeAndReferenced.size(); activeButUnreferenced.forEach( src -> matchSrcBDDs.put(src, sourceVar.value(unreferencedSourceValue))); return matchSrcBDDs.build(); }
@Override public void visitAclLineIndependentMatch(AclLineIndependentMatch.State state) { /* * For each acl line, add a rule that its match condition (as a BooleanExpr) implies its * corresponding named state. */ _input .getAclConditions() .forEach( (hostname, aclConditionsByAclName) -> aclConditionsByAclName.forEach( (aclName, aclConditionsList) -> forEachWithIndex( aclConditionsList, (lineNumber, lineCriteria) -> _rules.add( new BasicRuleStatement( lineCriteria, new AclLineIndependentMatch( hostname, aclName, lineNumber)))))); }
switchportsByVlan.forEach( (vlanId, interfaceNames) -> { CommonUtil.forEachWithIndex( interfaceNames, (i, i1Name) -> {
TableView processAnswerTable2(TableAnswerElement rawTable, AnswerRowsOptions options) { Map<Row, Integer> rowIds = Maps.newIdentityHashMap(); CommonUtil.forEachWithIndex(rawTable.getRowsList(), (i, row) -> rowIds.put(row, i)); Map<String, ColumnMetadata> rawColumnMap = rawTable.getMetadata().toColumnMap(); List<Row> filteredRows =
CommonUtil.forEachWithIndex( _communityLists, (index, communityListName) -> {