use of org.opendaylight.controller.config.facade.xml.mapping.attributes.toxml.AttributeWritingStrategy in project controller by opendaylight.
the class InstanceConfig method toXml.
@SuppressWarnings("IllegalCatch")
public Element toXml(final ObjectName on, final String namespace, final Document document, final Element rootElement, final EnumResolver enumResolver) {
Map<String, AttributeWritingStrategy> strats = new ObjectXmlWriter().prepareWriting(yangToAttrConfig, document);
Map<String, Object> mappedConfig = getMappedConfiguration(on, enumResolver);
Element parentElement;
if (nullableDummyContainerName != null) {
Element dummyElement = XmlUtil.createElement(document, nullableDummyContainerName, Optional.of(namespace));
rootElement.appendChild(dummyElement);
parentElement = dummyElement;
} else {
parentElement = rootElement;
}
for (Entry<String, ?> mappingEntry : mappedConfig.entrySet()) {
try {
strats.get(mappingEntry.getKey()).writeElement(parentElement, namespace, mappingEntry.getValue());
} catch (final RuntimeException e) {
throw new IllegalStateException("Unable to write value " + mappingEntry.getValue() + " for attribute " + mappingEntry.getValue(), e);
}
}
return rootElement;
}
Aggregations