*/
package org.opendaylight.yangtools.sal.binding.generator.impl
+import com.google.common.base.CharMatcher
import java.util.Collection
import java.util.Date
import java.util.List
import java.util.Set
import java.util.StringTokenizer
import org.opendaylight.yangtools.yang.common.QName
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil
import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
import org.opendaylight.yangtools.yang.model.api.RpcDefinition
import org.opendaylight.yangtools.yang.model.api.SchemaNode
import org.opendaylight.yangtools.yang.model.api.SchemaPath
+import org.opendaylight.yangtools.yang.model.api.Status
import org.opendaylight.yangtools.yang.model.api.TypeDefinition
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode
import org.opendaylight.yangtools.yang.model.api.UsesNode
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil
-import com.google.common.base.CharMatcher
class YangTemplate {
}
def static writeRPC(RpcDefinition rpc) {
+ var boolean isStatusDeprecated = rpc.status == Status::DEPRECATED
'''
rpc «rpc.QName.localName» {
«IF !rpc.description.nullOrEmpty»
reference
"«rpc.reference»";
«ENDIF»
- «IF rpc.status != null»
+ «IF isStatusDeprecated»
status «rpc.status»;
«ENDIF»
}
}
def static writeNotification(NotificationDefinition notification) {
+ var boolean isStatusDeprecated = notification.status == Status::DEPRECATED
'''
notification «notification.QName.localName» {
«IF !notification.description.nullOrEmpty»
reference
"«notification.reference»";
«ENDIF»
- «IF notification.status != null»
+ «IF isStatusDeprecated»
status «notification.status»;
«ENDIF»
}
}
def static writeTypeDefinition(TypeDefinition<?> typeDefinition) {
+ var boolean isStatusDeprecated = typeDefinition.status == Status::DEPRECATED
'''
- type «typeDefinition.QName.localName»;
+ type «typeDefinition.QName.localName»«IF !isStatusDeprecated»;«ELSE» {
+ status «typeDefinition.status»;
+ }
+ «ENDIF»
'''
}
}
def static writeGroupingDef(GroupingDefinition groupingDef) {
+ var boolean isStatusDeprecated = groupingDef.status == Status::DEPRECATED
'''
grouping «groupingDef.QName.localName» {
«IF !groupingDef.groupings.nullOrEmpty»
«IF !groupingDef.childNodes.nullOrEmpty»
«writeDataSchemaNodes(groupingDef.childNodes)»
«ENDIF»
+ «IF isStatusDeprecated»
+ status «groupingDef.status»;
+ «ENDIF»
«IF !groupingDef.unknownSchemaNodes.nullOrEmpty»
«writeUnknownSchemaNodes(groupingDef.unknownSchemaNodes)»
«ENDIF»
}
def static writeContSchemaNode(ContainerSchemaNode contSchemaNode) {
+ var boolean isStatusDeprecated = contSchemaNode.status == Status::DEPRECATED
'''
container «contSchemaNode.getQName.localName» {
«IF !contSchemaNode.childNodes.nullOrEmpty»
«IF !contSchemaNode.uses.nullOrEmpty»
«writeUsesNodes(contSchemaNode.uses)»
«ENDIF»
+ «IF isStatusDeprecated»
+ status «contSchemaNode.status»;
+ «ENDIF»
«IF !contSchemaNode.unknownSchemaNodes.nullOrEmpty»
«writeUnknownSchemaNodes(contSchemaNode.unknownSchemaNodes)»
«ENDIF»
}
def static writeAnyXmlSchemaNode(AnyXmlSchemaNode anyXmlSchemaNode) {
+ var boolean isStatusDeprecated = anyXmlSchemaNode.status == Status::DEPRECATED
'''
- anyxml «anyXmlSchemaNode.getQName.localName»;
+ anyxml «anyXmlSchemaNode.getQName.localName»«IF !isStatusDeprecated»;«ELSE» {
+ status «anyXmlSchemaNode.status»;
+ }
+ «ENDIF»
'''
}
def static writeLeafSchemaNode(LeafSchemaNode leafSchemaNode) {
+ var boolean isStatusDeprecated = leafSchemaNode.status == Status::DEPRECATED
'''
leaf «leafSchemaNode.getQName.localName» {
type «leafSchemaNode.type.getQName.localName»;
+ «IF isStatusDeprecated»
+ status «leafSchemaNode.status»;
+ «ENDIF»
}
'''
}
def static writeLeafListSchemaNode(LeafListSchemaNode leafListSchemaNode) {
+ var boolean isStatusDeprecated = leafListSchemaNode.status == Status::DEPRECATED
'''
leaf-list «leafListSchemaNode.getQName.localName» {
type «leafListSchemaNode.type.getQName.localName»;
+ «IF isStatusDeprecated»
+ status «leafListSchemaNode.status»;
+ «ENDIF»
}
'''
}
def static writeChoiceCaseNode(ChoiceCaseNode choiceCaseNode) {
+ var boolean isStatusDeprecated = choiceCaseNode.status == Status::DEPRECATED
'''
case «choiceCaseNode.getQName.localName» {
«FOR childNode : choiceCaseNode.childNodes»
«writeDataSchemaNode(childNode)»
«ENDFOR»
+ «IF isStatusDeprecated»
+ status «choiceCaseNode.status»;
+ «ENDIF»
}
'''
}
def static writeChoiceNode(ChoiceSchemaNode choiceNode) {
+ var boolean isStatusDeprecated = choiceNode.status == Status::DEPRECATED
'''
choice «choiceNode.getQName.localName» {
«FOR child : choiceNode.cases»
«writeDataSchemaNode(child)»
«ENDFOR»
+ «IF isStatusDeprecated»
+ status «choiceNode.status»;
+ «ENDIF»
}
'''
}
def static writeListSchemaNode(ListSchemaNode listSchemaNode) {
+ var boolean isStatusDeprecated = listSchemaNode.status == Status::DEPRECATED
+
'''
list «listSchemaNode.getQName.localName» {
key «FOR listKey : listSchemaNode.keyDefinition SEPARATOR " "»"«listKey.localName»"
«IF !listSchemaNode.uses.nullOrEmpty»
«writeUsesNodes(listSchemaNode.uses)»
«ENDIF»
+ «IF isStatusDeprecated»
+ status «listSchemaNode.status»;
+ «ENDIF»
«IF !listSchemaNode.unknownSchemaNodes.nullOrEmpty»
«writeUnknownSchemaNodes(listSchemaNode.unknownSchemaNodes)»
«ENDIF»