Bug 460 - Fix warning throughout netconf subsystem
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / mapping / CompositeAttributeMappingStrategy.java
index 252b13bf6850c498d6c122565044359647dd5520..594953e569e6c0c2c5531a8100e5e7f106f2d114 100644 (file)
@@ -35,8 +35,9 @@ public class CompositeAttributeMappingStrategy extends
 
     @Override
     public Optional<Map<String, Object>> mapAttribute(Object value) {
-        if (value == null)
+        if (value == null){
             return Optional.absent();
+        }
 
         Util.checkType(value, CompositeDataSupport.class);
 
@@ -53,17 +54,21 @@ public class CompositeAttributeMappingStrategy extends
         Map<String, Object> retVal = Maps.newHashMap();
 
         for (String jmxName : jmxToJavaNameMapping.keySet()) {
-            String innerAttrJmxName = jmxName;
-            Object innerValue = compositeData.get(innerAttrJmxName);
-
-            AttributeMappingStrategy<?, ? extends OpenType<?>> attributeMappingStrategy = innerStrategies
-                    .get(innerAttrJmxName);
-            Optional<?> mapAttribute = attributeMappingStrategy.mapAttribute(innerValue);
-            if (mapAttribute.isPresent())
-                retVal.put(jmxToJavaNameMapping.get(innerAttrJmxName), mapAttribute.get());
+            Optional<?> mapped = mapInnerAttribute(compositeData, jmxName, expectedType.getDescription(jmxName));
+            if(mapped.isPresent()){
+                retVal.put(jmxToJavaNameMapping.get(jmxName), mapped.get());
+            }
         }
 
         return Optional.of(retVal);
     }
 
+    protected Optional<?> mapInnerAttribute(CompositeDataSupport compositeData, String jmxName, String description) {
+        Object innerValue = compositeData.get(jmxName);
+
+        AttributeMappingStrategy<?, ? extends OpenType<?>> attributeMappingStrategy = innerStrategies
+                .get(jmxName);
+        return attributeMappingStrategy.mapAttribute(innerValue);
+    }
+
 }