[ONOS-4547, ONOS-4566, ONOS-4575, ONOS-4582, ONOS-4581, ONOS-4600,
ONOS-4598, ONOS-4607, ONOS-4610, ONOS-4611] Prefix addition from config
and defect fixes.
Change-Id: Ieaab5d3e0fe9a1bfa24a2527eeec5435cf0a1b85
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangList.java b/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
index 246ffa2..cd45bdc 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
@@ -444,8 +444,8 @@
validateConfig(leaves, leafLists);
/* A list must have atleast one key leaf if config is true */
- if (isConfig
- && (keys == null || leaves == null && leafLists == null && !isUsesPresentInList())) {
+ if (isConfig && (keys == null || leaves == null && leafLists == null) && !isUsesPresentInList()
+ && !isListPresentInGrouping()) {
throw new DataModelException("A list must have atleast one key leaf if config is true;");
} else if (keys != null) {
validateKey(leaves, leafLists, keys);
@@ -565,7 +565,7 @@
}
}
- if (!leafFound && !isUsesPresentInList()) {
+ if (!leafFound && !isUsesPresentInList() && !isListPresentInGrouping()) {
throw new DataModelException("An identifier, in key, must refer to a child leaf of the list");
}
leafFound = false;
@@ -617,6 +617,18 @@
node = node.getNextSibling();
}
return false;
+ // TODO When grouping linking is done this method has to be modified.
}
+ private boolean isListPresentInGrouping() {
+ YangNode node = this.getParent();
+ while (node != null) {
+ if (node instanceof YangGrouping) {
+ return true;
+ }
+ node = node.getParent();
+ }
+ return false;
+ // TODO When grouping linking is done this method has to be modified.
+ }
}