[ONOS-5058][ONOS-4796][ONOS-4893]compiler annotation implementation + defect fix
Change-Id: Ie317409d9ab1d36e626433558b2d51f26daaac82
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
index aa8b53f..7c82175 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
@@ -41,7 +41,9 @@
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.QUEUE;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
+import static org.onosproject.yangutils.utils.UtilConstants.SET;
import static java.util.Collections.sort;
/**
@@ -55,6 +57,16 @@
private boolean isListToImport;
/**
+ * Flag to denote if any queue is imported due to compiler annotation.
+ */
+ private boolean isQueueToImport;
+
+ /**
+ * Flag to denote if any set is imported due to compiler annotation.
+ */
+ private boolean isSetToImport;
+
+ /**
* Sorted set of import info, to be used to maintain the set of classes to
* be imported in the generated class.
*/
@@ -86,6 +98,42 @@
}
/**
+ * Is Queue to be imported due to compiler annotations.
+ *
+ * @return status of queue import
+ */
+ public boolean isQueueToImport() {
+ return isQueueToImport;
+ }
+
+ /**
+ * Is Set to be imported due to compiler annotations.
+ *
+ * @return status of set import
+ */
+ public boolean isSetToImport() {
+ return isSetToImport;
+ }
+
+ /**
+ * Sets the status of the queue to be imported due to compiler annotations.
+ *
+ * @param queueToImport status of queue to import
+ */
+ public void setQueueToImport(boolean queueToImport) {
+ isQueueToImport = queueToImport;
+ }
+
+ /**
+ * Sets the status of the set to be imported due to compiler annotations.
+ *
+ * @param setToImport status of set to import
+ */
+ public void setSetToImport(boolean setToImport) {
+ isSetToImport = setToImport;
+ }
+
+ /**
* Returns the set containing the imported class/interface info.
*
* @return the set containing the imported class/interface info
@@ -124,7 +172,7 @@
if (newImportInfo.getClassInfo().contentEquals(className)) {
/*
- * if the current class name is same as the attribute class name,
+ * If the current class name is same as the attribute class name,
* then the attribute must be accessed in a qualified manner.
*/
return true;
@@ -157,7 +205,7 @@
}
/*
- * import is added, so it is a member for non qualified access
+ * Import is added, so it is a member for non qualified access
*/
getImportSet().add(newImportInfo);
return false;
@@ -187,6 +235,14 @@
imports.add(getImportForList());
}
+ if (isQueueToImport()) {
+ imports.add(getImportForQueue());
+ }
+
+ if (isSetToImport()) {
+ imports.add(getImportForSet());
+ }
+
sort(imports);
return imports;
}
@@ -228,6 +284,24 @@
}
/**
+ * Returns import for queue attribute.
+ *
+ * @return import for queue attribute
+ */
+ public String getImportForQueue() {
+ return IMPORT + COLLECTION_IMPORTS + PERIOD + QUEUE + SEMI_COLAN + NEW_LINE;
+ }
+
+ /**
+ * Returns import for set attribute.
+ *
+ * @return import for set attribute
+ */
+ public String getImportForSet() {
+ return IMPORT + COLLECTION_IMPORTS + PERIOD + SET + SEMI_COLAN + NEW_LINE;
+ }
+
+ /**
* Returns import string for ListenerService class.
*
* @return import string for ListenerService class