Vinod Kumar S
Committed by Gerrit Code Review

[ONOS-3904] Derived data type and formatting fixes

Change-Id: I1d68899e0056fa0db6322e83f7e9d3ff9b3b1ee0
Showing 19 changed files with 429 additions and 121 deletions
...@@ -215,7 +215,7 @@ public enum YangDataTypes { ...@@ -215,7 +215,7 @@ public enum YangDataTypes {
215 INSTANCE_IDENTIFIER, 215 INSTANCE_IDENTIFIER,
216 216
217 /** 217 /**
218 - * Derived Data type. 218 + * Derived data type.
219 */ 219 */
220 DERIVED; 220 DERIVED;
221 221
......
1 +/*Copyright 2016.year Open Networking Laboratory
2 +
3 +Licensed under the Apache License, Version 2.0 (the "License");
4 +you may not use this file except in compliance with the License.
5 +You may obtain a copy of the License at
6 +
7 + http://www.apache.org/licenses/LICENSE-2.0
8 +
9 +Unless required by applicable law or agreed to in writing, software
10 +distributed under the License is distributed on an "AS IS" BASIS,
11 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 +See the License for the specific language governing permissions and
13 +limitations under the License.*/
14 +package org.onosproject.yangutils.datamodel;
15 +
16 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
17 +import org.onosproject.yangutils.parser.Parsable;
18 +import org.onosproject.yangutils.parser.ParsableDataType;
19 +
20 +/*-
21 + * The typedef Statement
22 + *
23 + * The "typedef" statement defines a new type that may be used locally
24 + * in the module, in modules or submodules which include it, and by
25 + * other modules that import from it. The new type is called the
26 + * "derived type", and the type from which it was derived is called
27 + * the "base type". All derived types can be traced back to a YANG
28 + * built-in type.
29 + *
30 + * The "typedef" statement's argument is an identifier that is the name
31 + * of the type to be defined, and MUST be followed by a block of
32 + * sub-statements that holds detailed typedef information.
33 + *
34 + * The name of the type MUST NOT be one of the YANG built-in types. If
35 + * the typedef is defined at the top level of a YANG module or
36 + * submodule, the name of the type to be defined MUST be unique within
37 + * the module.
38 + */
39 +/**
40 + * Derived type information.
41 + */
42 +public class YangDerivedType implements Parsable {
43 +
44 + /**
45 + * All derived types can be traced back to a YANG built-in type.
46 + */
47 + private YangDataTypes effectiveYangBuiltInType;
48 +
49 + /**
50 + * Base type from which the current type is derived.
51 + */
52 + private YangType<?> baseType;
53 +
54 + /**
55 + * Default constructor.
56 + */
57 + public YangDerivedType() {
58 + }
59 +
60 + /**
61 + * Get the effective YANG built-in type of the derived data type.
62 + *
63 + * @return effective YANG built-in type of the derived data type.
64 + */
65 + public YangDataTypes getEffectiveYangBuiltInType() {
66 + return effectiveYangBuiltInType;
67 + }
68 +
69 + /**
70 + * Set the effective YANG built-in type of the derived data type.
71 + *
72 + * @param builtInType effective YANG built-in type of the derived data type.
73 + */
74 + public void setEffectiveYangBuiltInType(YangDataTypes builtInType) {
75 + effectiveYangBuiltInType = builtInType;
76 + }
77 +
78 + /**
79 + * Get the base type information.
80 + *
81 + * @return base type information.
82 + */
83 + public YangType<?> getBaseType() {
84 + return baseType;
85 + }
86 +
87 + /**
88 + * Get the base type information.
89 + *
90 + * @param baseType base type information.
91 + */
92 + public void setBaseType(YangType<?> baseType) {
93 + this.baseType = baseType;
94 + }
95 +
96 + /**
97 + * Get the parsable type.
98 + */
99 + @Override
100 + public ParsableDataType getParsableDataType() {
101 + return ParsableDataType.DERIVED;
102 + }
103 +
104 + /**
105 + * TODO.
106 + */
107 + @Override
108 + public void validateDataOnEntry() throws DataModelException {
109 + // TODO Auto-generated method stub
110 +
111 + }
112 +
113 + /**
114 + * TODO.
115 + */
116 + @Override
117 + public void validateDataOnExit() throws DataModelException {
118 + // TODO Auto-generated method stub
119 +
120 + }
121 +
122 +}
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
16 16
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 +import java.util.HashSet;
20 +import java.util.Set;
21 +
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
21 import org.onosproject.yangutils.parser.ParsableDataType; 24 import org.onosproject.yangutils.parser.ParsableDataType;
22 25
23 -import java.util.HashSet;
24 -import java.util.Set;
25 -
26 /* 26 /*
27 * The enumeration built-in type represents values from a set of 27 * The enumeration built-in type represents values from a set of
28 * assigned names. 28 * assigned names.
......
...@@ -438,7 +438,7 @@ public class YangList extends YangNode ...@@ -438,7 +438,7 @@ public class YangList extends YangNode
438 */ 438 */
439 @Override 439 @Override
440 public void validateDataOnExit() throws DataModelException { 440 public void validateDataOnExit() throws DataModelException {
441 - List<String> keyList = getKeyList(); 441 + List<String> keys = getKeyList();
442 List<YangLeaf> leaves = getListOfLeaf(); 442 List<YangLeaf> leaves = getListOfLeaf();
443 List<YangLeafList> leafLists = getListOfLeafList(); 443 List<YangLeafList> leafLists = getListOfLeafList();
444 444
...@@ -447,29 +447,32 @@ public class YangList extends YangNode ...@@ -447,29 +447,32 @@ public class YangList extends YangNode
447 447
448 /* A list must have atleast one key leaf if config is true */ 448 /* A list must have atleast one key leaf if config is true */
449 if ((isConfig) 449 if ((isConfig)
450 - && ((keyList == null) || (leaves == null && leafLists == null))) { 450 + && ((keys == null) || ((leaves == null) && (leafLists == null)))) {
451 throw new DataModelException("A list must have atleast one key leaf if config is true;"); 451 throw new DataModelException("A list must have atleast one key leaf if config is true;");
452 - } else if (keyList != null) { 452 + } else if (keys != null) {
453 if (leaves != null) { 453 if (leaves != null) {
454 - validateLeafKey(leaves, keyList); 454 + validateLeafKey(leaves, keys);
455 } 455 }
456 456
457 if (leafLists != null) { 457 if (leafLists != null) {
458 - validateLeafListKey(leafLists, keyList); 458 + validateLeafListKey(leafLists, keys);
459 } 459 }
460 } 460 }
461 } 461 }
462 462
463 /** 463 /**
464 - * Sets the config's value to all leaf if leaf's config statement is not specified. 464 + * Sets the config's value to all leaf if leaf's config statement is not
465 + * specified.
465 * 466 *
466 * @param leaves list of leaf attributes of YANG list. 467 * @param leaves list of leaf attributes of YANG list.
467 * @param leafLists list of leaf-list attributes of YANG list. 468 * @param leafLists list of leaf-list attributes of YANG list.
468 */ 469 */
469 private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) { 470 private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
470 471
471 - /* If "config" is not specified, the default is the same as the parent 472 + /*
472 - schema node's "config" value.*/ 473 + * If "config" is not specified, the default is the same as the parent
474 + * schema node's "config" value.
475 + */
473 if (leaves != null) { 476 if (leaves != null) {
474 for (YangLeaf leaf : leaves) { 477 for (YangLeaf leaf : leaves) {
475 if (leaf.isConfig() == null) { 478 if (leaf.isConfig() == null) {
...@@ -478,8 +481,10 @@ public class YangList extends YangNode ...@@ -478,8 +481,10 @@ public class YangList extends YangNode
478 } 481 }
479 } 482 }
480 483
481 - /* If "config" is not specified, the default is the same as the parent 484 + /*
482 - schema node's "config" value.*/ 485 + * If "config" is not specified, the default is the same as the parent
486 + * schema node's "config" value.
487 + */
483 if (leafLists != null) { 488 if (leafLists != null) {
484 for (YangLeafList leafList : leafLists) { 489 for (YangLeafList leafList : leafLists) {
485 if (leafList.isConfig() == null) { 490 if (leafList.isConfig() == null) {
...@@ -498,8 +503,10 @@ public class YangList extends YangNode ...@@ -498,8 +503,10 @@ public class YangList extends YangNode
498 */ 503 */
499 private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException { 504 private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException {
500 505
501 - /* If a node has "config" set to "false", no node underneath it can have 506 + /*
502 - "config" set to "true".*/ 507 + * If a node has "config" set to "false", no node underneath it can have
508 + * "config" set to "true".
509 + */
503 if ((!isConfig) && (leaves != null)) { 510 if ((!isConfig) && (leaves != null)) {
504 for (YangLeaf leaf : leaves) { 511 for (YangLeaf leaf : leaves) {
505 if (leaf.isConfig()) { 512 if (leaf.isConfig()) {
...@@ -523,19 +530,21 @@ public class YangList extends YangNode ...@@ -523,19 +530,21 @@ public class YangList extends YangNode
523 * Validates key statement of list. 530 * Validates key statement of list.
524 * 531 *
525 * @param leaves list of leaf attributes of list. 532 * @param leaves list of leaf attributes of list.
526 - * @param keyList list of key attributes of list. 533 + * @param keys list of key attributes of list.
527 * @throws DataModelException a violation of data model rules. 534 * @throws DataModelException a violation of data model rules.
528 */ 535 */
529 - private void validateLeafKey(List<YangLeaf> leaves, List<String> keyList) throws DataModelException { 536 + private void validateLeafKey(List<YangLeaf> leaves, List<String> keys) throws DataModelException {
530 boolean leafFound = false; 537 boolean leafFound = false;
531 List<YangLeaf> keyLeaves = new LinkedList<>(); 538 List<YangLeaf> keyLeaves = new LinkedList<>();
532 539
533 - /* 1. Leaf identifier must refer to a child leaf of the list 540 + /*
534 - 2. A leaf that is part of the key must not be the built-in type "empty". */ 541 + * 1. Leaf identifier must refer to a child leaf of the list 2. A leaf
535 - for (String key : keyList) { 542 + * that is part of the key must not be the built-in type "empty".
543 + */
544 + for (String key : keys) {
536 for (YangLeaf leaf : leaves) { 545 for (YangLeaf leaf : leaves) {
537 if (key.equals(leaf.getLeafName())) { 546 if (key.equals(leaf.getLeafName())) {
538 - if (leaf.getDataType().getDataTypeName().replace("\"", "").equals("empty")) { 547 + if (leaf.getDataType().getDataType() == YangDataTypes.EMPTY) {
539 throw new DataModelException(" A leaf that is part of the key must not be the built-in " + 548 throw new DataModelException(" A leaf that is part of the key must not be the built-in " +
540 "type \"empty\"."); 549 "type \"empty\".");
541 } 550 }
...@@ -550,8 +559,10 @@ public class YangList extends YangNode ...@@ -550,8 +559,10 @@ public class YangList extends YangNode
550 leafFound = false; 559 leafFound = false;
551 } 560 }
552 561
553 - /* All key leafs in a list MUST have the same value for their "config" 562 + /*
554 - as the list itself. */ 563 + * All key leafs in a list MUST have the same value for their "config"
564 + * as the list itself.
565 + */
555 for (YangLeaf keyLeaf : keyLeaves) { 566 for (YangLeaf keyLeaf : keyLeaves) {
556 if (isConfig != keyLeaf.isConfig()) { 567 if (isConfig != keyLeaf.isConfig()) {
557 throw new DataModelException("All key leafs in a list must have the same value for their" + 568 throw new DataModelException("All key leafs in a list must have the same value for their" +
...@@ -564,19 +575,21 @@ public class YangList extends YangNode ...@@ -564,19 +575,21 @@ public class YangList extends YangNode
564 * Validates key statement of list. 575 * Validates key statement of list.
565 * 576 *
566 * @param leafLists list of leaf-list attributes of list. 577 * @param leafLists list of leaf-list attributes of list.
567 - * @param keyList list of key attributes of list. 578 + * @param keys list of key attributes of list.
568 * @throws DataModelException a violation of data model rules. 579 * @throws DataModelException a violation of data model rules.
569 */ 580 */
570 - private void validateLeafListKey(List<YangLeafList> leafLists, List<String> keyList) throws DataModelException { 581 + private void validateLeafListKey(List<YangLeafList> leafLists, List<String> keys) throws DataModelException {
571 boolean leafFound = false; 582 boolean leafFound = false;
572 List<YangLeafList> keyLeafLists = new LinkedList<>(); 583 List<YangLeafList> keyLeafLists = new LinkedList<>();
573 584
574 - /* 1. Leaf identifier must refer to a child leaf of the list 585 + /*
575 - 2. A leaf that is part of the key must not be the built-in type "empty". */ 586 + * 1. Leaf identifier must refer to a child leaf of the list 2. A leaf
576 - for (String key : keyList) { 587 + * that is part of the key must not be the built-in type "empty".
588 + */
589 + for (String key : keys) {
577 for (YangLeafList leafList : leafLists) { 590 for (YangLeafList leafList : leafLists) {
578 if (key.equals(leafList.getLeafName())) { 591 if (key.equals(leafList.getLeafName())) {
579 - if (leafList.getDataType().getDataTypeName().replace("\"", "").equals("empty")) { 592 + if (leafList.getDataType().getDataType() == YangDataTypes.EMPTY) {
580 throw new DataModelException(" A leaf-list that is part of the key must not be the built-in " + 593 throw new DataModelException(" A leaf-list that is part of the key must not be the built-in " +
581 "type \"empty\"."); 594 "type \"empty\".");
582 } 595 }
...@@ -591,8 +604,10 @@ public class YangList extends YangNode ...@@ -591,8 +604,10 @@ public class YangList extends YangNode
591 leafFound = false; 604 leafFound = false;
592 } 605 }
593 606
594 - /* All key leafs in a list MUST have the same value for their "config" 607 + /*
595 - as the list itself. */ 608 + * All key leafs in a list MUST have the same value for their "config"
609 + * as the list itself.
610 + */
596 for (YangLeafList keyLeafList : keyLeafLists) { 611 for (YangLeafList keyLeafList : keyLeafLists) {
597 if (isConfig() != keyLeafList.isConfig()) { 612 if (isConfig() != keyLeafList.isConfig()) {
598 throw new DataModelException("All key leaf-lists in a list must have the same value for their" + 613 throw new DataModelException("All key leaf-lists in a list must have the same value for their" +
...@@ -601,8 +616,9 @@ public class YangList extends YangNode ...@@ -601,8 +616,9 @@ public class YangList extends YangNode
601 } 616 }
602 } 617 }
603 618
604 - /* (non-Javadoc) 619 + /**
605 - * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() 620 + * Populate the cached handle with information about the list attributes to
621 + * generate java code.
606 */ 622 */
607 @Override 623 @Override
608 public void generateJavaCodeEntry() { 624 public void generateJavaCodeEntry() {
......
...@@ -166,6 +166,43 @@ public class YangModule extends YangNode ...@@ -166,6 +166,43 @@ public class YangModule extends YangNode
166 */ 166 */
167 private CachedFileHandle fileHandle; 167 private CachedFileHandle fileHandle;
168 168
169 + /*-
170 + * Nested typedefs and groupings.
171 + * Typedefs and groupings may appear nested under many YANG statements,
172 + * allowing these to be lexically scoped by the hierarchy under which
173 + * they appear. This allows types and groupings to be defined near
174 + * where they are used, rather than placing them at the top level of the
175 + * hierarchy. The close proximity increases readability.
176 + *
177 + * Scoping also allows types to be defined without concern for naming
178 + * conflicts between types in different submodules. Type names can be
179 + * specified without adding leading strings designed to prevent name
180 + * collisions within large modules.
181 + *
182 + * Finally, scoping allows the module author to keep types and groupings
183 + * private to their module or submodule, preventing their reuse. Since
184 + * only top-level types and groupings (i.e., those appearing as
185 + * sub-statements to a module or submodule statement) can be used outside
186 + * the module or submodule, the developer has more control over what
187 + * pieces of their module are presented to the outside world, supporting
188 + * the need to hide internal information and maintaining a boundary
189 + * between what is shared with the outside world and what is kept
190 + * private.
191 + *
192 + * Scoped definitions MUST NOT shadow definitions at a higher scope. A
193 + * type or grouping cannot be defined if a higher level in the schema
194 + * hierarchy has a definition with a matching identifier.
195 + *
196 + * A reference to an unprefixed type or grouping, or one which uses the
197 + * prefix of the current module, is resolved by locating the closest
198 + * matching "typedef" or "grouping" statement among the immediate
199 + * sub-statements of each ancestor statement.
200 + */
201 + /**
202 + * List of nodes which require nested reference resolution.
203 + */
204 + private List<YangNode> nestedReferenceResoulutionList;
205 +
169 /** 206 /**
170 * Create a YANG node of module type. 207 * Create a YANG node of module type.
171 */ 208 */
...@@ -173,16 +210,20 @@ public class YangModule extends YangNode ...@@ -173,16 +210,20 @@ public class YangModule extends YangNode
173 super(YangNodeType.MODULE_NODE); 210 super(YangNodeType.MODULE_NODE);
174 } 211 }
175 212
176 - /* (non-Javadoc) 213 + /**
177 - * @see org.onosproject.yangutils.datamodel.YangNode#getName() 214 + * Get name of the module.
215 + *
216 + * @return module name.
178 */ 217 */
179 @Override 218 @Override
180 public String getName() { 219 public String getName() {
181 return name; 220 return name;
182 } 221 }
183 222
184 - /* (non-Javadoc) 223 + /**
185 - * @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String) 224 + * Set module name.
225 + *
226 + * @param moduleName module name.
186 */ 227 */
187 @Override 228 @Override
188 public void setName(String moduleName) { 229 public void setName(String moduleName) {
...@@ -511,6 +552,37 @@ public class YangModule extends YangNode ...@@ -511,6 +552,37 @@ public class YangModule extends YangNode
511 } 552 }
512 553
513 /** 554 /**
555 + * Get the list of nested reference's which required resolution.
556 + *
557 + * @return list of nested reference's which required resolution.
558 + */
559 + public List<YangNode> getNestedReferenceResoulutionList() {
560 + return nestedReferenceResoulutionList;
561 + }
562 +
563 + /**
564 + * Set list of nested reference's which requires resolution.
565 + *
566 + * @param nestedReferenceResoulutionList list of nested reference's which
567 + * requires resolution.
568 + */
569 + private void setNestedReferenceResoulutionList(List<YangNode> nestedReferenceResoulutionList) {
570 + this.nestedReferenceResoulutionList = nestedReferenceResoulutionList;
571 + }
572 +
573 + /**
574 + * Set list of nested reference's which requires resolution.
575 + *
576 + * @param nestedReference nested reference which requires resolution.
577 + */
578 + public void addToNestedReferenceResoulutionList(YangNode nestedReference) {
579 + if (getNestedReferenceResoulutionList() == null) {
580 + setNestedReferenceResoulutionList(new LinkedList<YangNode>());
581 + }
582 + getNestedReferenceResoulutionList().add(nestedReference);
583 + }
584 +
585 + /**
514 * Returns the type of the parsed data. 586 * Returns the type of the parsed data.
515 * 587 *
516 * @return returns MODULE_DATA. 588 * @return returns MODULE_DATA.
...@@ -601,4 +673,28 @@ public class YangModule extends YangNode ...@@ -601,4 +673,28 @@ public class YangModule extends YangNode
601 } 673 }
602 } 674 }
603 675
676 + /**
677 + * Add a type to resolve the nested references.
678 + *
679 + * @param node grouping or typedef node which needs to be resolved.
680 + * @throws DataModelException data model exception.
681 + */
682 + public static void addToResolveList(YangNode node) throws DataModelException {
683 + /* get the module node to add maintain the list of nested reference */
684 + YangModule module;
685 + YangNode curNode = node;
686 + while (curNode.getNodeType() != YangNodeType.MODULE_NODE) {
687 + curNode = curNode.getParent();
688 + if (curNode == null) {
689 + break;
690 + }
691 + }
692 + if (curNode == null) {
693 + throw new DataModelException("Datamodel tree is not correct");
694 + }
695 +
696 + module = (YangModule) curNode;
697 + module.addToNestedReferenceResoulutionList(node);
698 + return;
699 + }
604 } 700 }
......
...@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and ...@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
13 limitations under the License.*/ 13 limitations under the License.*/
14 package org.onosproject.yangutils.datamodel; 14 package org.onosproject.yangutils.datamodel;
15 15
16 +import java.util.LinkedList;
16 import java.util.List; 17 import java.util.List;
17 18
18 /*- 19 /*-
...@@ -51,7 +52,7 @@ public class YangPatternRestriction { ...@@ -51,7 +52,7 @@ public class YangPatternRestriction {
51 /** 52 /**
52 * Pattern restriction defined for the current type. 53 * Pattern restriction defined for the current type.
53 */ 54 */
54 - private List<String> pattern; 55 + private List<String> patternList;
55 56
56 /** 57 /**
57 * Effective pattern restriction that needs inherited from base type. 58 * Effective pattern restriction that needs inherited from base type.
...@@ -62,6 +63,7 @@ public class YangPatternRestriction { ...@@ -62,6 +63,7 @@ public class YangPatternRestriction {
62 * Default constructor. 63 * Default constructor.
63 */ 64 */
64 public YangPatternRestriction() { 65 public YangPatternRestriction() {
66 + setPatternList(new LinkedList<String>());
65 } 67 }
66 68
67 /** 69 /**
...@@ -69,8 +71,8 @@ public class YangPatternRestriction { ...@@ -69,8 +71,8 @@ public class YangPatternRestriction {
69 * 71 *
70 * @return pattern restriction defined for the current type. 72 * @return pattern restriction defined for the current type.
71 */ 73 */
72 - public List<String> getPattern() { 74 + public List<String> getPatternList() {
73 - return pattern; 75 + return patternList;
74 } 76 }
75 77
76 /** 78 /**
...@@ -78,8 +80,17 @@ public class YangPatternRestriction { ...@@ -78,8 +80,17 @@ public class YangPatternRestriction {
78 * 80 *
79 * @param pattern pattern restriction defined for the current type.. 81 * @param pattern pattern restriction defined for the current type..
80 */ 82 */
81 - public void setPattern(List<String> pattern) { 83 + private void setPatternList(List<String> pattern) {
82 - this.pattern = pattern; 84 + patternList = pattern;
85 + }
86 +
87 + /**
88 + * Add a new pattern to the list of pattern restriction.
89 + *
90 + * @param newPattern pattern restriction.
91 + */
92 + public void addPattern(String newPattern) {
93 + getPatternList().add(newPattern);
83 } 94 }
84 95
85 /** 96 /**
......
...@@ -143,7 +143,7 @@ public class YangRangeRestriction<T extends Comparable<T>> implements YangDesc, ...@@ -143,7 +143,7 @@ public class YangRangeRestriction<T extends Comparable<T>> implements YangDesc,
143 * @param newInterval restricted length interval. 143 * @param newInterval restricted length interval.
144 * @throws DataModelException data model exception for range restriction. 144 * @throws DataModelException data model exception for range restriction.
145 */ 145 */
146 - public void addLenghtRestrictionInterval(YangRangeInterval<T> newInterval) throws DataModelException { 146 + public void addRangeRestrictionInterval(YangRangeInterval<T> newInterval) throws DataModelException {
147 147
148 checkNotNull(newInterval); 148 checkNotNull(newInterval);
149 checkNotNull(newInterval.getStartValue()); 149 checkNotNull(newInterval.getStartValue());
......
...@@ -109,7 +109,19 @@ public class YangStringRestriction { ...@@ -109,7 +109,19 @@ public class YangStringRestriction {
109 * 109 *
110 * @param patternRestriction pattern restriction for the type. 110 * @param patternRestriction pattern restriction for the type.
111 */ 111 */
112 - public void setPatternRestriction(YangPatternRestriction patternRestriction) { 112 + private void setPatternRestriction(YangPatternRestriction patternRestriction) {
113 this.patternRestriction = patternRestriction; 113 this.patternRestriction = patternRestriction;
114 } 114 }
115 +
116 + /**
117 + * Add a new pattern restriction for the type.
118 + *
119 + * @param newPattern new pattern restriction for the type.
120 + */
121 + public void addPattern(String newPattern) {
122 + if (getPatternRestriction() == null) {
123 + setPatternRestriction(new YangPatternRestriction());
124 + }
125 + getPatternRestriction().addPattern(newPattern);
126 + }
115 } 127 }
......
...@@ -54,10 +54,6 @@ import org.onosproject.yangutils.translator.CachedFileHandle; ...@@ -54,10 +54,6 @@ import org.onosproject.yangutils.translator.CachedFileHandle;
54 */ 54 */
55 public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { 55 public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
56 56
57 - /**
58 - * Name of derived data type.
59 - */
60 - private String derivedName;
61 57
62 /** 58 /**
63 * Default value in string, needs to be converted to the target object, 59 * Default value in string, needs to be converted to the target object,
...@@ -81,14 +77,9 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -81,14 +77,9 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
81 private YangStatusType status; 77 private YangStatusType status;
82 78
83 /** 79 /**
84 - * Derived data type. The type will be set when the parser detects the type 80 + * Maintain the derived type information.
85 - * parsing. Hence it is of raw type and it not know at the time of creation
86 - * of the object. i.e. in entry parse, it will not be know, in the exit
87 - * parse we may know the type implicitly based on the restriction. We must
88 - * know and validate the base built in type, by the linking phase. It is a
89 - * RAW type and it usage needs to be validate in linking phase.
90 */ 81 */
91 - private YangType<?> derivedType; 82 + private YangType<YangDerivedType> derivedType;
92 83
93 /** 84 /**
94 * Units of the data type. 85 * Units of the data type.
...@@ -96,11 +87,6 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -96,11 +87,6 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
96 private String units; 87 private String units;
97 88
98 /** 89 /**
99 - * YANG base built in data type.
100 - */
101 - private YangDataTypes baseBuiltInType;
102 -
103 - /**
104 * package of the generated java code. 90 * package of the generated java code.
105 */ 91 */
106 private String pkg; 92 private String pkg;
...@@ -112,23 +98,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -112,23 +98,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
112 super(YangNodeType.TYPEDEF_NODE); 98 super(YangNodeType.TYPEDEF_NODE);
113 } 99 }
114 100
115 - /**
116 - * Get the data type name.
117 - *
118 - * @return the data type name.
119 - */
120 - public String getDerivedName() {
121 - return derivedName;
122 - }
123 101
124 - /**
125 - * Set the data type name.
126 - *
127 - * @param derrivedName data type name.
128 - */
129 - public void setDerivedName(String derrivedName) {
130 - derivedName = derrivedName;
131 - }
132 102
133 /** 103 /**
134 * Get the default value. 104 * Get the default value.
...@@ -209,20 +179,20 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -209,20 +179,20 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
209 } 179 }
210 180
211 /** 181 /**
212 - * Get the referenced type. 182 + * Get the derived type.
213 * 183 *
214 - * @return the referenced type. 184 + * @return the derived type.
215 */ 185 */
216 - public YangType<?> getDerivedType() { 186 + public YangType<YangDerivedType> getDerivedType() {
217 return derivedType; 187 return derivedType;
218 } 188 }
219 189
220 /** 190 /**
221 - * Get the referenced type. 191 + * Set the derived type.
222 * 192 *
223 - * @param derivedType the referenced type. 193 + * @param derivedType the derived type.
224 */ 194 */
225 - public void setDerivedType(YangType<?> derivedType) { 195 + public void setDerivedType(YangType<YangDerivedType> derivedType) {
226 this.derivedType = derivedType; 196 this.derivedType = derivedType;
227 } 197 }
228 198
...@@ -245,24 +215,6 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -245,24 +215,6 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
245 } 215 }
246 216
247 /** 217 /**
248 - * Get the base built in YANG data type.
249 - *
250 - * @return base built in YANG data type.
251 - */
252 - public YangDataTypes getBaseBuiltInType() {
253 - return baseBuiltInType;
254 - }
255 -
256 - /**
257 - * Set the base built in YANG data type.
258 - *
259 - * @param baseBuiltInType base built in YANG data type.
260 - */
261 - public void setBaseBuiltInType(YangDataTypes baseBuiltInType) {
262 - this.baseBuiltInType = baseBuiltInType;
263 - }
264 -
265 - /**
266 * Returns the type of the data. 218 * Returns the type of the data.
267 * 219 *
268 * @return returns TYPEDEF_DATA 220 * @return returns TYPEDEF_DATA
...@@ -289,7 +241,34 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -289,7 +241,34 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
289 */ 241 */
290 @Override 242 @Override
291 public void validateDataOnExit() throws DataModelException { 243 public void validateDataOnExit() throws DataModelException {
292 - // TODO auto-generated method stub, to be implemented by parser 244 + YangType<YangDerivedType> type = getDerivedType();
245 + if (type == null) {
246 + throw new DataModelException("Typedef does not have type info.");
247 + }
248 + if ((type.getDataType() != YangDataTypes.DERIVED)
249 + || (type.getDataTypeName() == null)) {
250 + throw new DataModelException("Typedef type is not derived.");
251 + }
252 +
253 + YangDerivedType derivedTypeInfo = type.getDataTypeExtendedInfo();
254 + if (derivedTypeInfo == null) {
255 + throw new DataModelException("derrived type does not have derived info.");
256 + }
257 +
258 + YangType<?> baseType = derivedTypeInfo.getBaseType();
259 + if (baseType == null) {
260 + throw new DataModelException("Base type of a derived type is missing.");
261 + }
262 +
263 + if (derivedTypeInfo.getEffectiveYangBuiltInType() == null) {
264 + /* resolve the effective type from the data tree. */
265 + /*
266 + * TODO: try to resolve the nested reference, if possible in the
267 + * partial tree, otherwise we need to resolve finally when the
268 + * complete module is created.
269 + */
270 + YangModule.addToResolveList(this);
271 + }
293 } 272 }
294 273
295 /** 274 /**
...@@ -299,7 +278,10 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -299,7 +278,10 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
299 */ 278 */
300 @Override 279 @Override
301 public String getName() { 280 public String getName() {
302 - return derivedName; 281 + if (getDerivedType() != null) {
282 + return getDerivedType().getDataTypeName();
283 + }
284 + return null;
303 } 285 }
304 286
305 /** 287 /**
...@@ -309,8 +291,12 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -309,8 +291,12 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
309 */ 291 */
310 @Override 292 @Override
311 public void setName(String name) { 293 public void setName(String name) {
312 - // TODO Auto-generated method stub 294 + if (getDerivedType() == null) {
313 - 295 + throw new RuntimeException(
296 + "Derrived Type info needs to be set in parser when the typedef listner is processed");
297 + }
298 + getDerivedType().setDataTypeName(name);
299 + getDerivedType().setDataType(YangDataTypes.DERIVED);
314 } 300 }
315 301
316 /** 302 /**
......
...@@ -222,7 +222,12 @@ public enum ParsableDataType { ...@@ -222,7 +222,12 @@ public enum ParsableDataType {
222 /** 222 /**
223 * Identifies the YANG organization parsed data. 223 * Identifies the YANG organization parsed data.
224 */ 224 */
225 - ORGANIZATION_DATA; 225 + ORGANIZATION_DATA,
226 +
227 + /**
228 + * Identifies the derived data type.
229 + */
230 + DERIVED;
226 231
227 /** 232 /**
228 * Returns the YANG construct keyword corresponding to enum values. 233 * Returns the YANG construct keyword corresponding to enum values.
...@@ -315,6 +320,8 @@ public enum ParsableDataType { ...@@ -315,6 +320,8 @@ public enum ParsableDataType {
315 return "value"; 320 return "value";
316 case DEFAULT_DATA: 321 case DEFAULT_DATA:
317 return "default"; 322 return "default";
323 + case DERIVED:
324 + return "derived";
318 default: 325 default:
319 return "yang"; 326 return "yang";
320 } 327 }
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
16 16
17 package org.onosproject.yangutils.parser.impl; 17 package org.onosproject.yangutils.parser.impl;
18 18
19 +import java.util.Stack;
20 +
19 import org.antlr.v4.runtime.ParserRuleContext; 21 import org.antlr.v4.runtime.ParserRuleContext;
20 import org.antlr.v4.runtime.tree.ErrorNode; 22 import org.antlr.v4.runtime.tree.ErrorNode;
21 import org.antlr.v4.runtime.tree.TerminalNode; 23 import org.antlr.v4.runtime.tree.TerminalNode;
...@@ -57,8 +59,6 @@ import org.onosproject.yangutils.parser.impl.listeners.UnitsListener; ...@@ -57,8 +59,6 @@ import org.onosproject.yangutils.parser.impl.listeners.UnitsListener;
57 import org.onosproject.yangutils.parser.impl.listeners.ValueListener; 59 import org.onosproject.yangutils.parser.impl.listeners.ValueListener;
58 import org.onosproject.yangutils.parser.impl.listeners.VersionListener; 60 import org.onosproject.yangutils.parser.impl.listeners.VersionListener;
59 61
60 -import java.util.Stack;
61 -
62 /** 62 /**
63 * ANTLR generates a parse-tree listener interface that responds to events 63 * ANTLR generates a parse-tree listener interface that responds to events
64 * triggered by the built-in tree walker. The methods in listener are just 64 * triggered by the built-in tree walker. The methods in listener are just
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
16 16
17 package org.onosproject.yangutils.parser.impl; 17 package org.onosproject.yangutils.parser.impl;
18 18
19 +import java.io.IOException;
20 +
19 import org.antlr.v4.runtime.ANTLRFileStream; 21 import org.antlr.v4.runtime.ANTLRFileStream;
20 import org.antlr.v4.runtime.ANTLRInputStream; 22 import org.antlr.v4.runtime.ANTLRInputStream;
21 import org.antlr.v4.runtime.CommonTokenStream; 23 import org.antlr.v4.runtime.CommonTokenStream;
...@@ -28,8 +30,6 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; ...@@ -28,8 +30,6 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
28 import org.onosproject.yangutils.parser.exceptions.ParserException; 30 import org.onosproject.yangutils.parser.exceptions.ParserException;
29 import org.onosproject.yangutils.parser.impl.parserutils.ParseTreeErrorListener; 31 import org.onosproject.yangutils.parser.impl.parserutils.ParseTreeErrorListener;
30 32
31 -import java.io.IOException;
32 -
33 /** 33 /**
34 * Manages file parsing, parse tree creation and data model tree creation 34 * Manages file parsing, parse tree creation and data model tree creation
35 * corresponding to an input YANG file. 35 * corresponding to an input YANG file.
...@@ -88,8 +88,8 @@ public class YangUtilsParserManager implements YangUtilsParser { ...@@ -88,8 +88,8 @@ public class YangUtilsParserManager implements YangUtilsParser {
88 TreeWalkListener treeWalker = new TreeWalkListener(); 88 TreeWalkListener treeWalker = new TreeWalkListener();
89 89
90 /** 90 /**
91 - * Walk parse tree, provide call backs to methods in listener and 91 + * Walk parse tree, provide call backs to methods in listener and build
92 - * build data model tree. 92 + * data model tree.
93 */ 93 */
94 try { 94 try {
95 walker.walk(treeWalker, tree); 95 walker.walk(treeWalker, tree);
......
...@@ -48,10 +48,13 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -48,10 +48,13 @@ package org.onosproject.yangutils.parser.impl.listeners;
48 */ 48 */
49 49
50 import org.onosproject.yangutils.datamodel.YangContainer; 50 import org.onosproject.yangutils.datamodel.YangContainer;
51 +import org.onosproject.yangutils.datamodel.YangDataTypes;
52 +import org.onosproject.yangutils.datamodel.YangDerivedType;
51 import org.onosproject.yangutils.datamodel.YangList; 53 import org.onosproject.yangutils.datamodel.YangList;
52 import org.onosproject.yangutils.datamodel.YangModule; 54 import org.onosproject.yangutils.datamodel.YangModule;
53 import org.onosproject.yangutils.datamodel.YangNode; 55 import org.onosproject.yangutils.datamodel.YangNode;
54 import org.onosproject.yangutils.datamodel.YangSubModule; 56 import org.onosproject.yangutils.datamodel.YangSubModule;
57 +import org.onosproject.yangutils.datamodel.YangType;
55 import org.onosproject.yangutils.datamodel.YangTypeDef; 58 import org.onosproject.yangutils.datamodel.YangTypeDef;
56 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 59 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
57 import org.onosproject.yangutils.parser.Parsable; 60 import org.onosproject.yangutils.parser.Parsable;
...@@ -111,8 +114,16 @@ public final class TypeDefListener { ...@@ -111,8 +114,16 @@ public final class TypeDefListener {
111 throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY)); 114 throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
112 } 115 }
113 116
117 + /*
118 + * Create a derived type information, the base type must be set in type
119 + * listener.
120 + */
121 + YangType<YangDerivedType> derivedType = new YangType<YangDerivedType>();
122 + derivedType.setDataType(YangDataTypes.DERIVED);
123 + derivedType.setDataTypeName(ctx.IDENTIFIER().getText());
124 +
114 YangTypeDef typeDefNode = new YangTypeDef(); 125 YangTypeDef typeDefNode = new YangTypeDef();
115 - typeDefNode.setDerivedName(ctx.IDENTIFIER().getText()); 126 + typeDefNode.setDerivedType(derivedType);
116 127
117 Parsable curData = listener.getParsedDataStack().peek(); 128 Parsable curData = listener.getParsedDataStack().peek();
118 129
...@@ -149,6 +160,14 @@ public final class TypeDefListener { ...@@ -149,6 +160,14 @@ public final class TypeDefListener {
149 checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPEDEF_DATA, ctx.IDENTIFIER().getText(), EXIT); 160 checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPEDEF_DATA, ctx.IDENTIFIER().getText(), EXIT);
150 161
151 if (listener.getParsedDataStack().peek() instanceof YangTypeDef) { 162 if (listener.getParsedDataStack().peek() instanceof YangTypeDef) {
163 + YangTypeDef typeDefNode = (YangTypeDef) listener.getParsedDataStack().peek();
164 + try {
165 + typeDefNode.validateDataOnExit();
166 + } catch (DataModelException e) {
167 + // TODO Auto-generated catch block
168 + e.printStackTrace();
169 + }
170 +
152 listener.getParsedDataStack().pop(); 171 listener.getParsedDataStack().pop();
153 } else { 172 } else {
154 throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, TYPEDEF_DATA, 173 throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, TYPEDEF_DATA,
......
...@@ -17,14 +17,17 @@ ...@@ -17,14 +17,17 @@
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
20 +import org.onosproject.yangutils.datamodel.YangDerivedType;
20 import org.onosproject.yangutils.datamodel.YangLeaf; 21 import org.onosproject.yangutils.datamodel.YangLeaf;
21 import org.onosproject.yangutils.datamodel.YangLeafList; 22 import org.onosproject.yangutils.datamodel.YangLeafList;
22 import org.onosproject.yangutils.datamodel.YangType; 23 import org.onosproject.yangutils.datamodel.YangType;
24 +import org.onosproject.yangutils.datamodel.YangTypeDef;
23 import org.onosproject.yangutils.parser.Parsable; 25 import org.onosproject.yangutils.parser.Parsable;
24 -import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
25 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 26 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
26 import org.onosproject.yangutils.parser.exceptions.ParserException; 27 import org.onosproject.yangutils.parser.exceptions.ParserException;
27 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 28 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
29 +
30 +import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
28 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
29 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
...@@ -72,8 +75,9 @@ public final class TypeListener { ...@@ -72,8 +75,9 @@ public final class TypeListener {
72 // Check for stack to be non empty. 75 // Check for stack to be non empty.
73 checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), ENTRY); 76 checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), ENTRY);
74 77
75 - YangType type = new YangType();
76 YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText()); 78 YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText());
79 + YangType<?> type = new YangType();
80 +
77 type.setDataTypeName(ctx.string().getText()); 81 type.setDataTypeName(ctx.string().getText());
78 type.setDataType(yangDataTypes); 82 type.setDataType(yangDataTypes);
79 83
...@@ -112,8 +116,32 @@ public final class TypeListener { ...@@ -112,8 +116,32 @@ public final class TypeListener {
112 YangLeafList leafList = (YangLeafList) tmpData; 116 YangLeafList leafList = (YangLeafList) tmpData;
113 leafList.setDataType((YangType) type); 117 leafList.setDataType((YangType) type);
114 break; 118 break;
115 - case TYPEDEF_DATA: //TODO 119 + case TYPEDEF_DATA:
120 +
121 + /* Prepare the base type info and set in derived type */
122 + YangTypeDef typeDef = (YangTypeDef) tmpData;
123 + YangType<YangDerivedType> derivedType = typeDef.getDerivedType();
124 + if (derivedType == null) {
125 + //TODO: set the error info correctly, to depict missing info
126 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
127 + ctx.string().getText(), ENTRY));
128 + }
129 +
130 + YangDerivedType derivedTypeInfo = new YangDerivedType();
131 + if (((YangType) type).getDataType() != YangDataTypes.DERIVED) {
132 + derivedTypeInfo.setEffectiveYangBuiltInType(((YangType) type).getDataType());
133 + } else {
134 + /*
135 + * It will be resolved in the validate data model at exit.
136 + * Nothing needs to be done.
137 + */
138 + }
139 + derivedTypeInfo.setBaseType((YangType) type);
140 + derivedType.setDataTypeExtendedInfo(derivedTypeInfo);
141 +
116 break; 142 break;
143 + //TODO: union, deviate replacement statement.case TYPEDEF_DATA: //TODO
144 +
117 default: 145 default:
118 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA, 146 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
119 ctx.string().getText(), EXIT)); 147 ctx.string().getText(), EXIT));
......
...@@ -24,8 +24,7 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; ...@@ -24,8 +24,7 @@ import org.onosproject.yangutils.parser.exceptions.ParserException;
24 /** 24 /**
25 * By default, ANTLR sends all errors to standard error, this is changed by 25 * By default, ANTLR sends all errors to standard error, this is changed by
26 * providing this new implementation of interface ANTLRErrorListener. The 26 * providing this new implementation of interface ANTLRErrorListener. The
27 - * interface has a syntaxError() method that applies to both lexer and 27 + * interface has a syntaxError() method that applies to both lexer and parser.
28 - * parser.
29 */ 28 */
30 public class ParseTreeErrorListener extends BaseErrorListener { 29 public class ParseTreeErrorListener extends BaseErrorListener {
31 30
......
...@@ -53,11 +53,10 @@ public final class JavaCodeGenerator { ...@@ -53,11 +53,10 @@ public final class JavaCodeGenerator {
53 curTraversal = TraversalType.SIBILING; 53 curTraversal = TraversalType.SIBILING;
54 curNode = curNode.getNextSibling(); 54 curNode = curNode.getNextSibling();
55 } else { 55 } else {
56 - curTraversal = TraversalType.PARENT;
57 curNode.generateJavaCodeExit(); 56 curNode.generateJavaCodeExit();
57 + curTraversal = TraversalType.PARENT;
58 curNode = curNode.getParent(); 58 curNode = curNode.getParent();
59 } 59 }
60 } 60 }
61 -
62 } 61 }
63 } 62 }
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
16 16
17 package org.onosproject.yangutils.translator.tojava.utils; 17 package org.onosproject.yangutils.translator.tojava.utils;
18 18
19 +import java.util.List;
20 +import java.util.SortedSet;
21 +
19 import org.onosproject.yangutils.datamodel.YangType; 22 import org.onosproject.yangutils.datamodel.YangType;
20 import org.onosproject.yangutils.translator.GeneratedFileType; 23 import org.onosproject.yangutils.translator.GeneratedFileType;
21 import org.onosproject.yangutils.translator.tojava.GeneratedMethodTypes; 24 import org.onosproject.yangutils.translator.tojava.GeneratedMethodTypes;
...@@ -47,6 +50,17 @@ public final class JavaCodeSnippetGen { ...@@ -47,6 +50,17 @@ public final class JavaCodeSnippetGen {
47 } 50 }
48 51
49 /** 52 /**
53 + * reorder the import list based on the ONOS import rules.
54 + *
55 + * @param importInfo the set of classes/interfaces to be imported.
56 + * @return string of import info.
57 + */
58 + public List<ImportInfo> sortImportOrder(SortedSet<ImportInfo> importInfo) {
59 + /* TODO: reorder the import list based on the ONOS import rules. */
60 + return null;
61 + }
62 +
63 + /**
50 * Get the textual java code information corresponding to the import list. 64 * Get the textual java code information corresponding to the import list.
51 * 65 *
52 * @param importInfo import info. 66 * @param importInfo import info.
......
...@@ -109,7 +109,6 @@ public final class MethodsGenerator { ...@@ -109,7 +109,6 @@ public final class MethodsGenerator {
109 * @param returnType return type of method 109 * @param returnType return type of method
110 * @return constructed method impl 110 * @return constructed method impl
111 */ 111 */
112 - @SuppressWarnings("rawtypes")
113 public static String constructMethodInfo(GeneratedFileType genFileTypes, String yangName, 112 public static String constructMethodInfo(GeneratedFileType genFileTypes, String yangName,
114 GeneratedMethodTypes methodTypes, YangType<?> returnType) { 113 GeneratedMethodTypes methodTypes, YangType<?> returnType) {
115 114
......