@Test public void testGetAllStructureNamesOfType() { NetworkFactory nf = new NetworkFactory(); Configuration c1 = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build(); nf.routingPolicyBuilder().setOwner(c1).setName("rp1").build(); nf.routingPolicyBuilder().setOwner(c1).setName("rp2").build(); Configuration c2 = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build(); nf.routingPolicyBuilder().setOwner(c1).setName("rp1").build(); Map<String, Configuration> configurations = ImmutableMap.of("node1", c1, "node2", c2); assertThat( getAllStructureNamesOfType( NamedStructurePropertySpecifier.ROUTING_POLICY, configurations.keySet(), configurations), equalTo(ImmutableSet.of("rp1", "rp2"))); }
public static Set<String> getAllStructureNamesOfType( String structureType, Set<String> nodes, Map<String, Configuration> configurations) { Set<String> structNames = new HashSet<>(); Function<Configuration, Object> structMapGetter = NamedStructurePropertySpecifier.JAVA_MAP.get(structureType).getGetter(); for (String node : nodes) { Object namedStructuresMap = structMapGetter.apply(configurations.get(node)); if (namedStructuresMap instanceof Map<?, ?>) { for (Map.Entry<?, ?> entry : ((Map<?, ?>) namedStructuresMap).entrySet()) { structNames.add((String) entry.getKey()); } } } return structNames; }
NamedStructuresAnswerer extends Answerer { public static Set<String> getAllStructureNamesOfType( String structureType, Set<String> nodes, Map<String, Configuration> configurations) { Set<String> structNames = new HashSet<>(); Function<Configuration, Object> structMapGetter = NamedStructurePropertySpecifier.JAVA_MAP.get(structureType).getGetter(); for (String node : nodes) { Object namedStructuresMap = structMapGetter.apply(configurations.get(node)); if (namedStructuresMap instanceof Map<?, ?>) { for (Map.Entry<?, ?> entry : ((Map<?, ?>) namedStructuresMap).entrySet()) { structNames.add((String) entry.getKey()); } } } return structNames; } }
NamedStructuresAnswerer extends Answerer { public static Set<String> getAllStructureNamesOfType( String structureType, Set<String> nodes, Map<String, Configuration> configurations) { Set<String> structNames = new HashSet<>(); Function<Configuration, Object> structMapGetter = NamedStructurePropertySpecifier.JAVA_MAP.get(structureType).getGetter(); for (String node : nodes) { Object namedStructuresMap = structMapGetter.apply(configurations.get(node)); if (namedStructuresMap instanceof Map<?, ?>) { for (Map.Entry<?, ?> entry : ((Map<?, ?>) namedStructuresMap).entrySet()) { structNames.add((String) entry.getKey()); } } } return structNames; } NamedStructuresAnswerer(Question question, IBatfish batfish); }
NamedStructuresAnswerer extends Answerer { public static Set<String> getAllStructureNamesOfType( String structureType, Set<String> nodes, Map<String, Configuration> configurations) { Set<String> structNames = new HashSet<>(); Function<Configuration, Object> structMapGetter = NamedStructurePropertySpecifier.JAVA_MAP.get(structureType).getGetter(); for (String node : nodes) { Object namedStructuresMap = structMapGetter.apply(configurations.get(node)); if (namedStructuresMap instanceof Map<?, ?>) { for (Map.Entry<?, ?> entry : ((Map<?, ?>) namedStructuresMap).entrySet()) { structNames.add((String) entry.getKey()); } } } return structNames; } NamedStructuresAnswerer(Question question, IBatfish batfish); static TableMetadata createMetadata(NamedStructuresQuestion question); @Override TableAnswerElement answer(NetworkSnapshot snapshot); static Set<String> getAllStructureNamesOfType(
      String structureType, Set<String> nodes, Map<String, Configuration> configurations); static boolean isAutoGenerated(String structName); }
NamedStructuresAnswerer extends Answerer { public static Set<String> getAllStructureNamesOfType( String structureType, Set<String> nodes, Map<String, Configuration> configurations) { Set<String> structNames = new HashSet<>(); Function<Configuration, Object> structMapGetter = NamedStructurePropertySpecifier.JAVA_MAP.get(structureType).getGetter(); for (String node : nodes) { Object namedStructuresMap = structMapGetter.apply(configurations.get(node)); if (namedStructuresMap instanceof Map<?, ?>) { for (Map.Entry<?, ?> entry : ((Map<?, ?>) namedStructuresMap).entrySet()) { structNames.add((String) entry.getKey()); } } } return structNames; } NamedStructuresAnswerer(Question question, IBatfish batfish); static TableMetadata createMetadata(NamedStructuresQuestion question); @Override TableAnswerElement answer(NetworkSnapshot snapshot); static Set<String> getAllStructureNamesOfType(
      String structureType, Set<String> nodes, Map<String, Configuration> configurations); static boolean isAutoGenerated(String structName); static final String COL_NODE; static final String COL_PRESENT_ON_NODE; static final String COL_STRUCTURE_TYPE; static final String COL_STRUCTURE_NAME; static final String COL_STRUCTURE_DEFINITION; }