7 YANG Tools is set of libraries and tooling providing support for use
8 `YANG <https://tools.ietf.org/html/rfc6020>`__ for Java (or other
9 JVM-based language) projects and applications.
11 YANG Tools provides following features in OpenDaylight:
13 - parsing of YANG sources and semantic inference of relationship across
14 YANG models as defined in
15 `RFC6020 <https://tools.ietf.org/html/rfc6020>`__
17 - representation of YANG-modeled data in Java
19 - **Normalized Node** representation - DOM-like tree model, which
20 uses conceptual meta-model more tailored to YANG and OpenDaylight
21 use-cases than a standard XML DOM model allows for.
23 - **Java Binding** - concrete data model and classes generated from
24 YANG models, designed to provide compile-time safety when working
25 with YANG-modeled data.
27 - serialization / deserialization of YANG-modeled data driven by YANG
31 `RFC6020 <https://tools.ietf.org/html/rfc6020>`__
33 - JSON - as defined in
34 `draft-lhotka-netmod-yang-json-01 <https://tools.ietf.org/html/rfc6020>`__
36 - Java Binding to Normalized Node and vice-versa
38 - Integration of YANG model parsing into Maven build lifecycle and
39 support for third-party generators processing YANG models.
41 YANG Tools project consists of following logical subsystems:
43 - **Commons** - Set of general purpose code, which is not specific to
44 YANG, but is also useful outside YANG Tools implementation.
46 - **YANG Model and Parser** - YANG semantic model and lexical and
47 semantic parser of YANG models, which creates in-memory
48 cross-referenced represenation of YANG models, which is used by other
49 components to determine their behaviour based on the model.
51 - **YANG Data** - Definition of Normalized Node APIs and Data Tree
52 APIs, reference implementation of these APIs and implementation of
53 XML and JSON codecs for Normalized Nodes.
55 - **YANG Maven Plugin** - Maven plugin which integrates YANG parser
56 into Maven build lifecycle and provides code-generation framework for
57 components, which wants to generate code or other artefacts based on
60 - **YANG Java Binding** - Mapping of YANG model to generated Java APIs.
61 Java Binding also references to set of compile-time and runtime
62 components which implements this mapping, provides generation of
63 classes and APIs based on YANG models and integrate these Java
64 Binding objects with **YANG Data** APIs and components.
66 - **Models** - Set of **IETF** and **YANG Tools** models, with
67 generated Java Bindings so they could be simply consumed outside
70 YANG Java Binding: Mapping rules
71 --------------------------------
73 This chapter covers the details of mapping YANG to Java.
77 The following source code examples does not show canonical generated
78 code, but rather illustrative example. Generated classes and
79 interfaces may differ from this examples, but APIs are preserved.
81 General conversion rules
82 ~~~~~~~~~~~~~~~~~~~~~~~~
84 Package names of YANG models
85 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87 | The package name consists of the following parts:
89 - **Opendaylight prefix** - Specifies the opendaylight prefix. Every
90 package name starts with the prefix ``org.opendaylight.yang.gen.v``.
92 - **Java Binding version** - Specifies the YANG Java Binding version.
93 Curent Binding version is ``1``.
95 - **Namespace** - Specified by the value of ``namespace`` substatement.
96 URI is converted to package name structure.
98 - **Revision** - Specifies the concatenation of word ``rev`` and value
99 of ``module`` substatements ``revision`` argument value without
100 leading zeros before month and day. For example: ``rev201379``
102 After the package name is generated, we check if it contains any Java
103 keywords or starts with a digit. If so, then we add an underscore before
106 The following is a list of keywords which are prefixed with underscore:
108 abstract, assert, boolean, break, byte, case, catch, char, class, const,
109 continue, default, double, do, else, enum, extends, false, final,
110 finally, float, for, goto, if, implements, import, instanceof, int,
111 interface, long, native, new, null, package, private, protected, public,
112 return, short, static, strictfp, super, switch, synchronized, this,
113 throw, throws, transient, true, try, void, volatile, while
115 As an example suppose following yang model:
120 namespace "urn:2:case#module";
122 organization "OPEN DAYLIGHT";
123 contact "http://www.example.com/";
124 revision 2013-07-09 {
128 After applying rules (replacing digits and Java keywords) the resulting
130 ``org.opendaylight.yang.gen.v1.urn._2._case.module.rev201379``
135 In cases when YANG statement contain some of specific YANG statements
136 additional packages are generated to designate this containment. Table
137 below provides details of parent statement and nested statements, which
138 yields additional package generation:
140 +--------------------------------------+--------------------------------------+
141 | Parent statement | Substatement |
142 +======================================+======================================+
143 | ``list`` | list, container, choice |
144 +--------------------------------------+--------------------------------------+
145 | ``container`` | list, container, choice |
146 +--------------------------------------+--------------------------------------+
147 | ``choice`` | leaf, list, leaf-list, container, |
149 +--------------------------------------+--------------------------------------+
150 | ``case`` | list, container, choice |
151 +--------------------------------------+--------------------------------------+
152 | rpc ``input`` or ``output`` | list, container, (choice isn’t |
154 +--------------------------------------+--------------------------------------+
155 | ``notification`` | list, container, (choice isn’t |
157 +--------------------------------------+--------------------------------------+
158 | ``augment`` | list, container, choice, case |
159 +--------------------------------------+--------------------------------------+
161 Substatements are not only mapped to Java setter methods in the
162 interface representing the parent statement, but they also generate
163 packages with names consisting of the parent statement package name with
164 the parent statement name appended.
166 For example, this YANG model considers the container statement ``cont``
167 as the direct substatement of the module.
172 container cont-inner {
180 Container ``cont`` is the parent statement for the substatements
181 ``cont-inner`` and ``outter-list``. ``list outter-list`` is the parent
182 statement for substatement ``list-in-list``.
184 | Java code is generated in the following structure:
186 - ``org.opendaylight.yang.gen.v1.urn.module.rev201379`` - package
187 contains direct substatements of module statement
191 - ``org.opendaylight.yang.gen.v1.urn.module.rev201379.cont`` - package
192 contains substatements of ``cont`` container statement
194 - ``ContInner.java`` - interface representing container
197 - ``OutterList.java`` - interface representing list ``outer-list``
199 - ``org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.outter.list``
200 - package contains substatements of outter-list list element
202 - ``ListInList.java``
204 Class and interface names
205 ^^^^^^^^^^^^^^^^^^^^^^^^^
207 Some YANG statements are mapped to Java classes and interfaces. The name
208 of YANG element may contain various characters which aren’t permitted in
209 Java class names. Firstly whitespaces are trimmed from YANG name. Next
210 the characters space, -, \` are deleted and the subsequent letter is
211 capitalized. At the end, first letter is capitalized.
213 For example, ``example-name_ without_capitalization`` would map to
214 ``ExampleNameWithoutCapitalization``.
216 Getter and setter names
217 ^^^^^^^^^^^^^^^^^^^^^^^
219 In some cases, YANG statements are converted to getter and/or setter
220 methods. The process for getter is:
222 1. the name of YANG statement is converted to Java class name style as
223 `explained above <#_class_and_interface_names>`__.
225 2. the word ``get`` is added as prefix, if resulting type is
226 ``Boolean``, the name is prefixed with ``is`` prefix instead of
229 3. the return type of the getter method is set to Java type representing
232 The process for setter is:
234 1. the name of YANG statement is converted to Java class name style as
235 `explained above <#_class_and_interface_names>`__.
237 2. the word ``set`` is added as prefix
239 3. the input parameter name is set to element’s name converted to Java
242 4. the return parameter is set to builder type
244 Statement specific mapping
245 ~~~~~~~~~~~~~~~~~~~~~~~~~~
250 YANG ``module`` statement is converted to Java as two Java classes. Each
251 of the classes is in the separate Java file. The names of Java files are
252 composed as follows: ``<module name><suffix>.java`` where ``<suffix>``
253 is either data or service.
258 Data Interface has a mapping similar to container, but contains only top
259 level nodes defined in module.
261 Data interface serves only as marker interface for type-safe APIs of
262 ``InstanceIdentifier``.
267 Service Interface serves to describe RPC contract defined in the module.
268 This RPC contract is defined by ``rpc`` statements.
270 RPC implementation usually implement this interface and users of the
271 RPCs use this interface to invoke RPCs.
276 YANG containers are mapped to Java interfaces which extend the Java
277 DataObject and Augmentable<container-interface>, where
278 container-interface is the name of the mapped interface.
280 For example, the following YANG:
290 is converted into this Java:
296 public interface Cont extends ChildOf<...>, Augmentable<Cont> {
302 Each leaf has to contain at least one type substatement. The leaf is
303 mapped to getter method of parent statement with return type equal to
304 type substatement value.
306 For example, the following YANG:
318 is converted into this Java:
324 public interface Cont extends DataObject, Augmentable<Cont> {
328 - Represents ``leaf lf``
333 Each leaf-list has to contain one type substatement. The leaf-list is
334 mapped to getter method of parent statement with return type equal to
335 List of type substatement value.
337 For example, the following YANG:
349 is converted into this Java:
355 public interface Cont extends DataObject, Augmentable<Cont> {
356 List<String> getLfLst();
362 ``list`` statements are mapped to Java interfaces and a getter method is
363 generated in the interface associated with it’s parent statement. The
364 return type of getter the method is a Java List of objects implementing
365 the interface generated corresponding to the ``list statement.
366 Mapping of `list`` substatement to Java:
368 For example, the following YANG:
383 The list statement ``example-list`` is mapped to the Java interface
384 ``ExampleList`` and the ``Cont`` interface (parent of ``ExampleList``)
385 contains getter method with return type ``List<ExampleList>``. The
386 presence of a ``key`` statement, triggers generation of
387 ``ExampleListKey``, which may be used to identify item in list.
389 The end result is this Java:
395 package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont;
397 import org.opendaylight.yangtools.yang.binding.DataObject;
398 import org.opendaylight.yangtools.yang.binding.Augmentable;
399 import Java.util.List;
400 import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.outter.list.ListInList;
402 public interface OutterList extends DataObject, Augmentable<OutterList> {
404 List<String> getLeafListInList();
406 List<ListInList> getListInList();
409 Returns Primary Key of Yang List Type
411 OutterListKey getOutterListKey();
415 **OutterListKey.java.**
419 package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont;
421 import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.OutterListKey;
422 import Java.math.BigInteger;
424 public class OutterListKey {
426 private BigInteger _leafInList;
428 public OutterListKey(BigInteger _leafInList) {
430 this_leafInList = _leafInList;
433 public BigInteger getLeafInList() {
438 public int hashCode() {
439 final int prime = 31;
441 result = prime * result + ((_leafInList == null) ? 0 : _leafInList.hashCode());
446 public boolean equals(Object obj) {
453 if (getClass() != obj.getClass()) {
456 OutterListKey other = (OutterListKey) obj;
457 if (_leafInList == null) {
458 if (other._LeafInList != null) {
461 } else if(!_leafInList.equals(other._leafInList)) {
468 public String toString() {
469 StringBuilder builder = new StringBuilder();
470 builder.append("OutterListKey [_leafInList=");
471 builder.append(_leafInList);
473 return builder.toString();
477 choice and case statements
478 ^^^^^^^^^^^^^^^^^^^^^^^^^^
480 A ``choice`` element is mapped in mostly the same way a ``list`` element
481 is. The ``choice`` element is mapped to and interface (marker interface)
482 and a new getter method with the return type of a Java ``List`` of this
483 marker interfaces is added to the interface corresponding to the parent
484 statement. Any ``case`` substatements are mapped to Java interfaces
485 which extend the marker interface.
487 For example, the following YANG:
494 choice example-choice {
508 is converted into this Java:
514 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
516 import org.opendaylight.yangtools.yang.binding.DataObject;
517 import org.opendaylight.yangtools.yang.binding.Augmentable;
518 import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.ChoiceTest;
520 public interface Cont extends DataObject, Augmentable<Cont> {
522 ExampleChoice getExampleChoice();
526 **ExampleChoice.java.**
530 package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont;
532 import org.opendaylight.yangtools.yang.binding.DataObject;
534 public interface ExampleChoice extends DataContainer {
541 package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.example.choice;
543 import org.opendaylight.yangtools.yang.binding.DataObject;
544 import org.opendaylight.yangtools.yang.binding.Augmentable;
545 import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.ChoiceTest;
547 public interface FooCase extends ExampleChoice, DataObject, Augmentable<FooCase> {
557 package org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.example.choice;
559 import org.opendaylight.yangtools.yang.binding.DataObject;
560 import org.opendaylight.yangtools.yang.binding.Augmentable;
561 import org.opendaylight.yang.gen.v1.urn.module.rev201379.cont.ChoiceTest;
563 public interface BarCase extends ExampleChoice, DataObject, Augmentable<BarCase> {
569 grouping and uses statements
570 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
572 ``grouping`s are mapped to Java interfaces. `uses`` statements in some
573 element (using of concrete grouping) are mapped as extension of
574 interface for this element with the interface which represents grouping.
576 For example, the following YANG:
592 is converted into this Java:
598 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
600 import org.opendaylight.yangtools.yang.binding.DataObject;
602 public interface Grp extends DataObject {
612 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
614 import org.opendaylight.yangtools.yang.binding.DataObject;
615 import org.opendaylight.yangtools.yang.binding.Augmentable;
617 public interface Cont extends DataObject, Augmentable<Cont>, Grp {
620 rpc, input and output statements
621 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
623 An ``rpc`` statement is mapped to Java as method of class
624 ``ModuleService.java``. Any substatements of an ``rpc`` are mapped as
627 +--------------------------------------+--------------------------------------+
628 | Rpc Substatement | Mapping |
629 +======================================+======================================+
630 | input | presence of input statement triggers |
631 | | generation of interface |
632 +--------------------------------------+--------------------------------------+
633 | output | presence of output statement |
634 | | triggers generation of interface |
635 +--------------------------------------+--------------------------------------+
637 For example, the following YANG:
656 is converted into this Java:
658 **ModuleService.java.**
662 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
664 import Java.util.concurrent.Future;
665 import org.opendaylight.yangtools.yang.common.RpcResult;
667 public interface ModuleService {
669 Future<RpcResult<RpcTest1Output>> rpcTest1(RpcTest1Input input);
673 **RpcTest1Input.java.**
677 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
679 public interface RpcTest1Input {
685 **RpcTest1Output.java.**
689 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
691 public interface RpcTest1Output {
693 String getLfOutput();
697 notification statement
698 ^^^^^^^^^^^^^^^^^^^^^^
700 ``notification`` statements are mapped to Java interfaces which extend
701 the Notification interface.
703 For example, the following YANG:
712 is converted into this Java:
718 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
721 import org.opendaylight.yangtools.yang.binding.DataObject;
722 import org.opendaylight.yangtools.yang.binding.Augmentable;
723 import org.opendaylight.yangtools.yang.binding.Notification;
725 public interface Notif extends DataObject, Augmentable<Notif>, Notification {
731 ``augment`` statements are mapped to Java interfaces. The interface
732 starts with the same name as the name of augmented interface with a
733 suffix corresponding to the order number of augmenting interface. The
734 augmenting interface also extends ``Augmentation<>`` with actual type
735 parameter equal to augmented interface.
737 For example, the following YANG:
747 leaf additional-value {
752 is converted into this Java:
758 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
760 import org.opendaylight.yangtools.yang.binding.DataObject;
761 import org.opendaylight.yangtools.yang.binding.Augmentable;
763 public interface Cont extends DataObject, Augmentable<Cont> {
771 package org.opendaylight.yang.gen.v1.urn.module.rev201379;
773 import org.opendaylight.yangtools.yang.binding.DataObject;
774 import org.opendaylight.yangtools.yang.binding.Augmentation;
776 public interface Cont1 extends DataObject, Augmentation<Cont> {
786 YANG ``typedef`` statements are mapped to Java classes. A ``typedef``
787 may contain following substatements:
789 +--------------------------------------+--------------------------------------+
790 | Substatement | Behaviour |
791 +======================================+======================================+
792 | type | determines wrapped type and how |
793 | | class will be generated |
794 +--------------------------------------+--------------------------------------+
795 | descripton | Javadoc description |
796 +--------------------------------------+--------------------------------------+
797 | units | is not mapped |
798 +--------------------------------------+--------------------------------------+
799 | default | is not mapped |
800 +--------------------------------------+--------------------------------------+
805 Simple values of type argument are mapped as follows:
807 +--------------------------------------+--------------------------------------+
808 | YANG Type | Java type |
809 +======================================+======================================+
810 | boolean | Boolean |
811 +--------------------------------------+--------------------------------------+
813 +--------------------------------------+--------------------------------------+
815 +--------------------------------------+--------------------------------------+
817 +--------------------------------------+--------------------------------------+
819 +--------------------------------------+--------------------------------------+
821 +--------------------------------------+--------------------------------------+
822 | string | String or, wrapper class (if pattern |
823 | | substatement is specified) |
824 +--------------------------------------+--------------------------------------+
825 | decimal64 | Double |
826 +--------------------------------------+--------------------------------------+
828 +--------------------------------------+--------------------------------------+
830 +--------------------------------------+--------------------------------------+
832 +--------------------------------------+--------------------------------------+
833 | uint64 | BigInteger |
834 +--------------------------------------+--------------------------------------+
836 +--------------------------------------+--------------------------------------+
838 Complex values of type argument are mapped as follows:
840 +--------------------------------------+--------------------------------------+
841 | Argument Type | Java type |
842 +======================================+======================================+
843 | enumeration | generated java enum |
844 +--------------------------------------+--------------------------------------+
845 | bits | generated class for bits |
846 +--------------------------------------+--------------------------------------+
847 | leafref | same type as referenced leaf |
848 +--------------------------------------+--------------------------------------+
849 | identityref | Class |
850 +--------------------------------------+--------------------------------------+
851 | union | generated java class |
852 +--------------------------------------+--------------------------------------+
853 | instance-identifier | ``org.opendaylight.yangtools.yang.bi |
854 | | nding.InstanceIdentifier`` |
855 +--------------------------------------+--------------------------------------+
857 Enumeration Substatement Enum
858 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
860 The YANG ``enumeration`` type has to contain some ``enum``
861 substatements. An ``enumeration`` is mapped as Java enum type
862 (standalone class) and every YANG enum substatements is mapped to Java
863 enum’s predefined values.
865 An ``enum`` statement can have following substatements:
867 +--------------------------------------+--------------------------------------+
868 | Enum’s Substatement | Java mapping |
869 +======================================+======================================+
870 | description | is not mapped in API |
871 +--------------------------------------+--------------------------------------+
872 | value | mapped as input parameter for every |
873 | | predefined value of enum |
874 +--------------------------------------+--------------------------------------+
876 For example, the following YANG:
882 typedef typedef-enumeration {
885 description "enum1 description";
896 is converted into this Java:
898 **TypedefEnumeration.java.**
902 public enum TypedefEnumeration {
909 private TypedefEnumeration(int value) {
914 Bits’s Substatement Bit
915 ^^^^^^^^^^^^^^^^^^^^^^^
917 The YANG ``bits`` type has to contain some bit substatements. YANG
918 ``bits`` is mapped to a Java class (standalone class) and every YANG
919 ``bits`` substatements is mapped to a boolean attribute of that class.
920 In addition, the class provides overridden versions of the Object
921 methods ``hashCode``, ``toString``, and ``equals``.
923 For example, the following YANG:
929 typedef typedef-bits {
932 description "first-bit description";
939 is converted into this Java:
941 **TypedefBits.java.**
945 public class TypedefBits {
947 private Boolean firstBit;
948 private Boolean secondBit;
950 public TypedefBits() {
954 public Boolean getFirstBit() {
958 public void setFirstBit(Boolean firstBit) {
959 this.firstBit = firstBit;
962 public Boolean getSecondBit() {
966 public void setSecondBit(Boolean secondBit) {
967 this.secondBit = secondBit;
971 public int hashCode() {
972 final int prime = 31;
974 result = prime * result +
975 ((firstBit == null) ? 0 : firstBit.hashCode());
976 result = prime * result +
977 ((secondBit == null) ? 0 : secondBit.hashCode());
982 public boolean equals(Object obj) {
989 if (getClass() != obj.getClass()) {
992 TypedefBits other = (TypedefBits) obj;
993 if (firstBit == null) {
994 if (other.firstBit != null) {
997 } else if(!firstBit.equals(other.firstBit)) {
1000 if (secondBit == null) {
1001 if (other.secondBit != null) {
1004 } else if(!secondBit.equals(other.secondBit)) {
1011 public String toString() {
1012 StringBuilder builder = new StringBuilder();
1013 builder.append("TypedefBits [firstBit=");
1014 builder.append(firstBit);
1015 builder.append(", secondBit=");
1016 builder.append(secondBit);
1017 builder.append("]");
1018 return builder.toString();
1022 Union’s Substatement Type
1023 ^^^^^^^^^^^^^^^^^^^^^^^^^
1025 If the type of a ``typedef`` is ``union``, it has to contain ``type``
1026 substatements. The ``union typedef`` is mapped to class and its ``type``
1027 substatements are mapped to private class members. Every YANG union
1028 subtype gets its own Java constructor with a parameter which represent
1029 just that one attribute.
1031 For example, the following YANG:
1037 typedef typedef-union {
1044 is converted into this Java:
1046 **TypdefUnion.java.**
1050 public class TypedefUnion {
1052 private Integer int32;
1053 private String string;
1055 public TypedefUnion(Integer int32) {
1060 public TypedefUnion(String string) {
1062 this.string = string;
1065 public Integer getInt32() {
1069 public String getString() {
1074 public int hashCode() {
1075 final int prime = 31;
1077 result = prime * result + ((int32 == null) ? 0 : int32.hashCode());
1078 result = prime * result + ((string == null) ? 0 : string.hashCode());
1083 public boolean equals(Object obj) {
1090 if (getClass() != obj.getClass()) {
1093 TypedefUnion other = (TypedefUnion) obj;
1094 if (int32 == null) {
1095 if (other.int32 != null) {
1098 } else if(!int32.equals(other.int32)) {
1101 if (string == null) {
1102 if (other.string != null) {
1105 } else if(!string.equals(other.string)) {
1112 public String toString() {
1113 StringBuilder builder = new StringBuilder();
1114 builder.append("TypedefUnion [int32=");
1115 builder.append(int32);
1116 builder.append(", string=");
1117 builder.append(string);
1118 builder.append("]");
1119 return builder.toString();
1126 The YANG ``string`` type can contain the substatements ``length`` and
1127 ``pattern`` which are mapped as follows:
1129 +--------------------------------------+--------------------------------------+
1130 | Type substatements | Mapping to Java |
1131 +======================================+======================================+
1132 | length | not mapped |
1133 +--------------------------------------+--------------------------------------+
1134 | pattern | | . list of string constants = list |
1136 | | | . list of Pattern objects |
1137 | | | . static initialization block |
1138 | | where list of Patterns is |
1139 | | initialized from list of string of |
1141 +--------------------------------------+--------------------------------------+
1143 For example, the following YANG:
1149 typedef typedef-string {
1156 is converted into this Java:
1158 **TypedefString.java.**
1162 public class TypedefString {
1164 private static final List<Pattern> patterns = new ArrayList<Pattern>();
1165 public static final List<String> PATTERN`CONSTANTS = Arrays.asList("[a][.]*");
1168 for (String regEx : PATTERN`CONSTANTS) {
1169 patterns.add(Pattern.compile(regEx));
1173 private String typedefString;
1175 public TypedefString(String typedefString) {
1177 // Pattern validation
1178 this.typedefString = typedefString;
1181 public String getTypedefString() {
1182 return typedefString;
1186 public int hashCode() {
1187 final int prime = 31;
1189 result = prime * result + ((typedefString == null) ? 0 : typedefString.hashCode());
1194 public boolean equals(Object obj) {
1201 if (getClass() != obj.getClass()) {
1204 TypedefString other = (TypedefString) obj;
1205 if (typedefString == null) {
1206 if (other.typedefString != null) {
1209 } else if(!typedefString.equals(other.typedefString)) {
1216 public String toString() {
1217 StringBuilder builder = new StringBuilder();
1218 builder.append("TypedefString [typedefString=");
1219 builder.append(typedefString);
1220 builder.append("]");
1221 return builder.toString();
1228 The purpose of the ``identity`` statement is to define a new globally
1229 unique, abstract, and untyped value.
1231 The ``base`` substatement argument is the name of existing identity from
1232 which the new identity is derived.
1234 Given that, an ``identity`` statement is mapped to Java abstract class
1235 and any ``base`` substatements are mapped as ``extends`` Java keyword.
1236 The identity name is translated to class name.
1238 For example, the following YANG:
1244 identity toast-type {
1248 identity white-bread {
1252 is converted into this Java:
1258 public abstract class ToastType extends BaseIdentity {
1259 protected ToastType() {
1264 **WhiteBread.java.**
1268 public abstract class WhiteBread extends ToastType {
1269 protected WhiteBread() {