public Graph getGraph() {
Class<Graph> gclass = gd.getGraphClass();
Graph g;
Map<String, GenericBean> beansList;
try {
g = gclass.getConstructor(GraphNode.class).newInstance(this);
beansList = ArgFactory.getBeanPropertiesMap(gclass, Graph.class);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
Util.log(this, logger, Level.ERROR, e, "Failed to build a graph instance %s", gclass.getCanonicalName());
return null;
}
for(Map.Entry<String, String> e: beans.entrySet()) {
String name = Util.parseTemplate(e.getKey(), probe);
String textValue = Util.parseTemplate(e.getValue(), probe);
GenericBean bean = beansList.get(name);
if(bean == null) {
logger.error(String.format("Unknown bean for %s: %s", gd.getName(), name));
continue;
}
logger.trace(Util.delayedFormatString("Found attribute %s with value %s", name, textValue));
bean.set(g, textValue);
}
return g;
}