public static GenerationDependencies fromXml(Element root) { String version = GenerationRootDependencies.getValue(root, ATTR_VERSION); if (version == null || !version.equals(Integer.toString(DEPENDENCIES_VERSION))) { /* regenerate all */ return null; } Map<String, String> externalHashes = new HashMap<String, String>(); for (Element e : ((List<Element>) root.getChildren(NODE_MODEL))) { String modelReference = GenerationRootDependencies.getValue(e, ATTR_MODEL_ID); String rootHash = GenerationRootDependencies.getValue(e, ATTR_HASH); if (modelReference != null) { externalHashes.put(modelReference, rootHash); } } List<GenerationRootDependencies> data = new ArrayList<GenerationRootDependencies>(); for (Element e : ((List<Element>) root.getChildren(NODE_COMMON))) { data.add(GenerationRootDependencies.fromXml(e, true)); } for (Element e : ((List<Element>) root.getChildren(NODE_ROOT))) { data.add(GenerationRootDependencies.fromXml(e, false)); } String modelHash = GenerationRootDependencies.getValue(root, ATTR_MODEL_HASH); String paramsHash = GenerationRootDependencies.getValue(root, ATTR_PARAMS_HASH); if (externalHashes.isEmpty() && data.isEmpty()) { return new GenerationDependencies(modelHash, paramsHash); } return new GenerationDependencies( data, modelHash, paramsHash, externalHashes, Collections.<GenerationRootDependencies>emptyList(), 0, 0); }