// There should not be two graphs in the same serialization,
// but just in case ....
Object prior = context.get(GraphModel.class);
try {
GraphModel result = new GraphModel();
context.put(GraphModel.class, result);
while (reader.hasMoreChildren()) {
reader.moveDown();
String childName = reader.getNodeName();
Class<?> childClass = mapper.realClass(childName);
if (GraphNode.class.isAssignableFrom(childClass)) {
GraphNode node = (GraphNode) context.convertAnother(null, childClass);
result.addNode(node);
}
else if (GraphEdge.class.isAssignableFrom(childClass)) {
GraphEdge edge =
(GraphEdge) context.convertAnother(null, childClass);
result.addEdge(edge);
} else {
logger.info("Skipped object with tag " + childName);
}
reader.moveUp();