Adding yangtools chapter for review 91/11291/1
authorsthiruva <shahidat@gmail.com>
Wed, 17 Sep 2014 14:33:35 +0000 (20:03 +0530)
committersthiruva <shahidat@gmail.com>
Wed, 17 Sep 2014 14:35:03 +0000 (20:05 +0530)
Change-Id: Iac1084f38e06a37c0e394d05e46dfd5f250b795c
Signed-off-by: sthiruva <shahidat@gmail.com>
manuals/developers-guide/src/main/asciidoc/yangtools.adoc

index 935e8a08ecd06d5dc18641d4b9bdba110e73959d..e3411b070c8228243745175ee29efecb9e9dcb32 100644 (file)
-== Yangtools
-
-Chapter on Yang tools
-
+== YANG Tools\r
+YANG is a data modelling language used to model configuration and state data manipulated by the Network Configuration Protocol(NETCONF), NETCONF remote procedure calls, and NETCONF notifications.\r
+YANG is used to model the operations and content layers of NETCONF. \r
+\r
+=== Prerequisites for YANG Tools Project\r
+* OpenDayLight account +\r
+  https://identity.opendaylight.org/carbon/user-registration/index.jsp?region=region1&item=user_registration_menu[Get an account] to push or edit code on the wiki. You can however pull code anonymously.\r
+* Gerrit Setup for code review +\r
+  To use shh follow instructions on  Opendaylight wiki page at: https://wiki.opendaylight.org/view/OpenDaylight_Controller:Gerrit_Setup +\r
+  To use https follow instructions on  Opendaylight wiki page at: https://wiki.opendaylight.org/view/OpenDaylight_Controller:Setting_up_HTTP_in_Gerrit\r
+* Maven 3 to import Maven project from OpendayLight Git repository +\r
+  To clone the controller follow instructions at: https://git.opendaylight.org/gerrit/p/controller.git  +\r
+  To clone the yangtools repositories follow instructions at: https://git.opendaylight.org/gerrit/p/yangtools.git\r
+\r
+NOTE: You need to setup Gerrit  to access GIT using ssh.\r
+\r
+=== Pulling code using ssh\r
+To pull code using ssh use the following command: +\r
+\r
+       git clone ssh://${ODL_USERNAME}@git.opendaylight.org:29418/yangtools.git;(cd yangtools; scp -p -P 29418 ${ODL_USERNAME}@git.opendaylight.org:hooks/commit-msg .git/hooks/;chmod 755 .git/hooks/commit-msg;git config remote.origin.push HEAD:refs/for/master)\r
+\r
+=== Pulling code using https\r
+To pull code using https, use the following command: +\r
+\r
+       git clone https://git.opendaylight.org/gerrit/p/yangtools.git;(cd yangtools; curl -o .git/hooks/commit-msg https://git.opendaylight.org/gerrit/tools/hooks/commit-msg;chmod 755 .git/hooks/commit-msg;git config remote.origin.push HEAD:refs/for/master)\r
+\r
+=== Building the code\r
+To build the code, increase the memory available for Maven. The settings on the Jenkins build server are: +\r
+\r
+       export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"\r
+\r
+IMPORTANT: The top level build line for yangtools project is: `cd yangtools;mvn clean install`\r
+\r
+== Mapping YANG to Java \r
+This chapter covers the details of mapping YANG to Java.\r
+\r
+=== Name of the Package\r
+To configure your project and generate source code from YANG, edit your projects *pom.xml* and add Opendaylight SNAPSHOT repository for snapshot releases. Currently, only snapshots are available. \r
+The name of the package is _org.opendaylight.yang.gen.v1.urn:2:case#module.rev201379_\r
+After replacing digits and JAVA keywords the package name is _org.opendaylight.yang.gen.v1.urn._2._case.module.rev201379_\r
+\r
+The package name consists of the following parts: +\r
+\r
+* *Opendaylight prefix* - Specifies the opendaylight prefix. Every package name starts with the prefix _org.opendaylight.yang.gen.v_ that is hardcoded in *BindingGeneratorUtil.moduleNamespaceToPackageName()*.\r
+* *YANG version* - Specifies the YANG version. YANG version is updated through _module_ substatement _yang-version_.\r
+* *Namespace* - Specifies the value of _module_ subelement and the _namespace_ argument value. \r
+  The namespace characters are _: / : - @ $ # ' * + , ; = . character group:/_ are replaced with periods (*.*).\r
+* *Revision* - Specifies the concatenation of word `rev` and value of _module_ subelement _revision_ argument value without leading zeros before month and day. \r
+  For example: rev201379\r
+\r
+After the package name is generated check it in if it contains any JAVA key words or digits. If it is so then before the token add an underscore (*_*).\r
+\r
+List of key words which are prefixed with underscore:\r
+\r
+[sourceperl]\r
+\r
+    abstract, assert, boolean, break, byte, case, catch, char, class, const, continue, default, double, do, else, enum, extends, false, final, finally, float, for, goto, if, implements, import, instanceof, int, interface, long, native, new, null, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, throw, throws, transient, true, try, void, volatile, while\r
+\r
+As an example suppose following yang model:\r
+\r
+[sourceperl]\r
+\r
+    module module {\r
+    namespace <font color="blue">"urn:2:case#module"</font color>\r
+    prefix "sbd";\r
+    organization "OPEN DAYLIGHT";\r
+    contact "http://www.whatever.com/";\r
+    revision <font color="violet">2013-07-09</font color> {        \r
+    }\r
+}\r
+\r
+== Additional Packages\r
+In cases where the superior YANG elements contain specific subordinate YANG elements additional packages are generated. Table below provides details of superior and subordinate elements: \r
+\r
+[cols=*2,options="header",width="75%"]\r
+|===\r
+|Superior Element  | Subordinate Element \r
+|list  |list, container, choice \r
+|container | list, container, choice  \r
+|choice | leaf, list, leaf-list, container, case \r
+|case  | list, container, choice \r
+|rpc.output and rpc.input |  list, container, (choice isn't supported)\r
+|notification |  list, container, (choice isn't supported)\r
+|augment  | list, container, choice, case |\r
+|===\r
+\r
+Subordinate elements are not mapped only to JAVA Getter methods in the interface of superior element but, they also generate packages with names consisting of superior element package name and superior element name.\r
+In the example YANG model considers the container element _cont_ as the direct subelement of the module.\r
+\r
+[sourceperl]\r
+\r
+ container cont { \r
+   container cont-inner {\r
+   }\r
+   list outter-list {\r
+     list list-in-list {\r
+     }\r
+   }\r
+ }\r
+\r
+Container _cont_ is the superior element for the subordinate elements _cont-inner_ and _outter-list_.\r
+\r
+JAVA code is generated in the following structure: +\r
+\r
+* org.opendaylight.yang.gen.v1.urn.module.rev201379 - package contains element which are subordinate of module \r
+       ** Cont.java \r
+* org.opendaylight.yang.gen.v1.urn.module.rev201379.cont - package contains subordinate elements of cont container element \r
+       ** ContInner.java \r
+       ** OutterList.java \r
+\r
+[sourceperl]\r
+\r
+ container cont { \r
+   container cont-inner {\r
+   }\r
+   list outter-list {\r
+     list list-in-list {\r
+     }\r
+   }\r
+ }\r
\r
+_list outter-list_ is superior element for subordinate element _list-in-list_ \r
+\r
+JAVA code is generated in the following structure: +\r
+\r
+* org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.outter.list - package contains subordinate elements of outter-list list element \r
+  ** ListInList.java \r
+\r
+=== Class and interface name\r
+Some YANG elements are mapped to JAVA classes and interfaces. The name of YANG element may contain various characters which aren't permitted in JAVA class names. Firstly whitespaces are trimmed from YANG name. Next characters space, -, _ are deleted and subsequent letter is capitalized. At the end first letter is capitalized. Transformation example:\r
+example-name without_capitalization is mapped to \r
+`ExampleNameWithoutCapitalization`\r
+\r
+=== Getters and setters name\r
+In some cases are YANG elements generated as getter or setter methods. This methods are created through class `MethodSignatureBuilder`\r
+The process for getter is: +\r
+\r
+* name of YANG element is converted to JAVA class name style \r
+* the word get is added as preffix \r
+* return type of the getter method is set to element's type substatement value \r
+\r
+The process for setter is: +\r
+\r
+* name of YANG element is converted to JAVA class name style \r
+* word set is added as preffix \r
+* input parameter name is set to element's name converted to JAVA parameter style \r
+* return parameter is set to void \r
+\r
+=== Module\r
+\r
+YANG module is converted to JAVA as two JAVA classes. Each of the class is in the separate JAVA file. The names of JAVA files are composed as follows:\r
+`<YANG_module_name><Sufix>`.java where `<sufix>` can be data or service.\r
+\r
+\r
+\r
+\r
+== Data Interface\r
+Data Interface has a mapping similar to container, but contains only top level nodes defined in module. \r
+\r
+== Service Interface\r
+Service Interface serves to describe RPC contract defined in the module. This RPC contract is defined by rpc statements. \r
+\r
+=== Typedef\r
+YANG typedef statement is mapped to JAVA class. Typedef may contain following substatement:\r
+\r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|Substatement | Argument Mapped to JAVA\r
+|type| class attribute\r
+|descripton| is not mapped\r
+|units| is not mapped\r
+|default|is not mapped\r
+|===\r
+\r
+=== Valid Arguments Type\r
+Simple values of type argument are mapped as follows:\r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|Argument Type |  Mapped to JAVA\r
+|boolean| Boolean\r
+|empty| Boolean\r
+|int8| Byte\r
+|int16|Short\r
+|int32|Integer\r
+|int64|Long\r
+|string|String or, class (if pattern substatement is specified)\r
+|decimal64|Double\r
+|uint8|Short\r
+|uint16|Integer\r
+|uint32|Long\r
+|uint64|BigInteger\r
+|binary|byte[]\r
+|===\r
+\r
+Complex values of type argument are mapped as follows:\r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|Argument Type|Mapped to JAVA\r
+|enumeration|enum\r
+|bits|class\r
+|leafref|??\r
+|identityref|??\r
+|union|class\r
+|instance-identifier|??\r
+|===\r
+\r
+=== Enumeration Substatement Enum\r
+The YANG enumeration type has to contain some enum substatements. Enumeration is mapped as JAVA enum type (standalone class) and every YANG enum subelement is mapped to JAVA enum's predefined values.\r
+Enum substatement can have following substatements:\r
+\r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|Enum's Substatement |Mapped to JAVA\r
+|description|is not mapped\r
+|value|mapped as input parameter for every predefined value of enum\r
+|===\r
+\r
+Example of maping of YANG enumeration to JAVA:\r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|YANG|JAVA\r
+\r
+a|\r
+----\r
+typedef typedef-enumeration {\r
+    type enumeration {\r
+        enum enum1 {\r
+            description "enum1 description";\r
+            value 18;\r
+        }\r
+        enum enum2 {\r
+            value 16;\r
+        }\r
+        enum enum3 {\r
+        }              \r
+    }\r
+}\r
+----\r
+a|\r
+----\r
+public enum TypedefEnumeration {\r
+    Enum1(18),\r
+    Enum2(16),\r
+    Enum3(19);\r
\r
+    int value;\r
\r
+    private TypedefEnumeration(int value) {\r
+        this.value = value;\r
+    }\r
+}\r
+----\r
+|===\r
+=== Bits's Substatement Bit\r
+The YANG bits type has to contain some bit substatements. YANG Bits is mapped to JAVA class (standalone class) and every YANG bits subelement is mapped to class boolean attributes. In addition are overriden Object methods `hash, toString, equals`.\r
+\r
+[cols=*3,^,options="header",width="75%"]\r
+|===\r
+|YANG|JAVA|JAVA overriden Object methods\r
+a|----\r
+typedef typedef-bits {\r
+  type bits {\r
+    bit first-bit {\r
+      description "first-bit description";\r
+        position 15;\r
+      }\r
+    bit second-bit; \r
+  }\r
+}\r
+a|----\r
+public class TypedefBits {\r
\r
+    private Boolean firstBit;\r
+    private Boolean secondBit;\r
\r
+    public TypedefBits() {\r
+        super();\r
+    }\r
\r
+    public Boolean getFirstBit() {\r
+        return firstBit;\r
+    }\r
\r
+    public void setFirstBit(Boolean firstBit) {\r
+        this.firstBit = firstBit;\r
+    }\r
\r
+    public Boolean getSecondBit() {\r
+        return secondBit;\r
+    }\r
\r
+    public void setSecondBit(Boolean secondBit) {\r
+        this.secondBit = secondBit;\r
+    }\r
+}\r
+a|----\r
+ @Override\r
+public int hashCode() {\r
+    final int prime = 31;\r
+    int result = 1;\r
+    result = prime * result +\r
+     ((firstBit == null) ? 0 : firstBit.hashCode());\r
+    result = prime * result +\r
+     ((secondBit == null) ? 0 : secondBit.hashCode());\r
+    return result;\r
+}\r
\r
+@Override\r
+public boolean equals(Object obj) {\r
+    if (this == obj) {\r
+        return true;\r
+    }\r
+    if (obj == null) {\r
+        return false;\r
+    }\r
+    if (getClass() != obj.getClass()) {\r
+        return false;\r
+    }\r
+    TypedefBits other = (TypedefBits) obj;\r
+    if (firstBit == null) {\r
+        if (other.firstBit != null) {\r
+            return false;\r
+        }\r
+    } else if(!firstBit.equals(other.firstBit)) {\r
+        return false;\r
+    }\r
+    if (secondBit == null) {\r
+        if (other.secondBit != null) {\r
+            return false;\r
+        }\r
+    } else if(!secondBit.equals(other.secondBit)) {\r
+        return false;\r
+    }\r
+    return true;\r
+}\r
\r
+@Override\r
+public String toString() {\r
+    StringBuilder builder = new StringBuilder();\r
+    builder.append("TypedefBits [firstBit=");\r
+    builder.append(firstBit);\r
+    builder.append(", secondBit=");\r
+    builder.append(secondBit);\r
+    builder.append("]");\r
+    return builder.toString();\r
+}\r
+|===\r
+\r
+=== Union's Substatement Type\r
+If type of typedef is union it has to contain `type` substatements. Union typedef is mapped to class and its `type` subelements are mapped to private class attributes. For every YANG union subtype si generated own JAVA constructor with a parameter which represent just one attribute.\r
+Example to union mapping:\r
+\r
+\r
+[cols=[2, 2, 2,],^,options="header",width="90%"]\r
+|===\r
+|YANG|JAVA|JAVA overriden Object methods\r
+a|----\r
+typedef typedef-union {\r
+    type union {\r
+        type int32;\r
+        type string;\r
+    }\r
+}\r
+a|----\r
+public class TypedefUnion {\r
\r
\r
\r
+    private Integer int32;\r
+    private String string;\r
\r
+    public TypedefUnion(Integer int32) {\r
+        super();\r
+        this.int32 = int32;\r
+    }\r
\r
+    public TypedefUnion(String string) {\r
+        super();\r
+        this.string = string;\r
+    }\r
\r
+    public Integer getInt32() {\r
+        return int32;\r
+    }\r
\r
+    public String getString() {\r
+        return string;\r
+    }\r
+}\r
+a|----\r
+@Override\r
+public int hashCode() {\r
+    final int prime = 31;\r
+    int result = 1;\r
+    result = prime * result + ((int32 == null) ? 0 : int32.hashCode());\r
+    result = prime * result + ((string == null) ? 0 : string.hashCode());\r
+    return result;\r
+}\r
\r
+@Override\r
+public boolean equals(Object obj) {\r
+    if (this == obj) {\r
+        return true;\r
+    }\r
+    if (obj == null) {\r
+        return false;\r
+    }\r
+    if (getClass() != obj.getClass()) {\r
+        return false;\r
+    }\r
+    TypedefUnion other = (TypedefUnion) obj;\r
+    if (int32 == null) {\r
+        if (other.int32 != null) {\r
+            return false;\r
+        }\r
+    } else if(!int32.equals(other.int32)) {\r
+        return false;\r
+    }\r
+    if (string == null) {\r
+        if (other.string != null) {\r
+            return false;\r
+        }\r
+    } else if(!string.equals(other.string)) {\r
+        return false;\r
+    }\r
+    return true;\r
+}\r
\r
+@Override\r
+public String toString() {\r
+    StringBuilder builder = new StringBuilder();\r
+    builder.append("TypedefUnion [int32=");\r
+    builder.append(int32);\r
+    builder.append(", string=");\r
+    builder.append(string);\r
+    builder.append("]");\r
+    return builder.toString();\r
+}\r
+|===\r
+\r
+=== String Mapping\r
+YANG String can be detailed specified through type subelements length and pattern which are mapped as follows:\r
+\r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|Type  subelement  |  Mapping to JAVA\r
+| length | not mapped\r
+| pattern | \r
+\r
+. list of string constants = list of patterns +\r
+. list of Pattern objects + \r
+. static initialization block where list of Patterns is initialized from list of string of constants\r
+|===\r
+\r
+Example of YANG string mapping \r
+\r
+[cols=[3,3,3],^ ,options="header",width="75%"]\r
+|===\r
+|YANG|JAVA|JAVA Overriden Object Methods\r
+a|----\r
+typedef typedef-string {\r
+    type string {\r
+        length 44;\r
+        pattern "[a][.]*"\r
+    }\r
+}\r
+----\r
+a|\r
+----\r
+public class TypedefString {\r
\r
+    private static final List<Pattern> patterns = new ArrayList<Pattern>();\r
+    public static final List<String> PATTERN_CONSTANTS = Arrays.asList("[a][.]*");\r
\r
+    static {\r
+        for (String regEx : PATTERN_CONSTANTS) {\r
+            patterns.add(Pattern.compile(regEx));\r
+        }\r
+    }\r
\r
+    private String typedefString;\r
\r
+    public TypedefString(String typedefString) {\r
+        super();\r
+        this.typedefString = typedefString;\r
+    }\r
\r
+    public String getTypedefString() {\r
+        return typedefString;\r
+    }\r
+}\r
+----\r
+a|----\r
+@Override\r
+public int hashCode() {\r
+    final int prime = 31;\r
+    int result = 1;\r
+    result = prime * result + ((typedefString == null) ? 0 : typedefString.hashCode());\r
+    return result;\r
+}\r
\r
+@Override\r
+public boolean equals(Object obj) {\r
+    if (this == obj) {\r
+        return true;\r
+    }\r
+    if (obj == null) {\r
+        return false;\r
+    }\r
+    if (getClass() != obj.getClass()) {\r
+        return false;\r
+    }\r
+    TypedefString other = (TypedefString) obj;\r
+    if (typedefString == null) {\r
+        if (other.typedefString != null) {\r
+            return false;\r
+        }\r
+    } else if(!typedefString.equals(other.typedefString)) {\r
+        return false;\r
+    }\r
+    return true;\r
+}\r
\r
+@Override\r
+public String toString() {\r
+    StringBuilder builder = new StringBuilder();\r
+    builder.append("TypedefString [typedefString=");\r
+    builder.append(typedefString);\r
+    builder.append("]");\r
+    return builder.toString();\r
+} \r
+----\r
+|===\r
+=== Container\r
+YANG Container is mapped to JAVA interface which extends interfaces DataObject, Augmentable<container_interface>, where container_interface is name of mapped interface.\r
+Example of mapping:\r
+\r
+[cols= [2,2],^,options="header",width="90%"]\r
+|===\r
+|YANG|JAVA\r
+a|----\r
+container cont {\r
+}\r
+a|----\r
+public interface Cont extends DataObject, Augmentable<Cont> {\r
+}\r
+|===\r
+=== Leaf\r
+Each leaf has to contain at least one type substatement. The leaf is mapped to getter method of superior element with return type equal to type substatement value.\r
+Example of mapping:\r
+\r
+[cols= [2,2],^,options="header",width="90%"]\r
+|===\r
+|YANG|JAVA\r
+a|----\r
+module module {\r
\r
+    namespace "urn:module";\r
+    prefix "sbd";\r
\r
+    organization "OPEN DAYLIGHT";\r
+    contact "http://www.whatever.com/";    \r
\r
+    revision 2013-07-09 {\r
\r
+    }\r
+    leaf lf {\r
+        type string;                           \r
+    }     \r
+}\r
+a|----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
+public interface ModuleData {\r
+    String getLf();\r
+} \r
+|===\r
+Example of leaf mapping at container level:\r
+[cols= [2,2],^,options="header",width="90%"]\r
+|===\r
+|YANG|JAVA\r
+a|\r
+----\r
+container cont {\r
+  leaf lf {\r
+    type string;                               \r
+  }\r
+} \r
+a|----\r
+public interface Cont extends DataObject, Augmentable<Cont> {\r
+    String getLf();\r
+} \r
+|===\r
+\r
+=== Leaf-list\r
+Each leaf-list has to contain one type substatement. The leaf-list is mapped to getter method of superior element with return type equal to List of type substatement value.\r
+Example of mapping of leaf-list.\r
+[cols= [2,2],^,options="header",width="90%"]\r
+|===\r
+|YANG|JAVA\r
+a|\r
+----\r
+container cont {\r
+    leaf-list lf-lst {\r
+        type typedef-union;\r
+    }\r
+}\r
+a|----\r
+public interface Cont extends DataObject, Augmentable<Cont> {\r
+    List<TypedefUnion> getLfLst();\r
+}\r
+|===\r
+\r
+\r
+YANG `typedef-union` and `JAVA TypedefUnion` are the same as in union type.\r
+\r
+=== List\r
+YANG list element is mapped to JAVA interface. In superior element is generated as getter method with return type List of generated interfaces.\r
+Mapping of list substatement to JAVA:\r
+\r
+[cols=*2,2a,^,options="header",width="80%"]\r
+|===\r
+|Substatement|Mapping to JAVA\r
+|Key|Class\r
+|===\r
+Example of list mapping _outter-list_ is mapped to JAVA interface _OutterList_ and in _Cont_ interface (superior of _OutterList_) contains getter method with return type List<OutterList> \r
+[cols=[3,3,3],^ ,options="header",width="75%"]\r
+|===\r
+|YANG|JAVA|JAVA Overriden Object Methods\r
+a|\r
+----\r
+\r
+container cont {\r
+  list outter-list {\r
+    leaf leaf-in-list {\r
+      type uint64;                \r
+    }\r
+    leaf-list leaf-list-in-list {\r
+      type string;                \r
+    }\r
+    list list-in-list {\r
+      leaf-list inner-leaf-list {\r
+        type int16;\r
+      }\r
+    }\r
+  }\r
+}\r
+a|\r
+ListInList.java +\r
+\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.outter.list;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
+import java.util.List;\r
\r
+public interface ListInList extends DataObject, Augmentable<ListInList> {\r
\r
+    List<Short> getInnerLeafList();\r
+}\r
+----\r
+OutterListKey.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont;\r
\r
+import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.OutterListKey;\r
+import java.math.BigInteger;\r
\r
+public class OutterListKey {\r
\r
+    private BigInteger LeafInList;\r
\r
+    public OutterListKey(BigInteger LeafInList) {\r
+        super();\r
+        this.LeafInList = LeafInList;\r
+    }\r
\r
+    public BigInteger getLeafInList() {\r
+        return LeafInList;\r
+    }\r
+}\r
+----\r
+OutterList.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
+import java.util.List;\r
+import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.outter.list.ListInList;\r
\r
+public interface OutterList extends DataObject, Augmentable<OutterList> {\r
\r
+    List<String> getLeafListInList();\r
\r
+    List<ListInList> getListInList();\r
\r
+    /*\r
+    Returns Primary Key of Yang List Type\r
+    */\r
+    OutterListKey getOutterListKey();\r
\r
+}\r
+Cont.java\r
+\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
+import java.util.List;\r
+import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.OutterList;\r
\r
+public interface Cont extends DataObject, Augmentable<Cont> {\r
\r
+    List<OutterList> getOutterList();\r
\r
+}\r
+----\r
+a| OutterListKey.java\r
+----\r
+@Override\r
+public int hashCode() {\r
+    final int prime = 31;\r
+    int result = 1;\r
+    result = prime * result + ((LeafInList == null) ? 0 : LeafInList.hashCode());\r
+    return result;\r
+}\r
\r
+@Override\r
+public boolean equals(Object obj) {\r
+    if (this == obj) {\r
+        return true;\r
+    }\r
+    if (obj == null) {\r
+        return false;\r
+    }\r
+    if (getClass() != obj.getClass()) {\r
+        return false;\r
+    }\r
+    OutterListKey other = (OutterListKey) obj;\r
+    if (LeafInList == null) {\r
+        if (other.LeafInList != null) {\r
+            return false;\r
+        }\r
+    } else if(!LeafInList.equals(other.LeafInList)) {\r
+        return false;\r
+    }\r
+    return true;\r
+}\r
\r
+@Override\r
+public String toString() {\r
+    StringBuilder builder = new StringBuilder();\r
+    builder.append("OutterListKey [LeafInList=");\r
+    builder.append(LeafInList);\r
+    builder.append("]");\r
+    return builder.toString();\r
+}\r
+----\r
+|===\r
+\r
+=== Choice and Case    \r
+`Choice` element is mapped similarly as `list` element. Choice element is mapped to interface (marker interface) and in the superior element is created using getter method with the return type `List` of this marker interfaces.\r
+`Case` substatements are mapped to the JAVA interfaces which extend mentioned marker interface.\r
+Example of choice mapping: \r
+[cols=[3,3],^ ,options="header",width="90%"]\r
+|===\r
+|YANG|JAVA\r
+a|\r
+----\r
+container cont {\r
+    choice choice-test {\r
+        case case1 {\r
+        }\r
+        case case2 {\r
+        }\r
+    }\r
+}\r
+----\r
+a|\r
+Case1.java\r
+\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.choice.test;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
+import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.ChoiceTest;\r
\r
+public interface Case1 extends DataObject, Augmentable<Case1>, ChoiceTest {\r
+}\r
+----\r
+Case2.java \r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.choice.test;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
+import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.ChoiceTest;\r
\r
+public interface Case2 extends DataObject, Augmentable<Case2>, ChoiceTest {\r
+}\r
+----\r
+ChoiceTest.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
\r
+public interface ChoiceTest extends DataObject {\r
+}\r
+----\r
+a|\r
+\r
+Cont.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
+import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.ChoiceTest;\r
\r
+public interface Cont extends DataObject, Augmentable<Cont> {\r
\r
+    ChoiceTest getChoiceTest();\r
\r
+}\r
+----\r
+|===\r
+\r
+=== Grouping and Uses\r
+Grouping is mapped to JAVA interface. Uses used in some element (using of concrete grouping) are mapped as extension of interface for this element with the interface which represents grouping.\r
+Example of grouping and uses mapping.\r
+[cols=[3,3],^ ,options="header",width="90%"]\r
+|===\r
+|YANG|JAVA\r
+a|\r
+----\r
+grouping grp {\r
\r
+}\r
\r
+container cont {\r
+    uses grp;\r
+}\r
+----\r
+a|\r
+Cont.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
\r
+public interface Cont extends DataObject, Augmentable<Cont>, Grp {\r
+}\r
+----\r
+Grp.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
\r
+public interface Grp extends DataObject {\r
+}\r
+---- \r
+|===\r
+\r
+=== Rpc\r
+Rpc is mapped to JAVA as method of class `ModuleService.java`.\r
+Rpc's substatement are mapped as follows: \r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|Rpc Substatement|Mapping to JAVA\r
+|input|interface\r
+|output|interface\r
+|===\r
+\r
+Example of rpc mapping: \r
+[cols=[3,3],^ ,options="header",width="90%"]\r
+|===\r
+|YANG|JAVA\r
+a|\r
+----\r
+rpc rpc-test1 {\r
+    output {\r
+        leaf lf-output {\r
+            type string;\r
+        }\r
+    }\r
+    input {\r
+        leaf lf-input {\r
+            type string;\r
+        }        \r
+    }\r
+}\r
+----\r
+a| ModuleService.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
+import java.util.concurrent.Future;\r
+import org.opendaylight.yangtools.yang.common.RpcResult;\r
\r
+public interface ModuleService {\r
\r
+    Future<RpcResult<RpcTest1Output>> rpcTest1(RpcTest1Input input);\r
\r
+}\r
+----\r
+RpcTest1Input.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
+public interface RpcTest1Input {\r
\r
+    String getLfInput();\r
\r
+}\r
+----\r
+RpcTest1Output.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
+public interface RpcTest1Output {\r
\r
+    String getLfOutput();\r
\r
+}\r
+----\r
+|===\r
+\r
+=== Notification\r
+`Notification` is mapped to the JAVA interface which extends Notification interface.\r
+Example of notification mapping:\r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|YANG|JAVA\r
+a|\r
+----\r
+notification notif {\r
+       }\r
+----\r
+a| \r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
+import org.opendaylight.yangtools.yang.binding.Notification;\r
\r
+public interface Notif extends DataObject, Augmentable<Notif>, Notification {\r
+}\r
+----\r
+|===\r
+\r
+=== Augment\r
+`Augment` is mapped to the JAVA interface. The interface starts with the same name as the name of augmented interface. The suffix is order number of augmenting interface. The augmenting interface also extends `Augmentation<>` with actual type parameter equal to augmented interface.\r
+Example of augment mapping. In this example is augmented interface `Cont` so whole parametrized type is `Augmentation<Cont>`. \r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|YANG|JAVA\r
+a|\r
+----\r
+container cont {\r
+}         \r
\r
+augment "/cont" {\r
+}\r
+----\r
+a| Cont.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentable;\r
\r
+public interface Cont extends DataObject, Augmentable<Cont> {\r
\r
+}\r
+----\r
+Cont1.java\r
+----\r
+package org.opendaylight.yang.gen.v1.urn.module.rev201379;\r
\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+import org.opendaylight.yangtools.yang.binding.Augmentation;\r
\r
+public interface Cont1 extends DataObject, Augmentation<Cont> {\r
\r
+}\r
+----\r
+|===\r
+=== Identity\r
+The purpose of the identity statement is to define a new globally unique, abstract, and untyped identity. YANG substatement base considers an argument a string; the name of existing identity from which the new identity is derived. Hence, the identity statement is mapped to JAVA abstract class and base substatement is mapped as extends JAVA keyword. The identity name is translated to class name. \r
+\r
+[cols=*2,2a,^,options="header",width="75%"]\r
+|===\r
+|YANG|JAVA\r
+\r
+a|\r
+----\r
+identity toast-type {  \r
+}\r
+----\r
+a| \r
+----\r
+public abstract class ToastType extends BaseIdentity {\r
+    protected ToastType() {\r
+        super();\r
+    }\r
+}\r
+----\r
+a|\r
+----\r
+identity white-bread {\r
+  base toast-type;\r
+}\r
+----\r
+a| WhiteBread.java\r
+----\r
+public abstract class WhiteBread extends ToastType {\r
+    protected WhiteBread() {\r
+        super();\r
+    }\r
+}\r
+----\r
+|===\r
+\r
+\r
\r
+\r
+\r