Bug 8002 - Fixing and cleanup of templates for binding2
[mdsal.git] / binding2 / mdsal-binding2-generator-impl / src / main / twirl / org / opendaylight / mdsal / binding / javav2 / generator / impl / yangTemplateWriteUsesNodes.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.yangtools.yang.model.api.DataSchemaNode
17 @import org.opendaylight.yangtools.yang.model.api.Module
18 @import org.opendaylight.yangtools.yang.model.api.UsesNode
19
20 @(usesNodes: Set[_ <: UsesNode], module: Module)
21 @if(usesNodes != null) {
22     @for(usesNode <- usesNodes) {
23         @if(usesNode != null) {
24             uses @{usesNode.getGroupingPath().getLastComponent().getLocalName()}@if(usesNode.getRefines().isEmpty()) {;} else { {
25                 @for(path <- usesNode.getRefines().keySet()) {
26                     refine @{path.getLastComponent().getLocalName()} {
27                     @if(usesNode.getRefines().get(path).isInstanceOf[DataSchemaNode]) {
28                             @if(usesNode.getRefines().get(path).asInstanceOf[DataSchemaNode].getDescription() != null){
29                                 description "@{usesNode.getRefines().get(path).asInstanceOf[DataSchemaNode].getDescription()}";
30                             }
31                             @yangTemplateWriteDataSchemaNode(usesNode.getRefines().get(path).asInstanceOf[DataSchemaNode], module)
32                         }
33                     }
34                 }
35                 }
36             }
37         }
38     }
39 }