5ee18de975687b012a2299882c67d056c7e93c29
[mdsal.git] / binding2 / mdsal-binding2-generator-impl / src / main / twirl / org / opendaylight / mdsal / binding / javav2 / generator / impl / yangTemplateForModule.scala.txt
1 @*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *@
8
9 @**********************************************************
10 * Twirl YangTemplate for generating yang snippets.        *
11 * Twirl is transformed to Scala and compiled. Then,       *
12 * it can be called from Java with particular input        *
13 * parameters to render desired output code.               *
14 ***********************************************************@
15
16 @import org.opendaylight.mdsal.binding.javav2.generator.impl.util.YangTextTemplate
17 @import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil
18 @import org.opendaylight.yangtools.yang.model.api.Module
19 @import org.opendaylight.yangtools.yang.model.api.DocumentedNode
20 @import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement
21 @import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement
22
23 @(module: Module)
24 @if(module != null) {
25     @generateYangSnippet(module)
26 }
27
28 @generateYangSnippet(module: Module) = {
29     module @{module.getName()} {
30         yang-version @module.getYangVersion();
31         namespace "@module.getNamespace().toString()";
32         prefix "@module.getPrefix()";
33
34         @if(module.getImports() != null && !module.getImports().isEmpty()) {
35             @for(moduleImport <- module.getImports()) {
36                 @if(moduleImport != null && moduleImport.getModuleName() != "") {
37                     import @{moduleImport.getModuleName()} { prefix "@{moduleImport.getPrefix()}"; revision-date @{SimpleDateFormatUtil.getRevisionFormat().format(moduleImport.getRevision())}; }
38                 }
39             }
40         }
41         @if(module.getRevision() != null) {
42             revision @{SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision())} {
43                 @for(effectiveStatement <- module.asInstanceOf[EffectiveStatement[_, _]].effectiveSubstatements()){
44                     @if(effectiveStatement.getDeclared().isInstanceOf[RevisionStatement]){
45                         description "@{effectiveStatement.asInstanceOf[DocumentedNode].getDescription()}";
46                     }
47                 }
48             }
49         }
50         @if(module.getTypeDefinitions() != null && !module.getTypeDefinitions().isEmpty()){
51             @yangTemplateWriteTypeDefs(module.getTypeDefinitions())
52         }
53         @if(module.getChildNodes() != null) {
54             @yangTemplateWriteDataSchemaNodes(module.getChildNodes(), module)
55         }
56         @if(module.getGroupings() != null && !module.getGroupings().isEmpty()) {
57             @yangTemplateWriteGroupingDefs(module.getGroupings(), module)
58         }
59         @if(module.getAugmentations() != null && !module.getAugmentations().isEmpty()) {
60             @yangTemplateWriteAugments(module.getAugmentations(), module)
61         }
62         @if(module.getDeviations() != null && !module.getDeviations().isEmpty()) {
63             @yangTemplateWriteDeviations(module.getDeviations())
64         }
65         @if(module.getExtensionSchemaNodes() != null && !module.getExtensionSchemaNodes().isEmpty()) {
66             @for(extension <- module.getExtensionSchemaNodes()) {
67                 @if(extension != null) {
68                     @yangTemplateWriteExtension(extension)
69                 }
70             }
71         }
72         @if(module.getFeatures() != null && !module.getFeatures().isEmpty()) {
73             @for(feature <- module.getFeatures()) {
74                 @if(feature != null) {
75                     @yangTemplateWriteFeature(feature)
76                 }
77             }
78         }
79         @if(module.getIdentities() != null && !module.getIdentities().isEmpty()) {
80             @for(identity <- module.getIdentities()) {
81                 @if(identity != null) {
82                     @yangTemplateWriteIdentity(identity)
83                 }
84             }
85         }
86         @if(module.getNotifications() != null && !module.getNotifications().isEmpty()) {
87             @for(notification <- module.getNotifications()) {
88                 @if(notification != null) {
89                     @yangTemplateWriteNotification(notification, module)
90                 }
91             }
92         }
93         @if(module.getRpcs() != null && !module.getRpcs().isEmpty()) {
94             @for(rpc <- module.getRpcs()) {
95                 @if(rpc != null) {
96                     @yangTemplateWriteRPC(rpc, module)
97                 }
98             }
99         }
100         @if(module.getUnknownSchemaNodes() != null && !module.getUnknownSchemaNodes().isEmpty()) {
101             @yangTemplateWriteUnknownSchemaNodes(module.getUnknownSchemaNodes(), module)
102         }
103         @if(module.getUses() != null && !module.getUses().isEmpty()) {
104             @yangTemplateWriteUsesNodes(module.getUses(), module)
105         }
106     }
107 }