Merge "BUG-2470: add trace of failed modification"
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / ftl / TemplateFactory.java
index 7b7aab85597eafbd4fcb113abfea20dfe19c49d1..53ab4ef335973029568f0820968c830d59112f17 100644 (file)
@@ -10,6 +10,14 @@ package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.management.openmbean.SimpleType;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.IdentityAttributeRef;
 import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
@@ -44,15 +52,6 @@ import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
 import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 
-import javax.management.openmbean.SimpleType;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
 public class TemplateFactory {
 
     /**
@@ -113,7 +112,7 @@ public class TemplateFactory {
     static String serializeType(Type type, boolean addWildcards) {
         if (type instanceof ParameterizedType){
             ParameterizedType parameterizedType = (ParameterizedType) type;
-            StringBuffer sb = new StringBuffer();
+            StringBuilder sb = new StringBuilder();
             sb.append(parameterizedType.getRawType().getFullyQualifiedName());
             sb.append(addWildcards ? "<? extends " : "<");
             boolean first = true;
@@ -167,10 +166,11 @@ public class TemplateFactory {
                 Lists.<MethodDeclaration> newArrayList());
         sieTemplate.setJavadoc(sie.getNullableDescription());
 
-        if (sie.getNullableDescription() != null)
+        if (sie.getNullableDescription() != null) {
             sieTemplate.getAnnotations().add(
                     Annotation.createDescriptionAnnotation(sie
                             .getNullableDescription()));
+        }
         sieTemplate.getAnnotations().addAll(Annotation.createSieAnnotations(sie));
 
         return sieTemplate;
@@ -224,10 +224,11 @@ public class TemplateFactory {
                 attrProcessor.getMethods(), generateRuntime,
                 registratorFullyQualifiedName);
 
-        if (mbe.getNullableDescription() != null)
+        if (mbe.getNullableDescription() != null) {
             abstractModuleTemplate.getAnnotations().add(
                     Annotation.createDescriptionAnnotation(mbe
                             .getNullableDescription()));
+        }
         return abstractModuleTemplate;
     }
 
@@ -282,12 +283,15 @@ public class TemplateFactory {
         for (Rpc rpc : rbe.getRpcs()) {
             AttributeIfc returnType = rpc.getReturnType();
 
-            if (returnType == VoidAttribute.getInstance())
+            if (returnType == VoidAttribute.getInstance()) {
                 continue;
-            if (returnType instanceof JavaAttribute)
+            }
+            if (returnType instanceof JavaAttribute) {
                 continue;
-            if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType)
+            }
+            if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType) {
                 continue;
+            }
 
             Preconditions.checkState(yangPropertiesToTypesMap.containsKey(returnType.getAttributeYangName()) == false,
                     "Duplicate TO %s for %s", returnType.getAttributeYangName(), rbe);
@@ -449,7 +453,6 @@ public class TemplateFactory {
                 String returnType;
                 AttributeIfc attributeIfc = attrEntry.getValue();
 
-                boolean isIdentityRef = false;
                 if (attributeIfc instanceof TypedAttribute) {
                     TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
                     returnType = serializeType(typedAttribute.getType());
@@ -605,9 +608,8 @@ public class TemplateFactory {
 
                 String varName = BindingGeneratorUtil
                         .parseToValidParamName(attrEntry.getKey());
-                {
-                ModuleField field;
 
+                ModuleField field;
                 if (isIdentity) {
                     String identityBaseClass = getInnerTypeFromIdentity(((TypedAttribute) attributeIfc).getType());
                     IdentityRefModuleField identityField = new IdentityRefModuleField(type, varName,
@@ -639,7 +641,8 @@ public class TemplateFactory {
                             nullableDefaultWrapped, isDependency, dependency, isListOfDependencies, needsDepResolver);
                 }
                 moduleFields.add(field);
-                }
+
+
                 String getterName = "get"
                         + attributeIfc.getUpperCaseCammelCase();
                 MethodDefinition getter = new MethodDefinition(type,
@@ -686,8 +689,9 @@ public class TemplateFactory {
 
 
     private static boolean needsDepResolver(AttributeIfc value) {
-        if(value instanceof TOAttribute)
+        if(value instanceof TOAttribute) {
             return true;
+        }
         if(value instanceof ListAttribute) {
             AttributeIfc innerAttribute = ((ListAttribute) value).getInnerAttribute();
             return needsDepResolver(innerAttribute);