Add support for identity-ref config attributes to config/netconf subsystem
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / ftl / model / ModuleField.java
index 293696d10e0887e3157412d9653bc87878791ef8..74e5bb0490c5de483a357476ecf3bde7b3aeb790 100644 (file)
@@ -7,31 +7,41 @@
  */
 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,
-            String attributeName, String nullableDefault, boolean isDependency,
-            Dependency dependency) {
-        super(modifiers, type, name);
-        this.nullableDefault = nullableDefault;
+    private ModuleField(List<String> modifiers, String type, String name, String attributeName, String nullableDefault,
+            boolean isDependency, Dependency dependency, boolean isListOfDependencies, boolean needsDepResolver) {
+        super(modifiers, type, name, null, needsDepResolver);
         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) {
-        this(Collections.<String> emptyList(), type, name, attributeName,
-                nullableDefault, isDependency, dependency);
+    public ModuleField(String type, String name, String attributeName, String nullableDefault, boolean isDependency,
+            Dependency dependency, boolean isListOfDependencies, boolean needsDepResolve) {
+        this(Collections.<String> emptyList(), type, name, attributeName, nullableDefault, isDependency, dependency,
+                isListOfDependencies, needsDepResolve);
+    }
+
+    public boolean isIdentityRef() {
+        return false;
     }
 
     public Dependency getDependency() {
@@ -46,7 +56,12 @@ public class ModuleField extends Field {
         return dependent;
     }
 
+    public boolean isListOfDependencies() {
+        return isListOfDependencies;
+    }
+
     public String getAttributeName() {
         return attributeName;
     }
+
 }