removed code duplication in translator, and addressed review comments
Change-Id: I27767a81c4bf279c80d2b98192f75f8f507b4457
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/AttributeInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/AttributeInfo.java
index f2c1562..9cb1c28 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/AttributeInfo.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/AttributeInfo.java
@@ -16,20 +16,12 @@
package org.onosproject.yangutils.translator.tojava;
-import java.io.Serializable;
-
import org.onosproject.yangutils.datamodel.YangType;
-import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType;
/**
* Maintains the attribute info corresponding to class/interface generated.
*/
-public class AttributeInfo implements Serializable {
-
- /**
- * version of serialized info.
- */
- private static final long serialVersionUID = 201602151004L;
+public class AttributeInfo {
/**
* The data type info of attribute.
@@ -44,7 +36,7 @@
/**
* If the added attribute is a list of info.
*/
- private boolean isListAttr;
+ private boolean isListAttr = false;
/**
* If the added attribute has to be accessed in a fully qualified manner.
@@ -52,6 +44,12 @@
private boolean isQualifiedName;
/**
+ * The class info will be used to set the attribute type and package info
+ * will be use for qualified name.
+ */
+ private ImportInfo importInfo;
+
+ /**
* Default constructor.
*/
public AttributeInfo() {
@@ -60,7 +58,7 @@
/**
* Get the data type info of attribute.
*
- * @return the data type info of attribute.
+ * @return the data type info of attribute
*/
public YangType<?> getAttributeType() {
return attrType;
@@ -69,19 +67,17 @@
/**
* Set the data type info of attribute.
*
- * @param type the data type info of attribute.
+ * @param type the data type info of attribute
*/
public void setAttributeType(YangType<?> type) {
- if (type != null) {
- attrType = AttributesJavaDataType.getJavaDataType(type);
- }
+ attrType = type;
}
/**
* Get name of the attribute.
*
- * @return name of the attribute.
+ * @return name of the attribute
*/
public String getAttributeName() {
return name;
@@ -90,7 +86,7 @@
/**
* Set name of the attribute.
*
- * @param attrName name of the attribute.
+ * @param attrName name of the attribute
*/
public void setAttributeName(String attrName) {
name = attrName;
@@ -99,7 +95,7 @@
/**
* Get if the added attribute is a list of info.
*
- * @return the if the added attribute is a list of info.
+ * @return the if the added attribute is a list of info
*/
public boolean isListAttr() {
return isListAttr;
@@ -108,7 +104,7 @@
/**
* Set if the added attribute is a list of info.
*
- * @param isList if the added attribute is a list of info.
+ * @param isList if the added attribute is a list of info
*/
public void setListAttr(boolean isList) {
isListAttr = isList;
@@ -130,10 +126,29 @@
* manner.
*
* @param isQualified if the added attribute has to be accessed in a fully
- * qualified manner.
+ * qualified manner
*/
public void setQualifiedName(boolean isQualified) {
isQualifiedName = isQualified;
}
+ /**
+ * Get the import info for the attribute type. It will be null, of the type
+ * is basic built-in java type.
+ *
+ * @return import info
+ */
+ public ImportInfo getImportInfo() {
+ return importInfo;
+ }
+
+ /**
+ * Set the import info for the attribute type.
+ *
+ * @param importInfo import info for the attribute type
+ */
+ public void setImportInfo(ImportInfo importInfo) {
+ this.importInfo = importInfo;
+ }
+
}