Merge "Lazily initialize jaxb context in NB application"
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / ftl / model / ModuleField.java
index 293696d10e0887e3157412d9653bc87878791ef8..aff7af2811f061ba762d4789e088b4fb3c0c41f1 100644 (file)
@@ -7,31 +7,38 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
 
+
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.Dependency;
+
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute.Dependency;
-
 public class ModuleField extends Field {
 
     private final String nullableDefault, attributeName;
-    private final boolean dependent;
+    private final boolean dependent, isListOfDependencies;
     private final Dependency dependency;
 
-    public ModuleField(List<String> modifiers, String type, String name,
+    private ModuleField(List<String> modifiers, String type, String name,
             String attributeName, String nullableDefault, boolean isDependency,
-            Dependency dependency) {
+            Dependency dependency, boolean isListOfDependencies) {
         super(modifiers, type, name);
-        this.nullableDefault = nullableDefault;
         this.dependent = isDependency;
         this.dependency = dependency;
         this.attributeName = attributeName;
+        if (type.startsWith(List.class.getName()) && nullableDefault == null) {
+            String generics = type.substring(List.class.getName().length());
+            nullableDefault = "new " + ArrayList.class.getName() + generics + "()";
+        }
+        this.nullableDefault = nullableDefault;
+        this.isListOfDependencies = isListOfDependencies;
     }
 
     public ModuleField(String type, String name, String attributeName,
-            String nullableDefault, boolean isDependency, Dependency dependency) {
+            String nullableDefault, boolean isDependency, Dependency dependency, boolean isListOfDependencies) {
         this(Collections.<String> emptyList(), type, name, attributeName,
-                nullableDefault, isDependency, dependency);
+                nullableDefault, isDependency, dependency, isListOfDependencies);
     }
 
     public Dependency getDependency() {
@@ -46,7 +53,12 @@ public class ModuleField extends Field {
         return dependent;
     }
 
+    public boolean isListOfDependencies() {
+        return isListOfDependencies;
+    }
+
     public String getAttributeName() {
         return attributeName;
     }
+
 }