/** Returns all structures of type {@code structureType} across {@code nodes} */ public static Set<String> getAllStructureNamesOfType( String structureType, Set<String> nodes, Map<String, Configuration> configurations) { Set<String> structNames = new HashSet<>(); Function<Configuration, Object> structMapGetter = NamedStructureSpecifier.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; }
@VisibleForTesting public static Set<String> getStructureNames(Map<String, Configuration> configurations) { ImmutableSet.Builder<String> structureNames = ImmutableSet.builder(); configurations .values() .forEach( configuration -> NamedStructureSpecifier.JAVA_MAP .values() .forEach( type -> { // fetch names of all defined structures of given type and configuration Object namedStructuresMap = type.getGetter().apply(configuration); // should be an instance of a Map if (namedStructuresMap instanceof Map<?, ?>) { ((Map<?, ?>) namedStructuresMap) .keySet() .forEach( key -> { if (key instanceof String) { structureNames.add((String) key); } }); } })); return structureNames.build(); }
/** * Uses {@code propertyDescriptor} to extract the property value from {@code object} and insert * into {@code row} at {@code columnName}. * * @throws ClassCastException if the recovered property value is not compatible with the specified * {@link Schema} in the {@code propertyDescriptor}. */ public static <T> void fillProperty( PropertyDescriptor<T> propertyDescriptor, T object, String columnName, RowBuilder row) { checkArgument(propertyDescriptor != null, "'propertyDescriptor' cannot be null"); checkArgument(object != null, "'object' cannot be null"); checkArgument(columnName != null, "'columnName' cannot be null"); checkArgument(row != null, "'row' cannot be null"); Object propertyValue = propertyDescriptor.getGetter().apply(object); propertyValue = PropertySpecifier.convertTypeIfNeeded(propertyValue, propertyDescriptor.getSchema()); fillProperty(columnName, propertyValue, row, propertyDescriptor); // separate for testing }
String.format( "Type mismatch between property value ('%s') and Schema ('%s') for property '%s' for VXLAN VNI settings '%s': %s", propertyDescriptor.getGetter().apply(vxlanVniProperties), propertyDescriptor.getSchema(), property,
String.format( "Type mismatch between property value ('%s') and Schema ('%s') for property '%s' for BGP process '%s->%s-%s': %s", propertyDescriptor.getGetter().apply(bgpProcess), propertyDescriptor.getSchema(), property,
String.format( "Type mismatch between property value ('%s') and Schema ('%s') for property '%s' for OSPF process '%s->%s-%s': %s", propertyDescriptor.getGetter().apply(ospfProcess), propertyDescriptor.getSchema(), property,
String.format( "Type mismatch between property value ('%s') and Schema ('%s') for property '%s' for interface '%s': %s", propertyDescriptor.getGetter().apply(iface), propertyDescriptor.getSchema(), property,
NamedStructureSpecifier.JAVA_MAP.get(structureType).getGetter();
String.format( "Type mismatch between property value ('%s') and Schema ('%s') for property '%s' for BGP peer '%s->%s-%s': %s", propertyDescriptor.getGetter().apply(peer), propertyDescriptor.getSchema(), property,