Fix YangTemplate key statement generation 77/67677/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 29 Jan 2018 14:39:16 +0000 (15:39 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 29 Jan 2018 14:40:06 +0000 (15:40 +0100)
key statement should be terminated by a semicolon and it should be
emitted only if the key definition is really present.

Change-Id: I499b697be586d5cf92149a14a8ca763ba2272816
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/YangTemplate.xtend

index 630b088cec4f0771492a0a503a32f5c2cf4f6596..c34890e2f79df96682ddc879701ef27275291aee 100644 (file)
@@ -657,8 +657,9 @@ class YangTemplate {
 
         '''
             list «listSchemaNode.getQName.localName» {
-                key «FOR listKey : listSchemaNode.keyDefinition SEPARATOR " "»"«listKey.localName»"
-                «ENDFOR»
+                «IF !listSchemaNode.keyDefinition.empty»
+                    key «FOR listKey : listSchemaNode.keyDefinition SEPARATOR " "»"«listKey.localName»"«ENDFOR»;
+                «ENDIF»
                 «IF !listSchemaNode.childNodes.nullOrEmpty»
                     «writeDataSchemaNodes(listSchemaNode.childNodes)»
                 «ENDIF»