Resolve Bug:445 Remove freemarker from config code generator.
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / ftl / model / Field.java
index ad5cbb287c73a4aef2cafebce6afb442f57fd1ed..3639b6d727274d9656c24a04cd62e09a7a3ae62a 100644 (file)
@@ -11,6 +11,8 @@ import com.google.common.collect.Lists;
 
 import java.util.List;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 public class Field {
     private final String type;
     private final String name;
@@ -36,11 +38,11 @@ public class Field {
     }
 
     public Field(List<String> modifiers, String type, String name,
-            String definition, boolean needsDepResolver) {
-        this.modifiers = modifiers;
-        this.type = type;
-        this.name = name;
-        this.definition = definition;
+            String nullableDefinition, boolean needsDepResolver) {
+        this.modifiers = checkNotNull(modifiers);
+        this.type = checkNotNull(type);
+        this.name = checkNotNull(name);
+        this.definition = nullableDefinition;
         this.needsDepResolver = needsDepResolver;
     }
 
@@ -56,6 +58,10 @@ public class Field {
         return type;
     }
 
+    public String getGenericInnerType() {
+        return type.substring(type.indexOf("<") + 1, type.indexOf(">"));
+    }
+
     public List<String> getModifiers() {
         return modifiers;
     }
@@ -71,4 +77,9 @@ public class Field {
     public boolean isArray() {
         return type.endsWith("[]");
     }
+
+    @Override
+    public String toString() {
+        return FieldSerializer.toString(this);
+    }
 }