Fix checkstyle warnings for config-netconf-connector
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / fromxml / CompositeAttributeReadingStrategy.java
index fdbfb98e1ca7e9f57c6421eda42f0c3bbd2d93c7..99c8ef5e99b561683ec20d28d16e3e681da57fa0 100644 (file)
@@ -11,11 +11,11 @@ package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attri
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
-
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
 
 public class CompositeAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
 
@@ -28,7 +28,7 @@ public class CompositeAttributeReadingStrategy extends AbstractAttributeReadingS
     }
 
     @Override
-    AttributeConfigElement readElementHook(List<XmlElement> configNodes) {
+    AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException {
 
         Preconditions.checkState(configNodes.size() == 1, "This element should be present only once %s", configNodes);
 
@@ -38,12 +38,18 @@ public class CompositeAttributeReadingStrategy extends AbstractAttributeReadingS
 
         List<XmlElement> recognisedChildren = Lists.newArrayList();
         for (Entry<String, AttributeReadingStrategy> innerAttrEntry : innerStrategies.entrySet()) {
-            List<XmlElement> childItem = complexElement.getChildElementsWithSameNamespace(innerAttrEntry.getKey());
+            List<XmlElement> childItem = complexElement.getChildElementsWithSameNamespace(
+                    innerAttrEntry.getKey());
             recognisedChildren.addAll(childItem);
 
             AttributeConfigElement resolvedInner = innerAttrEntry.getValue().readElement(childItem);
 
-            innerMap.put(innerAttrEntry.getKey(), resolvedInner.getValue());
+            Object value = resolvedInner.getValue();
+            if(value == null) {
+                value = resolvedInner.getDefaultValue();
+            }
+
+            innerMap.put(innerAttrEntry.getKey(), value);
         }
 
         complexElement.checkUnrecognisedElements(recognisedChildren);