Bharat saraswal
Committed by bharat saraswal-huawei

[ONOS-5003][ONOS-5004][ONOS-5005]Generated Code modification for YangUtils+added…

… interface for augmentation method and other api changes.

Change-Id: I954b9c99e182f21d01fcc5cd76fbac7d61a6c3aa
Showing 82 changed files with 2167 additions and 2494 deletions
...@@ -83,7 +83,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -83,7 +83,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
83 public class YangAugment 83 public class YangAugment
84 extends YangNode 84 extends YangNode
85 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentedInfo, Resolvable, 85 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentedInfo, Resolvable,
86 - YangXPathResolver, YangWhenHolder, YangIfFeatureHolder { 86 + YangXPathResolver, YangWhenHolder, YangIfFeatureHolder, YangTranslatorOperatorNode {
87 87
88 private static final long serialVersionUID = 806201602L; 88 private static final long serialVersionUID = 806201602L;
89 89
...@@ -254,7 +254,7 @@ public class YangAugment ...@@ -254,7 +254,7 @@ public class YangAugment
254 @Override 254 @Override
255 public void addLeaf(YangLeaf leaf) { 255 public void addLeaf(YangLeaf leaf) {
256 if (getListOfLeaf() == null) { 256 if (getListOfLeaf() == null) {
257 - setListOfLeaf(new LinkedList<YangLeaf>()); 257 + setListOfLeaf(new LinkedList<>());
258 } 258 }
259 259
260 getListOfLeaf().add(leaf); 260 getListOfLeaf().add(leaf);
...@@ -288,7 +288,7 @@ public class YangAugment ...@@ -288,7 +288,7 @@ public class YangAugment
288 @Override 288 @Override
289 public void addLeafList(YangLeafList leafList) { 289 public void addLeafList(YangLeafList leafList) {
290 if (getListOfLeafList() == null) { 290 if (getListOfLeafList() == null) {
291 - setListOfLeafList(new LinkedList<YangLeafList>()); 291 + setListOfLeafList(new LinkedList<>());
292 } 292 }
293 293
294 getListOfLeafList().add(leafList); 294 getListOfLeafList().add(leafList);
......
...@@ -96,7 +96,7 @@ import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CASE_D ...@@ -96,7 +96,7 @@ import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CASE_D
96 public class YangCase 96 public class YangCase
97 extends YangNode 97 extends YangNode
98 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentableNode, 98 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentableNode,
99 - YangWhenHolder, YangIfFeatureHolder { 99 + YangWhenHolder, YangIfFeatureHolder, YangIsFilterContentNodes {
100 100
101 private static final long serialVersionUID = 806201603L; 101 private static final long serialVersionUID = 806201603L;
102 102
...@@ -149,6 +149,8 @@ public class YangCase ...@@ -149,6 +149,8 @@ public class YangCase
149 */ 149 */
150 public YangCase() { 150 public YangCase() {
151 super(YangNodeType.CASE_NODE); 151 super(YangNodeType.CASE_NODE);
152 + listOfLeaf = new LinkedList<>();
153 + listOfLeafList = new LinkedList<>();
152 } 154 }
153 155
154 /** 156 /**
...@@ -239,7 +241,7 @@ public class YangCase ...@@ -239,7 +241,7 @@ public class YangCase
239 @Override 241 @Override
240 public void addLeaf(YangLeaf leaf) { 242 public void addLeaf(YangLeaf leaf) {
241 if (getListOfLeaf() == null) { 243 if (getListOfLeaf() == null) {
242 - setListOfLeaf(new LinkedList<YangLeaf>()); 244 + setListOfLeaf(new LinkedList<>());
243 } 245 }
244 246
245 getListOfLeaf().add(leaf); 247 getListOfLeaf().add(leaf);
......
...@@ -91,7 +91,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -91,7 +91,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
91 public class YangContainer 91 public class YangContainer
92 extends YangNode 92 extends YangNode
93 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, 93 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector,
94 - YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder { 94 + YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder, YangIsFilterContentNodes {
95 95
96 private static final long serialVersionUID = 806201605L; 96 private static final long serialVersionUID = 806201605L;
97 97
...@@ -158,6 +158,8 @@ public class YangContainer ...@@ -158,6 +158,8 @@ public class YangContainer
158 */ 158 */
159 public YangContainer() { 159 public YangContainer() {
160 super(YangNodeType.CONTAINER_NODE); 160 super(YangNodeType.CONTAINER_NODE);
161 + listOfLeaf = new LinkedList<>();
162 + listOfLeafList = new LinkedList<>();
161 } 163 }
162 164
163 /** 165 /**
......
...@@ -71,7 +71,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -71,7 +71,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
71 */ 71 */
72 public class YangInput 72 public class YangInput
73 extends YangNode 73 extends YangNode
74 - implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode { 74 + implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode, YangIsFilterContentNodes {
75 75
76 private static final long serialVersionUID = 806201608L; 76 private static final long serialVersionUID = 806201608L;
77 77
...@@ -97,8 +97,8 @@ public class YangInput ...@@ -97,8 +97,8 @@ public class YangInput
97 */ 97 */
98 public YangInput() { 98 public YangInput() {
99 super(YangNodeType.INPUT_NODE); 99 super(YangNodeType.INPUT_NODE);
100 - listOfLeaf = new LinkedList<YangLeaf>(); 100 + listOfLeaf = new LinkedList<>();
101 - listOfLeafList = new LinkedList<YangLeafList>(); 101 + listOfLeafList = new LinkedList<>();
102 } 102 }
103 103
104 @Override 104 @Override
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.datamodel;
18 +
19 +/**
20 + * Represent the YANG nodes which can contain is filter content match.
21 + */
22 +public interface YangIsFilterContentNodes {
23 +}
...@@ -19,6 +19,7 @@ package org.onosproject.yangutils.datamodel; ...@@ -19,6 +19,7 @@ package org.onosproject.yangutils.datamodel;
19 import java.util.ArrayList; 19 import java.util.ArrayList;
20 import java.util.LinkedList; 20 import java.util.LinkedList;
21 import java.util.List; 21 import java.util.List;
22 +
22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 import org.onosproject.yangutils.datamodel.utils.Parsable; 24 import org.onosproject.yangutils.datamodel.utils.Parsable;
24 import org.onosproject.yangutils.datamodel.utils.YangConstructType; 25 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
...@@ -71,7 +72,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -71,7 +72,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
71 public class YangList 72 public class YangList
72 extends YangNode 73 extends YangNode
73 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, 74 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector,
74 - YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder, YangDataNode { 75 + YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder, YangDataNode,
76 + YangIsFilterContentNodes {
75 77
76 private static final long serialVersionUID = 806201609L; 78 private static final long serialVersionUID = 806201609L;
77 79
...@@ -92,7 +94,7 @@ public class YangList ...@@ -92,7 +94,7 @@ public class YangList
92 94
93 /** 95 /**
94 * Reference RFC 6020. 96 * Reference RFC 6020.
95 - * 97 + * <p>
96 * The "key" statement, which MUST be present if the list represents 98 * The "key" statement, which MUST be present if the list represents
97 * configuration, and MAY be present otherwise, takes as an argument a 99 * configuration, and MAY be present otherwise, takes as an argument a
98 * string that specifies a space-separated list of leaf identifiers of this 100 * string that specifies a space-separated list of leaf identifiers of this
...@@ -100,39 +102,39 @@ public class YangList ...@@ -100,39 +102,39 @@ public class YangList
100 * such leaf identifier MUST refer to a child leaf of the list. The leafs 102 * such leaf identifier MUST refer to a child leaf of the list. The leafs
101 * can be defined directly in sub-statements to the list, or in groupings 103 * can be defined directly in sub-statements to the list, or in groupings
102 * used in the list. 104 * used in the list.
103 - * 105 + * <p>
104 * The combined values of all the leafs specified in the key are used to 106 * The combined values of all the leafs specified in the key are used to
105 * uniquely identify a list entry. All key leafs MUST be given values when a 107 * uniquely identify a list entry. All key leafs MUST be given values when a
106 * list entry is created. Thus, any default values in the key leafs or their 108 * list entry is created. Thus, any default values in the key leafs or their
107 * types are ignored. It also implies that any mandatory statement in the 109 * types are ignored. It also implies that any mandatory statement in the
108 * key leafs are ignored. 110 * key leafs are ignored.
109 - * 111 + * <p>
110 * A leaf that is part of the key can be of any built-in or derived type, 112 * A leaf that is part of the key can be of any built-in or derived type,
111 * except it MUST NOT be the built-in type "empty". 113 * except it MUST NOT be the built-in type "empty".
112 - * 114 + * <p>
113 * All key leafs in a list MUST have the same value for their "config" as 115 * All key leafs in a list MUST have the same value for their "config" as
114 * the list itself. 116 * the list itself.
115 - * 117 + * <p>
116 * List of key leaf names. 118 * List of key leaf names.
117 */ 119 */
118 private List<String> keyList; 120 private List<String> keyList;
119 121
120 /** 122 /**
121 * Reference RFC 6020. 123 * Reference RFC 6020.
122 - * 124 + * <p>
123 * The "unique" statement is used to put constraints on valid list 125 * The "unique" statement is used to put constraints on valid list
124 * entries. It takes as an argument a string that contains a space- 126 * entries. It takes as an argument a string that contains a space-
125 * separated list of schema node identifiers, which MUST be given in the 127 * separated list of schema node identifiers, which MUST be given in the
126 * descendant form. Each such schema node identifier MUST refer to a leaf. 128 * descendant form. Each such schema node identifier MUST refer to a leaf.
127 - * 129 + * <p>
128 * If one of the referenced leafs represents configuration data, then 130 * If one of the referenced leafs represents configuration data, then
129 * all of the referenced leafs MUST represent configuration data. 131 * all of the referenced leafs MUST represent configuration data.
130 - * 132 + * <p>
131 * The "unique" constraint specifies that the combined values of all the 133 * The "unique" constraint specifies that the combined values of all the
132 * leaf instances specified in the argument string, including leafs with 134 * leaf instances specified in the argument string, including leafs with
133 * default values, MUST be unique within all list entry instances in 135 * default values, MUST be unique within all list entry instances in
134 * which all referenced leafs exist. 136 * which all referenced leafs exist.
135 - * 137 + * <p>
136 * List of unique leaf/leaf-list names 138 * List of unique leaf/leaf-list names
137 */ 139 */
138 private List<String> uniqueList; 140 private List<String> uniqueList;
...@@ -151,32 +153,32 @@ public class YangList ...@@ -151,32 +153,32 @@ public class YangList
151 153
152 /** 154 /**
153 * Reference RFC 6020. 155 * Reference RFC 6020.
154 - * 156 + * <p>
155 * The "max-elements" statement, which is optional, takes as an argument a 157 * The "max-elements" statement, which is optional, takes as an argument a
156 * positive integer or the string "unbounded", which puts a constraint on 158 * positive integer or the string "unbounded", which puts a constraint on
157 * valid list entries. A valid leaf-list or list always has at most 159 * valid list entries. A valid leaf-list or list always has at most
158 * max-elements entries. 160 * max-elements entries.
159 - * 161 + * <p>
160 * If no "max-elements" statement is present, it defaults to "unbounded". 162 * If no "max-elements" statement is present, it defaults to "unbounded".
161 */ 163 */
162 private YangMaxElement maxElements; 164 private YangMaxElement maxElements;
163 165
164 /** 166 /**
165 * Reference RFC 6020. 167 * Reference RFC 6020.
166 - * 168 + * <p>
167 * The "min-elements" statement, which is optional, takes as an argument a 169 * The "min-elements" statement, which is optional, takes as an argument a
168 * non-negative integer that puts a constraint on valid list entries. A 170 * non-negative integer that puts a constraint on valid list entries. A
169 * valid leaf-list or list MUST have at least min-elements entries. 171 * valid leaf-list or list MUST have at least min-elements entries.
170 - * 172 + * <p>
171 * If no "min-elements" statement is present, it defaults to zero. 173 * If no "min-elements" statement is present, it defaults to zero.
172 - * 174 + * <p>
173 * The behavior of the constraint depends on the type of the leaf-list's or 175 * The behavior of the constraint depends on the type of the leaf-list's or
174 * list's closest ancestor node in the schema tree that is not a non- 176 * list's closest ancestor node in the schema tree that is not a non-
175 * presence container: 177 * presence container:
176 - * 178 + * <p>
177 * o If this ancestor is a case node, the constraint is enforced if any 179 * o If this ancestor is a case node, the constraint is enforced if any
178 * other node from the case exists. 180 * other node from the case exists.
179 - * 181 + * <p>
180 * o Otherwise, it is enforced if the ancestor node exists. 182 * o Otherwise, it is enforced if the ancestor node exists.
181 */ 183 */
182 private YangMinElement minElements; 184 private YangMinElement minElements;
...@@ -211,6 +213,8 @@ public class YangList ...@@ -211,6 +213,8 @@ public class YangList
211 */ 213 */
212 public YangList() { 214 public YangList() {
213 super(YangNodeType.LIST_NODE); 215 super(YangNodeType.LIST_NODE);
216 + listOfLeaf = new LinkedList<>();
217 + listOfLeafList = new LinkedList<>();
214 } 218 }
215 219
216 /** 220 /**
...@@ -624,8 +628,8 @@ public class YangList ...@@ -624,8 +628,8 @@ public class YangList
624 /** 628 /**
625 * Validates key statement of list. 629 * Validates key statement of list.
626 * 630 *
627 - * @param leaves list of leaf attributes of list 631 + * @param leaves list of leaf attributes of list
628 - * @param keys list of key attributes of list 632 + * @param keys list of key attributes of list
629 * @throws DataModelException a violation of data model rules 633 * @throws DataModelException a violation of data model rules
630 */ 634 */
631 private void validateKey(List<YangLeaf> leaves, List<String> keys) 635 private void validateKey(List<YangLeaf> leaves, List<String> keys)
......
...@@ -74,7 +74,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi ...@@ -74,7 +74,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi
74 public class YangModule 74 public class YangModule
75 extends YangNode 75 extends YangNode
76 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, 76 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
77 - RpcNotificationContainer, YangFeatureHolder { 77 + RpcNotificationContainer, YangFeatureHolder, YangIsFilterContentNodes {
78 78
79 private static final long serialVersionUID = 806201610L; 79 private static final long serialVersionUID = 806201610L;
80 80
...@@ -85,7 +85,7 @@ public class YangModule ...@@ -85,7 +85,7 @@ public class YangModule
85 85
86 /** 86 /**
87 * Reference:RFC 6020. 87 * Reference:RFC 6020.
88 - * 88 + * <p>
89 * The "contact" statement provides contact information for the module. The 89 * The "contact" statement provides contact information for the module. The
90 * argument is a string that is used to specify contact information for the 90 * argument is a string that is used to specify contact information for the
91 * person or persons to whom technical queries concerning this module should 91 * person or persons to whom technical queries concerning this module should
...@@ -96,7 +96,7 @@ public class YangModule ...@@ -96,7 +96,7 @@ public class YangModule
96 96
97 /** 97 /**
98 * Reference:RFC 6020. 98 * Reference:RFC 6020.
99 - * 99 + * <p>
100 * The "description" statement takes as an argument a string that contains a 100 * The "description" statement takes as an argument a string that contains a
101 * human-readable textual description of this definition. The text is 101 * human-readable textual description of this definition. The text is
102 * provided in a language (or languages) chosen by the module developer; for 102 * provided in a language (or languages) chosen by the module developer; for
...@@ -136,7 +136,7 @@ public class YangModule ...@@ -136,7 +136,7 @@ public class YangModule
136 136
137 /** 137 /**
138 * Reference:RFC 6020. 138 * Reference:RFC 6020.
139 - * 139 + * <p>
140 * The "organization" statement defines the party responsible for this 140 * The "organization" statement defines the party responsible for this
141 * module. The argument is a string that is used to specify a textual 141 * module. The argument is a string that is used to specify a textual
142 * description of the organization(s) under whose auspices this module was 142 * description of the organization(s) under whose auspices this module was
...@@ -211,9 +211,9 @@ public class YangModule ...@@ -211,9 +211,9 @@ public class YangModule
211 private List<YangResolutionInfo> ifFeatureResolutionList; 211 private List<YangResolutionInfo> ifFeatureResolutionList;
212 212
213 /** 213 /**
214 - * Leafref resolution list. 214 + * LeafRef resolution list.
215 */ 215 */
216 - private List<YangResolutionInfo> leafrefResolutionList; 216 + private List<YangResolutionInfo> leafRefResolutionList;
217 217
218 /** 218 /**
219 * Base resolution list. 219 * Base resolution list.
...@@ -221,9 +221,9 @@ public class YangModule ...@@ -221,9 +221,9 @@ public class YangModule
221 private List<YangResolutionInfo> baseResolutionList; 221 private List<YangResolutionInfo> baseResolutionList;
222 222
223 /** 223 /**
224 - * Identityref resolution list. 224 + * IdentityRef resolution list.
225 */ 225 */
226 - private List<YangResolutionInfo> identityrefResolutionList; 226 + private List<YangResolutionInfo> identityRefResolutionList;
227 227
228 /** 228 /**
229 * Augment resolution list. 229 * Augment resolution list.
...@@ -250,15 +250,15 @@ public class YangModule ...@@ -250,15 +250,15 @@ public class YangModule
250 augmentResolutionList = new LinkedList<>(); 250 augmentResolutionList = new LinkedList<>();
251 usesResolutionList = new LinkedList<>(); 251 usesResolutionList = new LinkedList<>();
252 ifFeatureResolutionList = new LinkedList<>(); 252 ifFeatureResolutionList = new LinkedList<>();
253 - leafrefResolutionList = new LinkedList<>(); 253 + leafRefResolutionList = new LinkedList<>();
254 baseResolutionList = new LinkedList<>(); 254 baseResolutionList = new LinkedList<>();
255 - identityrefResolutionList = new LinkedList<>(); 255 + identityRefResolutionList = new LinkedList<>();
256 compilerAnnotationList = new LinkedList<>(); 256 compilerAnnotationList = new LinkedList<>();
257 - importList = new LinkedList<YangImport>(); 257 + importList = new LinkedList<>();
258 - includeList = new LinkedList<YangInclude>(); 258 + includeList = new LinkedList<>();
259 - listOfLeaf = new LinkedList<YangLeaf>(); 259 + listOfLeaf = new LinkedList<>();
260 - listOfLeafList = new LinkedList<YangLeafList>(); 260 + listOfLeafList = new LinkedList<>();
261 - extensionList = new LinkedList<YangExtension>(); 261 + extensionList = new LinkedList<>();
262 } 262 }
263 263
264 /** 264 /**
...@@ -684,11 +684,11 @@ public class YangModule ...@@ -684,11 +684,11 @@ public class YangModule
684 } else if (type == ResolvableType.YANG_IF_FEATURE) { 684 } else if (type == ResolvableType.YANG_IF_FEATURE) {
685 return ifFeatureResolutionList; 685 return ifFeatureResolutionList;
686 } else if (type == ResolvableType.YANG_LEAFREF) { 686 } else if (type == ResolvableType.YANG_LEAFREF) {
687 - return leafrefResolutionList; 687 + return leafRefResolutionList;
688 } else if (type == ResolvableType.YANG_BASE) { 688 } else if (type == ResolvableType.YANG_BASE) {
689 return baseResolutionList; 689 return baseResolutionList;
690 } else { 690 } else {
691 - return identityrefResolutionList; 691 + return identityRefResolutionList;
692 } 692 }
693 } 693 }
694 694
...@@ -702,13 +702,13 @@ public class YangModule ...@@ -702,13 +702,13 @@ public class YangModule
702 } else if (type == ResolvableType.YANG_IF_FEATURE) { 702 } else if (type == ResolvableType.YANG_IF_FEATURE) {
703 ifFeatureResolutionList.add(resolutionInfo); 703 ifFeatureResolutionList.add(resolutionInfo);
704 } else if (type == ResolvableType.YANG_LEAFREF) { 704 } else if (type == ResolvableType.YANG_LEAFREF) {
705 - leafrefResolutionList.add(resolutionInfo); 705 + leafRefResolutionList.add(resolutionInfo);
706 } else if (type == ResolvableType.YANG_BASE) { 706 } else if (type == ResolvableType.YANG_BASE) {
707 baseResolutionList.add(resolutionInfo); 707 baseResolutionList.add(resolutionInfo);
708 } else if (type == ResolvableType.YANG_AUGMENT) { 708 } else if (type == ResolvableType.YANG_AUGMENT) {
709 augmentResolutionList.add(resolutionInfo); 709 augmentResolutionList.add(resolutionInfo);
710 } else if (type == ResolvableType.YANG_IDENTITYREF) { 710 } else if (type == ResolvableType.YANG_IDENTITYREF) {
711 - identityrefResolutionList.add(resolutionInfo); 711 + identityRefResolutionList.add(resolutionInfo);
712 } 712 }
713 } 713 }
714 714
...@@ -722,13 +722,13 @@ public class YangModule ...@@ -722,13 +722,13 @@ public class YangModule
722 } else if (type == ResolvableType.YANG_IF_FEATURE) { 722 } else if (type == ResolvableType.YANG_IF_FEATURE) {
723 ifFeatureResolutionList.add((YangResolutionInfo) resolutionList); 723 ifFeatureResolutionList.add((YangResolutionInfo) resolutionList);
724 } else if (type == ResolvableType.YANG_LEAFREF) { 724 } else if (type == ResolvableType.YANG_LEAFREF) {
725 - leafrefResolutionList = resolutionList; 725 + leafRefResolutionList = resolutionList;
726 } else if (type == ResolvableType.YANG_BASE) { 726 } else if (type == ResolvableType.YANG_BASE) {
727 baseResolutionList = resolutionList; 727 baseResolutionList = resolutionList;
728 } else if (type == ResolvableType.YANG_AUGMENT) { 728 } else if (type == ResolvableType.YANG_AUGMENT) {
729 augmentResolutionList = resolutionList; 729 augmentResolutionList = resolutionList;
730 } else if (type == ResolvableType.YANG_IDENTITYREF) { 730 } else if (type == ResolvableType.YANG_IDENTITYREF) {
731 - identityrefResolutionList = resolutionList; 731 + identityRefResolutionList = resolutionList;
732 } 732 }
733 733
734 } 734 }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 package org.onosproject.yangutils.datamodel; 16 package org.onosproject.yangutils.datamodel;
17 17
18 import java.io.Serializable; 18 import java.io.Serializable;
19 +
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 20 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.datamodel.utils.Parsable; 21 import org.onosproject.yangutils.datamodel.utils.Parsable;
21 22
...@@ -185,7 +186,7 @@ public abstract class YangNode ...@@ -185,7 +186,7 @@ public abstract class YangNode
185 * 186 *
186 * @param sibling YANG node 187 * @param sibling YANG node
187 */ 188 */
188 - private void setNextSibling(YangNode sibling) { 189 + public void setNextSibling(YangNode sibling) {
189 nextSibling = sibling; 190 nextSibling = sibling;
190 } 191 }
191 192
...@@ -203,7 +204,7 @@ public abstract class YangNode ...@@ -203,7 +204,7 @@ public abstract class YangNode
203 * 204 *
204 * @param previousSibling points to predecessor sibling 205 * @param previousSibling points to predecessor sibling
205 */ 206 */
206 - private void setPreviousSibling(YangNode previousSibling) { 207 + public void setPreviousSibling(YangNode previousSibling) {
207 this.previousSibling = previousSibling; 208 this.previousSibling = previousSibling;
208 } 209 }
209 210
......
...@@ -124,8 +124,8 @@ public class YangNotification ...@@ -124,8 +124,8 @@ public class YangNotification
124 */ 124 */
125 public YangNotification() { 125 public YangNotification() {
126 super(YangNodeType.NOTIFICATION_NODE); 126 super(YangNodeType.NOTIFICATION_NODE);
127 - listOfLeaf = new LinkedList<YangLeaf>(); 127 + listOfLeaf = new LinkedList<>();
128 - listOfLeafList = new LinkedList<YangLeafList>(); 128 + listOfLeafList = new LinkedList<>();
129 } 129 }
130 130
131 @Override 131 @Override
......
...@@ -70,7 +70,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -70,7 +70,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
70 */ 70 */
71 public class YangOutput 71 public class YangOutput
72 extends YangNode 72 extends YangNode
73 - implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode { 73 + implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode, YangIsFilterContentNodes {
74 74
75 private static final long serialVersionUID = 806201612L; 75 private static final long serialVersionUID = 806201612L;
76 76
...@@ -96,8 +96,8 @@ public class YangOutput ...@@ -96,8 +96,8 @@ public class YangOutput
96 */ 96 */
97 public YangOutput() { 97 public YangOutput() {
98 super(YangNodeType.OUTPUT_NODE); 98 super(YangNodeType.OUTPUT_NODE);
99 - listOfLeaf = new LinkedList<YangLeaf>(); 99 + listOfLeaf = new LinkedList<>();
100 - listOfLeafList = new LinkedList<YangLeafList>(); 100 + listOfLeafList = new LinkedList<>();
101 } 101 }
102 102
103 @Override 103 @Override
......
...@@ -82,7 +82,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi ...@@ -82,7 +82,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi
82 public class YangSubModule 82 public class YangSubModule
83 extends YangNode 83 extends YangNode
84 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, 84 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
85 - RpcNotificationContainer, YangFeatureHolder { 85 + RpcNotificationContainer, YangFeatureHolder, YangIsFilterContentNodes {
86 86
87 private static final long serialVersionUID = 806201614L; 87 private static final long serialVersionUID = 806201614L;
88 88
...@@ -209,9 +209,9 @@ public class YangSubModule ...@@ -209,9 +209,9 @@ public class YangSubModule
209 private List<YangResolutionInfo> ifFeatureResolutionList; 209 private List<YangResolutionInfo> ifFeatureResolutionList;
210 210
211 /** 211 /**
212 - * Leafref resolution list. 212 + * LeafRef resolution list.
213 */ 213 */
214 - private List<YangResolutionInfo> leafrefResolutionList; 214 + private List<YangResolutionInfo> leafRefResolutionList;
215 215
216 /** 216 /**
217 * Base resolution list. 217 * Base resolution list.
...@@ -219,9 +219,9 @@ public class YangSubModule ...@@ -219,9 +219,9 @@ public class YangSubModule
219 private List<YangResolutionInfo> baseResolutionList; 219 private List<YangResolutionInfo> baseResolutionList;
220 220
221 /** 221 /**
222 - * Identityref resolution list. 222 + * IdentityRef resolution list.
223 */ 223 */
224 - private List<YangResolutionInfo> identityrefResolutionList; 224 + private List<YangResolutionInfo> identityRefResolutionList;
225 225
226 /** 226 /**
227 * Compiler annotation list. 227 * Compiler annotation list.
...@@ -247,15 +247,15 @@ public class YangSubModule ...@@ -247,15 +247,15 @@ public class YangSubModule
247 augmentResolutionList = new LinkedList<>(); 247 augmentResolutionList = new LinkedList<>();
248 usesResolutionList = new LinkedList<>(); 248 usesResolutionList = new LinkedList<>();
249 ifFeatureResolutionList = new LinkedList<>(); 249 ifFeatureResolutionList = new LinkedList<>();
250 - leafrefResolutionList = new LinkedList<>(); 250 + leafRefResolutionList = new LinkedList<>();
251 baseResolutionList = new LinkedList<>(); 251 baseResolutionList = new LinkedList<>();
252 - identityrefResolutionList = new LinkedList<>(); 252 + identityRefResolutionList = new LinkedList<>();
253 compilerAnnotationList = new LinkedList<>(); 253 compilerAnnotationList = new LinkedList<>();
254 - importList = new LinkedList<YangImport>(); 254 + importList = new LinkedList<>();
255 - includeList = new LinkedList<YangInclude>(); 255 + includeList = new LinkedList<>();
256 - listOfLeaf = new LinkedList<YangLeaf>(); 256 + listOfLeaf = new LinkedList<>();
257 - listOfLeafList = new LinkedList<YangLeafList>(); 257 + listOfLeafList = new LinkedList<>();
258 - extensionList = new LinkedList<YangExtension>(); 258 + extensionList = new LinkedList<>();
259 } 259 }
260 260
261 /** 261 /**
...@@ -592,11 +592,11 @@ public class YangSubModule ...@@ -592,11 +592,11 @@ public class YangSubModule
592 } else if (type == ResolvableType.YANG_IF_FEATURE) { 592 } else if (type == ResolvableType.YANG_IF_FEATURE) {
593 return ifFeatureResolutionList; 593 return ifFeatureResolutionList;
594 } else if (type == ResolvableType.YANG_LEAFREF) { 594 } else if (type == ResolvableType.YANG_LEAFREF) {
595 - return leafrefResolutionList; 595 + return leafRefResolutionList;
596 } else if (type == ResolvableType.YANG_BASE) { 596 } else if (type == ResolvableType.YANG_BASE) {
597 return baseResolutionList; 597 return baseResolutionList;
598 } else { 598 } else {
599 - return identityrefResolutionList; 599 + return identityRefResolutionList;
600 } 600 }
601 } 601 }
602 602
...@@ -610,13 +610,13 @@ public class YangSubModule ...@@ -610,13 +610,13 @@ public class YangSubModule
610 } else if (type == ResolvableType.YANG_IF_FEATURE) { 610 } else if (type == ResolvableType.YANG_IF_FEATURE) {
611 ifFeatureResolutionList.add(resolutionInfo); 611 ifFeatureResolutionList.add(resolutionInfo);
612 } else if (type == ResolvableType.YANG_LEAFREF) { 612 } else if (type == ResolvableType.YANG_LEAFREF) {
613 - leafrefResolutionList.add(resolutionInfo); 613 + leafRefResolutionList.add(resolutionInfo);
614 } else if (type == ResolvableType.YANG_BASE) { 614 } else if (type == ResolvableType.YANG_BASE) {
615 baseResolutionList.add(resolutionInfo); 615 baseResolutionList.add(resolutionInfo);
616 } else if (type == ResolvableType.YANG_AUGMENT) { 616 } else if (type == ResolvableType.YANG_AUGMENT) {
617 augmentResolutionList.add(resolutionInfo); 617 augmentResolutionList.add(resolutionInfo);
618 } else if (type == ResolvableType.YANG_IDENTITYREF) { 618 } else if (type == ResolvableType.YANG_IDENTITYREF) {
619 - identityrefResolutionList.add(resolutionInfo); 619 + identityRefResolutionList.add(resolutionInfo);
620 } 620 }
621 } 621 }
622 622
...@@ -630,13 +630,13 @@ public class YangSubModule ...@@ -630,13 +630,13 @@ public class YangSubModule
630 } else if (type == ResolvableType.YANG_IF_FEATURE) { 630 } else if (type == ResolvableType.YANG_IF_FEATURE) {
631 ifFeatureResolutionList.add((YangResolutionInfo) resolutionList); 631 ifFeatureResolutionList.add((YangResolutionInfo) resolutionList);
632 } else if (type == ResolvableType.YANG_LEAFREF) { 632 } else if (type == ResolvableType.YANG_LEAFREF) {
633 - leafrefResolutionList = resolutionList; 633 + leafRefResolutionList = resolutionList;
634 } else if (type == ResolvableType.YANG_BASE) { 634 } else if (type == ResolvableType.YANG_BASE) {
635 baseResolutionList = resolutionList; 635 baseResolutionList = resolutionList;
636 } else if (type == ResolvableType.YANG_AUGMENT) { 636 } else if (type == ResolvableType.YANG_AUGMENT) {
637 augmentResolutionList = resolutionList; 637 augmentResolutionList = resolutionList;
638 } else if (type == ResolvableType.YANG_IDENTITYREF) { 638 } else if (type == ResolvableType.YANG_IDENTITYREF) {
639 - identityrefResolutionList = resolutionList; 639 + identityRefResolutionList = resolutionList;
640 } 640 }
641 641
642 } 642 }
......
...@@ -276,7 +276,7 @@ public class YangType<T> ...@@ -276,7 +276,7 @@ public class YangType<T>
276 * @param value input data value 276 * @param value input data value
277 * @throws DataModelException a violation of data model rules 277 * @throws DataModelException a violation of data model rules
278 */ 278 */
279 - public void isValidValue(String value) throws DataModelException { 279 + void isValidValue(String value) throws DataModelException {
280 switch (getDataType()) { 280 switch (getDataType()) {
281 case INT8: 281 case INT8:
282 case INT16: 282 case INT16:
...@@ -291,7 +291,7 @@ public class YangType<T> ...@@ -291,7 +291,7 @@ public class YangType<T>
291 } else { 291 } else {
292 if (!((YangRangeRestriction) getDataTypeExtendedInfo()).isValidValueString(value)) { 292 if (!((YangRangeRestriction) getDataTypeExtendedInfo()).isValidValueString(value)) {
293 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 293 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
294 - getDataType()); 294 + getDataType());
295 } 295 }
296 } 296 }
297 break; 297 break;
...@@ -301,7 +301,7 @@ public class YangType<T> ...@@ -301,7 +301,7 @@ public class YangType<T>
301 YangDecimal64<YangRangeRestriction> decimal64 = 301 YangDecimal64<YangRangeRestriction> decimal64 =
302 (YangDecimal64<YangRangeRestriction>) getDataTypeExtendedInfo(); 302 (YangDecimal64<YangRangeRestriction>) getDataTypeExtendedInfo();
303 validateDecimal64(value, decimal64.getFractionDigit(), 303 validateDecimal64(value, decimal64.getFractionDigit(),
304 - decimal64.getRangeRestrictedExtendedInfo()); 304 + decimal64.getRangeRestrictedExtendedInfo());
305 break; 305 break;
306 } 306 }
307 case STRING: { 307 case STRING: {
...@@ -311,14 +311,14 @@ public class YangType<T> ...@@ -311,14 +311,14 @@ public class YangType<T>
311 && ((YangStringRestriction) getDataTypeExtendedInfo()) 311 && ((YangStringRestriction) getDataTypeExtendedInfo())
312 .isValidStringOnPatternRestriction(value))) { 312 .isValidStringOnPatternRestriction(value))) {
313 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 313 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
314 - getDataType()); 314 + getDataType());
315 } 315 }
316 break; 316 break;
317 } 317 }
318 case BOOLEAN: 318 case BOOLEAN:
319 if (!(value.equals(DataModelUtils.TRUE) || value.equals(DataModelUtils.FALSE))) { 319 if (!(value.equals(DataModelUtils.TRUE) || value.equals(DataModelUtils.FALSE))) {
320 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 320 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
321 - getDataType()); 321 + getDataType());
322 } 322 }
323 break; 323 break;
324 case ENUMERATION: { 324 case ENUMERATION: {
...@@ -334,7 +334,7 @@ public class YangType<T> ...@@ -334,7 +334,7 @@ public class YangType<T>
334 334
335 if (!isValidated) { 335 if (!isValidated) {
336 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 336 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
337 - getDataType()); 337 + getDataType());
338 } 338 }
339 break; 339 break;
340 } 340 }
...@@ -342,14 +342,14 @@ public class YangType<T> ...@@ -342,14 +342,14 @@ public class YangType<T>
342 YangBits bits = (YangBits) getDataTypeExtendedInfo(); 342 YangBits bits = (YangBits) getDataTypeExtendedInfo();
343 if (bits.fromString(value) == null) { 343 if (bits.fromString(value) == null) {
344 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 344 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
345 - getDataType()); 345 + getDataType());
346 } 346 }
347 break; 347 break;
348 } 348 }
349 case BINARY: { 349 case BINARY: {
350 if (!isValidBinary(value, (YangRangeRestriction) getDataTypeExtendedInfo())) { 350 if (!isValidBinary(value, (YangRangeRestriction) getDataTypeExtendedInfo())) {
351 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 351 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
352 - getDataType()); 352 + getDataType());
353 } 353 }
354 break; 354 break;
355 } 355 }
...@@ -365,13 +365,13 @@ public class YangType<T> ...@@ -365,13 +365,13 @@ public class YangType<T>
365 case EMPTY: { 365 case EMPTY: {
366 if (value.length() > 0) { 366 if (value.length() > 0) {
367 throw new DataTypeException("YANG file error : Input value \"" + value 367 throw new DataTypeException("YANG file error : Input value \"" + value
368 - + "\" is not allowed for a data type " + getDataType()); 368 + + "\" is not allowed for a data type " + getDataType());
369 } 369 }
370 break; 370 break;
371 } 371 }
372 case UNION: { 372 case UNION: {
373 ListIterator<YangType<?>> listIterator = ((YangUnion) getDataTypeExtendedInfo()).getTypeList() 373 ListIterator<YangType<?>> listIterator = ((YangUnion) getDataTypeExtendedInfo()).getTypeList()
374 - .listIterator(); 374 + .listIterator();
375 boolean isValidated = false; 375 boolean isValidated = false;
376 while (listIterator.hasNext()) { 376 while (listIterator.hasNext()) {
377 YangType<?> type = (YangType<?>) listIterator.next(); 377 YangType<?> type = (YangType<?>) listIterator.next();
...@@ -386,7 +386,7 @@ public class YangType<T> ...@@ -386,7 +386,7 @@ public class YangType<T>
386 386
387 if (!isValidated) { 387 if (!isValidated) {
388 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 388 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
389 - getDataType()); 389 + getDataType());
390 } 390 }
391 break; 391 break;
392 } 392 }
...@@ -399,13 +399,13 @@ public class YangType<T> ...@@ -399,13 +399,13 @@ public class YangType<T>
399 if (isOfRangeRestrictedType(dataType)) { 399 if (isOfRangeRestrictedType(dataType)) {
400 if (((YangDerivedInfo) getDataTypeExtendedInfo()).getResolvedExtendedInfo() == null) { 400 if (((YangDerivedInfo) getDataTypeExtendedInfo()).getResolvedExtendedInfo() == null) {
401 getDataObjectFromString(value, 401 getDataObjectFromString(value,
402 - ((YangDerivedInfo) getDataTypeExtendedInfo()) 402 + ((YangDerivedInfo) getDataTypeExtendedInfo())
403 - .getEffectiveBuiltInType()); 403 + .getEffectiveBuiltInType());
404 } else { 404 } else {
405 if (!((YangRangeRestriction) ((YangDerivedInfo) getDataTypeExtendedInfo()) 405 if (!((YangRangeRestriction) ((YangDerivedInfo) getDataTypeExtendedInfo())
406 .getResolvedExtendedInfo()).isValidValueString(value)) { 406 .getResolvedExtendedInfo()).isValidValueString(value)) {
407 throw new DataTypeException("YANG file error : Input value \"" + value 407 throw new DataTypeException("YANG file error : Input value \"" + value
408 - + "\" is not a valid " + dataType); 408 + + "\" is not a valid " + dataType);
409 } 409 }
410 } 410 }
411 } else if (dataType == YangDataTypes.STRING) { 411 } else if (dataType == YangDataTypes.STRING) {
...@@ -416,20 +416,20 @@ public class YangType<T> ...@@ -416,20 +416,20 @@ public class YangType<T>
416 if (!(stringRestriction.isValidStringOnLengthRestriction(value) && 416 if (!(stringRestriction.isValidStringOnLengthRestriction(value) &&
417 stringRestriction.isValidStringOnPatternRestriction(value))) { 417 stringRestriction.isValidStringOnPatternRestriction(value))) {
418 throw new DataTypeException("YANG file error : Input value \"" + value 418 throw new DataTypeException("YANG file error : Input value \"" + value
419 - + "\" is not a valid " + dataType); 419 + + "\" is not a valid " + dataType);
420 } 420 }
421 } 421 }
422 } else if (dataType == YangDataTypes.BITS) { 422 } else if (dataType == YangDataTypes.BITS) {
423 YangBits bits = (YangBits) getDataTypeExtendedInfo(); 423 YangBits bits = (YangBits) getDataTypeExtendedInfo();
424 if (bits.fromString(value) == null) { 424 if (bits.fromString(value) == null) {
425 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 425 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
426 - dataType); 426 + dataType);
427 } 427 }
428 } else if (dataType == YangDataTypes.BINARY) { 428 } else if (dataType == YangDataTypes.BINARY) {
429 if (!isValidBinary(value, (YangRangeRestriction) ((YangDerivedInfo) 429 if (!isValidBinary(value, (YangRangeRestriction) ((YangDerivedInfo)
430 getDataTypeExtendedInfo()).getResolvedExtendedInfo())) { 430 getDataTypeExtendedInfo()).getResolvedExtendedInfo())) {
431 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " + 431 throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
432 - dataType); 432 + dataType);
433 } 433 }
434 } else if (dataType == YangDataTypes.DECIMAL64) { 434 } else if (dataType == YangDataTypes.DECIMAL64) {
435 YangDerivedInfo derivedInfo = (YangDerivedInfo) getDataTypeExtendedInfo(); 435 YangDerivedInfo derivedInfo = (YangDerivedInfo) getDataTypeExtendedInfo();
...@@ -439,13 +439,13 @@ public class YangType<T> ...@@ -439,13 +439,13 @@ public class YangType<T>
439 YangDecimal64<YangRangeRestriction> decimal64 = decimal64Type.getDataTypeExtendedInfo(); 439 YangDecimal64<YangRangeRestriction> decimal64 = decimal64Type.getDataTypeExtendedInfo();
440 // Fraction-Digits and range needs to get it from yang 440 // Fraction-Digits and range needs to get it from yang
441 validateDecimal64(value, decimal64.getFractionDigit(), 441 validateDecimal64(value, decimal64.getFractionDigit(),
442 - decimal64.getRangeRestrictedExtendedInfo()); 442 + decimal64.getRangeRestrictedExtendedInfo());
443 } 443 }
444 break; 444 break;
445 } 445 }
446 default: { 446 default: {
447 throw new DataTypeException("YANG file error : Input value \"" + value + "\" received for " + 447 throw new DataTypeException("YANG file error : Input value \"" + value + "\" received for " +
448 - "unsupported data type " + getDataType()); 448 + "unsupported data type " + getDataType());
449 } 449 }
450 } 450 }
451 } 451 }
...@@ -456,7 +456,7 @@ public class YangType<T> ...@@ -456,7 +456,7 @@ public class YangType<T>
456 * 456 *
457 * @param value decimal64 value 457 * @param value decimal64 value
458 */ 458 */
459 - private void validateDecimal64(String value, int fractionDigit, YangRangeRestriction rangeRestriction) 459 + private void validateDecimal64(String value, int fractionDigit, YangRangeRestriction rangeRestriction)
460 throws DataModelException { 460 throws DataModelException {
461 YangDecimal64<YangRangeRestriction> decimal64 = YangDecimal64.fromString(value); 461 YangDecimal64<YangRangeRestriction> decimal64 = YangDecimal64.fromString(value);
462 decimal64.setFractionDigit(fractionDigit); 462 decimal64.setFractionDigit(fractionDigit);
......
...@@ -17,6 +17,7 @@ package org.onosproject.yangutils.datamodel; ...@@ -17,6 +17,7 @@ package org.onosproject.yangutils.datamodel;
17 17
18 import java.util.LinkedList; 18 import java.util.LinkedList;
19 import java.util.List; 19 import java.util.List;
20 +
20 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
21 import org.onosproject.yangutils.datamodel.utils.Parsable; 22 import org.onosproject.yangutils.datamodel.utils.Parsable;
22 import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; 23 import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
...@@ -68,7 +69,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.updateClo ...@@ -68,7 +69,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.updateClo
68 public class YangUses 69 public class YangUses
69 extends YangNode 70 extends YangNode
70 implements YangCommonInfo, Parsable, Resolvable, CollisionDetector, YangWhenHolder, 71 implements YangCommonInfo, Parsable, Resolvable, CollisionDetector, YangWhenHolder,
71 - YangIfFeatureHolder { 72 + YangIfFeatureHolder, YangTranslatorOperatorNode {
72 73
73 private static final long serialVersionUID = 806201617L; 74 private static final long serialVersionUID = 806201617L;
74 75
......
...@@ -27,14 +27,14 @@ public final class YangPluginConfig { ...@@ -27,14 +27,14 @@ public final class YangPluginConfig {
27 private String codeGenDir; 27 private String codeGenDir;
28 28
29 /** 29 /**
30 - * Contains the code generation directory. 30 + * Contains information of naming conflicts that can be resolved.
31 */ 31 */
32 - private String managerCodeGenDir; 32 + private YangToJavaNamingConflictUtil conflictResolver;
33 33
34 /** 34 /**
35 - * Contains information of naming conflicts that can be resolved. 35 + * Java code generation is for sbi.
36 */ 36 */
37 - private YangToJavaNamingConflictUtil conflictResolver; 37 + private String codeGenerateForsbi;
38 38
39 /** 39 /**
40 * Creates an object for YANG plugin config. 40 * Creates an object for YANG plugin config.
...@@ -43,11 +43,6 @@ public final class YangPluginConfig { ...@@ -43,11 +43,6 @@ public final class YangPluginConfig {
43 } 43 }
44 44
45 /** 45 /**
46 - * Java code generation is for sbi.
47 - */
48 - private String codeGenerateForsbi;
49 -
50 - /**
51 * Returns the string for code generation. 46 * Returns the string for code generation.
52 * 47 *
53 * @return returns the string for code generation. 48 * @return returns the string for code generation.
...@@ -101,21 +96,4 @@ public final class YangPluginConfig { ...@@ -101,21 +96,4 @@ public final class YangPluginConfig {
101 return conflictResolver; 96 return conflictResolver;
102 } 97 }
103 98
104 - /**
105 - * Returns manager's code generation directory.
106 - *
107 - * @return manager's code generation directory
108 - */
109 - public String getManagerCodeGenDir() {
110 - return managerCodeGenDir;
111 - }
112 -
113 - /**
114 - * Sets manager's code generation directory.
115 - *
116 - * @param moduleCodeGenDir manager's code generation directory
117 - */
118 - public void setManagerCodeGenDir(String moduleCodeGenDir) {
119 - this.managerCodeGenDir = moduleCodeGenDir;
120 - }
121 } 99 }
......
...@@ -16,6 +16,22 @@ ...@@ -16,6 +16,22 @@
16 16
17 package org.onosproject.yangutils.datamodel.utils; 17 package org.onosproject.yangutils.datamodel.utils;
18 18
19 +import java.io.File;
20 +import java.io.FileInputStream;
21 +import java.io.FileOutputStream;
22 +import java.io.IOException;
23 +import java.io.InputStream;
24 +import java.io.ObjectInputStream;
25 +import java.util.ArrayList;
26 +import java.util.Enumeration;
27 +import java.util.Iterator;
28 +import java.util.LinkedList;
29 +import java.util.List;
30 +import java.util.Map;
31 +import java.util.Set;
32 +import java.util.jar.JarEntry;
33 +import java.util.jar.JarFile;
34 +
19 import org.onosproject.yangutils.datamodel.CollisionDetector; 35 import org.onosproject.yangutils.datamodel.CollisionDetector;
20 import org.onosproject.yangutils.datamodel.ResolvableType; 36 import org.onosproject.yangutils.datamodel.ResolvableType;
21 import org.onosproject.yangutils.datamodel.YangAtomicPath; 37 import org.onosproject.yangutils.datamodel.YangAtomicPath;
...@@ -41,22 +57,13 @@ import org.onosproject.yangutils.datamodel.YangUses; ...@@ -41,22 +57,13 @@ import org.onosproject.yangutils.datamodel.YangUses;
41 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 57 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
42 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; 58 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
43 59
44 -import java.io.FileInputStream;
45 -import java.io.IOException;
46 -import java.io.ObjectInputStream;
47 -import java.util.ArrayList;
48 -import java.util.Iterator;
49 -import java.util.LinkedList;
50 -import java.util.List;
51 -import java.util.Map;
52 -import java.util.Set;
53 -
54 /** 60 /**
55 * Represents utilities for data model tree. 61 * Represents utilities for data model tree.
56 */ 62 */
57 public final class DataModelUtils { 63 public final class DataModelUtils {
58 public static final String TRUE = "true"; 64 public static final String TRUE = "true";
59 public static final String FALSE = "false"; 65 public static final String FALSE = "false";
66 + private static final String SLASH = File.separator;
60 67
61 /** 68 /**
62 * Creates a new data model tree utility. 69 * Creates a new data model tree utility.
...@@ -103,7 +110,7 @@ public final class DataModelUtils { ...@@ -103,7 +110,7 @@ public final class DataModelUtils {
103 * @param node node instance of calling node 110 * @param node node instance of calling node
104 * @throws DataModelException a violation of data model rules 111 * @throws DataModelException a violation of data model rules
105 */ 112 */
106 - public static void detectCollidingForUsesGrouping(String identifierName, YangConstructType dataType, YangNode node) 113 + private static void detectCollidingForUsesGrouping(String identifierName, YangConstructType dataType, YangNode node)
107 throws DataModelException { 114 throws DataModelException {
108 115
109 node = node.getChild(); 116 node = node.getChild();
...@@ -297,27 +304,24 @@ public final class DataModelUtils { ...@@ -297,27 +304,24 @@ public final class DataModelUtils {
297 /** 304 /**
298 * Returns de-serializes YANG data-model nodes. 305 * Returns de-serializes YANG data-model nodes.
299 * 306 *
300 - * @param serializableInfoSet YANG file info set 307 + * @param serializedFileInfo serialized File Info
301 * @return de-serializes YANG data-model nodes 308 * @return de-serializes YANG data-model nodes
302 * @throws IOException when fails do IO operations 309 * @throws IOException when fails do IO operations
303 */ 310 */
304 - public static List<YangNode> deSerializeDataModel(List<String> serializableInfoSet) throws IOException { 311 + public static YangNode deSerializeDataModel(String serializedFileInfo) throws IOException {
305 - 312 +
306 - List<YangNode> nodes = new ArrayList<>(); 313 + YangNode node;
307 - for (String fileInfo : serializableInfoSet) { 314 + try {
308 - YangNode node = null; 315 + FileInputStream fileInputStream = new FileInputStream(serializedFileInfo);
309 - try { 316 + ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
310 - FileInputStream fileInputStream = new FileInputStream(fileInfo); 317 + node = (YangNode) objectInputStream.readObject();
311 - ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); 318 + objectInputStream.close();
312 - node = (YangNode) objectInputStream.readObject(); 319 + fileInputStream.close();
313 - nodes.add(node); 320 + } catch (IOException | ClassNotFoundException e) {
314 - objectInputStream.close(); 321 + throw new IOException(serializedFileInfo + " not found.");
315 - fileInputStream.close();
316 - } catch (IOException | ClassNotFoundException e) {
317 - throw new IOException(fileInfo + " not found.");
318 - }
319 } 322 }
320 - return nodes; 323 +
324 + return node;
321 } 325 }
322 326
323 /** 327 /**
...@@ -332,7 +336,7 @@ public final class DataModelUtils { ...@@ -332,7 +336,7 @@ public final class DataModelUtils {
332 throws CloneNotSupportedException, DataModelException { 336 throws CloneNotSupportedException, DataModelException {
333 List<YangLeaf> currentListOfLeaves = leavesHolder.getListOfLeaf(); 337 List<YangLeaf> currentListOfLeaves = leavesHolder.getListOfLeaf();
334 if (currentListOfLeaves != null) { 338 if (currentListOfLeaves != null) {
335 - List<YangLeaf> clonedLeavesList = new LinkedList<YangLeaf>(); 339 + List<YangLeaf> clonedLeavesList = new LinkedList<>();
336 for (YangLeaf leaf : currentListOfLeaves) { 340 for (YangLeaf leaf : currentListOfLeaves) {
337 YangLeaf clonedLeaf = leaf.clone(); 341 YangLeaf clonedLeaf = leaf.clone();
338 if (yangUses.getCurrentGroupingDepth() == 0) { 342 if (yangUses.getCurrentGroupingDepth() == 0) {
...@@ -350,7 +354,7 @@ public final class DataModelUtils { ...@@ -350,7 +354,7 @@ public final class DataModelUtils {
350 354
351 List<YangLeafList> currentListOfLeafList = leavesHolder.getListOfLeafList(); 355 List<YangLeafList> currentListOfLeafList = leavesHolder.getListOfLeafList();
352 if (currentListOfLeafList != null) { 356 if (currentListOfLeafList != null) {
353 - List<YangLeafList> clonedListOfLeafList = new LinkedList<YangLeafList>(); 357 + List<YangLeafList> clonedListOfLeafList = new LinkedList<>();
354 for (YangLeafList leafList : currentListOfLeafList) { 358 for (YangLeafList leafList : currentListOfLeafList) {
355 YangLeafList clonedLeafList = leafList.clone(); 359 YangLeafList clonedLeafList = leafList.clone();
356 if (yangUses.getCurrentGroupingDepth() == 0) { 360 if (yangUses.getCurrentGroupingDepth() == 0) {
...@@ -410,11 +414,9 @@ public final class DataModelUtils { ...@@ -410,11 +414,9 @@ public final class DataModelUtils {
410 while (atomicPathIterator.hasNext()) { 414 while (atomicPathIterator.hasNext()) {
411 YangAtomicPath atomicPath = atomicPathIterator.next(); 415 YangAtomicPath atomicPath = atomicPathIterator.next();
412 Map<String, String> prefixesAndItsImportNameNode = leafrefForCloning.getPrefixAndItsImportedModule(); 416 Map<String, String> prefixesAndItsImportNameNode = leafrefForCloning.getPrefixAndItsImportedModule();
413 - if (!prefixesAndItsImportNameNode.isEmpty() || prefixesAndItsImportNameNode != null) { 417 + String prefixInPath = atomicPath.getNodeIdentifier().getPrefix();
414 - String prefixInPath = atomicPath.getNodeIdentifier().getPrefix(); 418 + String importedNodeName = prefixesAndItsImportNameNode.get(prefixInPath);
415 - String importedNodeName = prefixesAndItsImportNameNode.get(prefixInPath); 419 + assignCurrentLeafedWithNewPrefixes(importedNodeName, atomicPath, yangUses);
416 - assignCurrentLeafrefWithNewPrefixes(importedNodeName, atomicPath, yangUses);
417 - }
418 } 420 }
419 } 421 }
420 } 422 }
...@@ -427,8 +429,8 @@ public final class DataModelUtils { ...@@ -427,8 +429,8 @@ public final class DataModelUtils {
427 * @param node instance of YANG uses where cloning is done 429 * @param node instance of YANG uses where cloning is done
428 * @throws DataModelException data model error 430 * @throws DataModelException data model error
429 */ 431 */
430 - private static void assignCurrentLeafrefWithNewPrefixes(String importedNodeName, YangAtomicPath atomicPath, 432 + private static void assignCurrentLeafedWithNewPrefixes(String importedNodeName, YangAtomicPath atomicPath,
431 - YangNode node) throws DataModelException { 433 + YangNode node) throws DataModelException {
432 while (!(node instanceof YangReferenceResolver)) { 434 while (!(node instanceof YangReferenceResolver)) {
433 node = node.getParent(); 435 node = node.getParent();
434 if (node == null) { 436 if (node == null) {
...@@ -534,7 +536,7 @@ public final class DataModelUtils { ...@@ -534,7 +536,7 @@ public final class DataModelUtils {
534 dataTypeName = unionNode.getName(); 536 dataTypeName = unionNode.getName();
535 } 537 }
536 if (potentialTypeNode.getName().contentEquals(dataTypeName)) { 538 if (potentialTypeNode.getName().contentEquals(dataTypeName)) {
537 - dataType.setDataTypeExtendedInfo((Object) potentialTypeNode); 539 + dataType.setDataTypeExtendedInfo(potentialTypeNode);
538 return; 540 return;
539 } 541 }
540 potentialTypeNode = potentialTypeNode.getNextSibling(); 542 potentialTypeNode = potentialTypeNode.getNextSibling();
...@@ -542,4 +544,52 @@ public final class DataModelUtils { ...@@ -542,4 +544,52 @@ public final class DataModelUtils {
542 544
543 throw new DataModelException("Data model error: cloned leaves type is not found"); 545 throw new DataModelException("Data model error: cloned leaves type is not found");
544 } 546 }
547 +
548 + /**
549 + * Parses jar file and returns list of serialized file names.
550 + *
551 + * @param jarFile jar file to be parsed
552 + * @param directory directory where to search
553 + * @return list of serialized files
554 + * @throws IOException when fails to do IO operations
555 + */
556 + public static List<YangNode> parseJarFile(String jarFile, String directory)
557 + throws IOException {
558 +
559 + List<YangNode> nodes = new ArrayList<>();
560 + JarFile jar = new JarFile(jarFile);
561 + Enumeration<?> enumEntries = jar.entries();
562 +
563 + while (enumEntries.hasMoreElements()) {
564 + JarEntry file = (JarEntry) enumEntries.nextElement();
565 + if (file.getName().endsWith(".ser")) {
566 +
567 + if (file.getName().contains(SLASH)) {
568 + String[] strArray = file.getName().split(SLASH);
569 + String tempPath = "";
570 + for (int i = 0; i < strArray.length - 1; i++) {
571 + tempPath = SLASH + tempPath + SLASH + strArray[i];
572 + }
573 + File dir = new File(directory + tempPath);
574 + dir.mkdirs();
575 + }
576 + File serializedFile = new File(directory + SLASH + file.getName());
577 + if (file.isDirectory()) {
578 + serializedFile.mkdirs();
579 + continue;
580 + }
581 + InputStream inputStream = jar.getInputStream(file);
582 +
583 + FileOutputStream fileOutputStream = new FileOutputStream(serializedFile);
584 + while (inputStream.available() > 0) {
585 + fileOutputStream.write(inputStream.read());
586 + }
587 + fileOutputStream.close();
588 + inputStream.close();
589 + nodes.add(deSerializeDataModel(serializedFile.toString()));
590 + }
591 + }
592 + jar.close();
593 + return nodes;
594 + }
545 } 595 }
......
...@@ -22,6 +22,7 @@ import java.util.List; ...@@ -22,6 +22,7 @@ import java.util.List;
22 import java.util.Set; 22 import java.util.Set;
23 import java.util.regex.Pattern; 23 import java.util.regex.Pattern;
24 24
25 +import org.onosproject.yangutils.datamodel.YangAtomicPath;
25 import org.onosproject.yangutils.datamodel.YangAugment; 26 import org.onosproject.yangutils.datamodel.YangAugment;
26 import org.onosproject.yangutils.datamodel.YangAugmentableNode; 27 import org.onosproject.yangutils.datamodel.YangAugmentableNode;
27 import org.onosproject.yangutils.datamodel.YangAugmentedInfo; 28 import org.onosproject.yangutils.datamodel.YangAugmentedInfo;
...@@ -41,7 +42,6 @@ import org.onosproject.yangutils.linker.exceptions.LinkerException; ...@@ -41,7 +42,6 @@ import org.onosproject.yangutils.linker.exceptions.LinkerException;
41 42
42 import static org.onosproject.yangutils.utils.UtilConstants.COLON; 43 import static org.onosproject.yangutils.utils.UtilConstants.COLON;
43 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 44 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
44 -import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING;
45 45
46 /** 46 /**
47 * Represent utilities for YANG linker. 47 * Represent utilities for YANG linker.
...@@ -73,7 +73,7 @@ public final class YangLinkerUtils { ...@@ -73,7 +73,7 @@ public final class YangLinkerUtils {
73 } 73 }
74 } 74 }
75 if (targetNode instanceof YangChoice) { 75 if (targetNode instanceof YangChoice) {
76 - // no need to check here. 76 + //Do nothing
77 } else { 77 } else {
78 detectCollisionInLeaveHolders(targetNode, augment); 78 detectCollisionInLeaveHolders(targetNode, augment);
79 while (augmentsChild != null) { 79 while (augmentsChild != null) {
...@@ -83,7 +83,7 @@ public final class YangLinkerUtils { ...@@ -83,7 +83,7 @@ public final class YangLinkerUtils {
83 } 83 }
84 } 84 }
85 85
86 - /*Detects collision between leaves/leaflists*/ 86 + /*Detects collision between leaves/leaf-lists*/
87 private static void detectCollisionInLeaveHolders(YangNode targetNode, YangAugment augment) { 87 private static void detectCollisionInLeaveHolders(YangNode targetNode, YangAugment augment) {
88 YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode; 88 YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode;
89 YangNode parent = targetNode; 89 YangNode parent = targetNode;
...@@ -160,17 +160,19 @@ public final class YangLinkerUtils { ...@@ -160,17 +160,19 @@ public final class YangLinkerUtils {
160 * @param remainingAncestors ancestor count to move in augment path 160 * @param remainingAncestors ancestor count to move in augment path
161 * @return list of path names needed in leafref 161 * @return list of path names needed in leafref
162 */ 162 */
163 - public static List<String> getPathWithAugment(YangAugment augment, int remainingAncestors) { 163 + static List<String> getPathWithAugment(YangAugment augment, int remainingAncestors) {
164 - String augmentName = augment.getName();
165 List<String> listOfPathName = new ArrayList<>(); 164 List<String> listOfPathName = new ArrayList<>();
166 - if (augmentName.contains(SLASH_FOR_STRING)) { 165 + for (YangAtomicPath atomicPath : augment.getTargetNode()) {
167 - String[] augmentNodeNames = augmentName.split(SLASH_FOR_STRING); 166 + if (atomicPath.getNodeIdentifier().getPrefix() != null && !atomicPath.getNodeIdentifier().getPrefix()
168 - for (String valueInAugment : augmentNodeNames) { 167 + .equals(EMPTY_STRING)) {
169 - if (valueInAugment != null && valueInAugment != EMPTY_STRING && !valueInAugment.isEmpty()) { 168 + listOfPathName.add(atomicPath.getNodeIdentifier().getPrefix() + ":" +
170 - listOfPathName.add(valueInAugment); 169 + atomicPath.getNodeIdentifier().getName());
171 - } 170 + } else {
171 + listOfPathName.add(atomicPath.getNodeIdentifier().getName());
172 } 172 }
173 } 173 }
174 +
175 +
174 for (int countOfAncestor = 0; countOfAncestor < remainingAncestors; countOfAncestor++) { 176 for (int countOfAncestor = 0; countOfAncestor < remainingAncestors; countOfAncestor++) {
175 listOfPathName.remove(listOfPathName.size() - 1); 177 listOfPathName.remove(listOfPathName.size() - 1);
176 } 178 }
...@@ -185,7 +187,7 @@ public final class YangLinkerUtils { ...@@ -185,7 +187,7 @@ public final class YangLinkerUtils {
185 * @return parent node which can hold data 187 * @return parent node which can hold data
186 * @throws LinkerException a violation of linker rules 188 * @throws LinkerException a violation of linker rules
187 */ 189 */
188 - public static YangNode skipInvalidDataNodes(YangNode currentParent, YangLeafRef leafref) throws LinkerException { 190 + static YangNode skipInvalidDataNodes(YangNode currentParent, YangLeafRef leafref) throws LinkerException {
189 while (currentParent instanceof YangChoice || currentParent instanceof YangCase) { 191 while (currentParent instanceof YangChoice || currentParent instanceof YangCase) {
190 if (currentParent.getParent() == null) { 192 if (currentParent.getParent() == null) {
191 throw new LinkerException("YANG file error: The target node, in the leafref path " + 193 throw new LinkerException("YANG file error: The target node, in the leafref path " +
...@@ -203,8 +205,8 @@ public final class YangLinkerUtils { ...@@ -203,8 +205,8 @@ public final class YangLinkerUtils {
203 * @param yangConstruct yang construct for creating error message 205 * @param yangConstruct yang construct for creating error message
204 * @return valid node identifier 206 * @return valid node identifier
205 */ 207 */
206 - public static YangNodeIdentifier getValidNodeIdentifier(String nodeIdentifierString, 208 + static YangNodeIdentifier getValidNodeIdentifier(String nodeIdentifierString,
207 - YangConstructType yangConstruct) { 209 + YangConstructType yangConstruct) {
208 String[] tmpData = nodeIdentifierString.split(Pattern.quote(COLON)); 210 String[] tmpData = nodeIdentifierString.split(Pattern.quote(COLON));
209 if (tmpData.length == 1) { 211 if (tmpData.length == 1) {
210 YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier(); 212 YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier();
...@@ -264,7 +266,7 @@ public final class YangLinkerUtils { ...@@ -264,7 +266,7 @@ public final class YangLinkerUtils {
264 * 266 *
265 * @param yangNode YANG node information 267 * @param yangNode YANG node information
266 */ 268 */
267 - public static void updateFilePriorityOfNode(YangNode yangNode) { 269 + private static void updateFilePriorityOfNode(YangNode yangNode) {
268 int curNodePriority = yangNode.getPriority(); 270 int curNodePriority = yangNode.getPriority();
269 if (yangNode instanceof YangReferenceResolver) { 271 if (yangNode instanceof YangReferenceResolver) {
270 List<YangImport> yangImportList = ((YangReferenceResolver) yangNode).getImportList(); 272 List<YangImport> yangImportList = ((YangReferenceResolver) yangNode).getImportList();
......
...@@ -21,6 +21,7 @@ import java.util.Iterator; ...@@ -21,6 +21,7 @@ import java.util.Iterator;
21 import java.util.LinkedList; 21 import java.util.LinkedList;
22 import java.util.List; 22 import java.util.List;
23 import java.util.Stack; 23 import java.util.Stack;
24 +
24 import org.onosproject.yangutils.datamodel.Resolvable; 25 import org.onosproject.yangutils.datamodel.Resolvable;
25 import org.onosproject.yangutils.datamodel.ResolvableType; 26 import org.onosproject.yangutils.datamodel.ResolvableType;
26 import org.onosproject.yangutils.datamodel.TraversalType; 27 import org.onosproject.yangutils.datamodel.TraversalType;
...@@ -1221,7 +1222,7 @@ public class YangResolutionInfoImpl<T> ...@@ -1221,7 +1222,7 @@ public class YangResolutionInfoImpl<T>
1221 YangXpathLinker<T> xPathLinker = new YangXpathLinker<T>(); 1222 YangXpathLinker<T> xPathLinker = new YangXpathLinker<T>();
1222 1223
1223 if (entityToResolve instanceof YangAugment) { 1224 if (entityToResolve instanceof YangAugment) {
1224 - YangNode targetNode = null; 1225 + YangNode targetNode;
1225 YangAugment augment = (YangAugment) entityToResolve; 1226 YangAugment augment = (YangAugment) entityToResolve;
1226 targetNode = xPathLinker.processAugmentXpathLinking(augment.getTargetNode(), 1227 targetNode = xPathLinker.processAugmentXpathLinking(augment.getTargetNode(),
1227 (YangNode) root); 1228 (YangNode) root);
...@@ -1485,9 +1486,9 @@ public class YangResolutionInfoImpl<T> ...@@ -1485,9 +1486,9 @@ public class YangResolutionInfoImpl<T>
1485 /** 1486 /**
1486 * Fills the absolute path values in the leafref from relative path. 1487 * Fills the absolute path values in the leafref from relative path.
1487 * 1488 *
1488 - * @param leafref instance of YANG leafref 1489 + * @param leafref instance of YANG leafref
1489 - * @param pathNameToBePrefixed path name which has to be prefixed to relative path 1490 + * @param pathNameToBePrefixed path name which has to be prefixed to relative path
1490 - * @param atomicPathsInRelative atomic paths in relative 1491 + * @param atomicPathsInRelative atomic paths in relative
1491 * @throws DataModelException a violation of data model rules 1492 * @throws DataModelException a violation of data model rules
1492 */ 1493 */
1493 private void fillAbsolutePathValuesInLeafref(YangLeafRef leafref, String pathNameToBePrefixed, 1494 private void fillAbsolutePathValuesInLeafref(YangLeafRef leafref, String pathNameToBePrefixed,
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 package org.onosproject.yangutils.parser.impl; 17 package org.onosproject.yangutils.parser.impl;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 +
20 import org.antlr.v4.runtime.ANTLRFileStream; 21 import org.antlr.v4.runtime.ANTLRFileStream;
21 import org.antlr.v4.runtime.ANTLRInputStream; 22 import org.antlr.v4.runtime.ANTLRInputStream;
22 import org.antlr.v4.runtime.CommonTokenStream; 23 import org.antlr.v4.runtime.CommonTokenStream;
......
...@@ -24,7 +24,7 @@ import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; ...@@ -24,7 +24,7 @@ import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
24 /** 24 /**
25 * Represents YANG file information. 25 * Represents YANG file information.
26 */ 26 */
27 -public class YangFileInfo { 27 +class YangFileInfo {
28 28
29 /** 29 /**
30 * YANG file name. 30 * YANG file name.
...@@ -79,7 +79,7 @@ public class YangFileInfo { ...@@ -79,7 +79,7 @@ public class YangFileInfo {
79 * 79 *
80 * @return yangFileName YANG file name 80 * @return yangFileName YANG file name
81 */ 81 */
82 - public String getYangFileName() { 82 + String getYangFileName() {
83 return yangFileName; 83 return yangFileName;
84 } 84 }
85 85
...@@ -88,7 +88,7 @@ public class YangFileInfo { ...@@ -88,7 +88,7 @@ public class YangFileInfo {
88 * 88 *
89 * @param yangFileName YANG file name 89 * @param yangFileName YANG file name
90 */ 90 */
91 - public void setYangFileName(String yangFileName) { 91 + void setYangFileName(String yangFileName) {
92 this.yangFileName = yangFileName; 92 this.yangFileName = yangFileName;
93 } 93 }
94 94
...@@ -151,7 +151,7 @@ public class YangFileInfo { ...@@ -151,7 +151,7 @@ public class YangFileInfo {
151 * 151 *
152 * @return isForTranslator true if node need to be translated 152 * @return isForTranslator true if node need to be translated
153 */ 153 */
154 - public boolean isForTranslator() { 154 + boolean isForTranslator() {
155 return isForTranslator; 155 return isForTranslator;
156 } 156 }
157 157
...@@ -160,7 +160,7 @@ public class YangFileInfo { ...@@ -160,7 +160,7 @@ public class YangFileInfo {
160 * 160 *
161 * @param isForTranslator true if node need to be translated 161 * @param isForTranslator true if node need to be translated
162 */ 162 */
163 - public void setForTranslator(boolean isForTranslator) { 163 + void setForTranslator(boolean isForTranslator) {
164 this.isForTranslator = isForTranslator; 164 this.isForTranslator = isForTranslator;
165 } 165 }
166 166
......
...@@ -19,41 +19,36 @@ package org.onosproject.yangutils.plugin.manager; ...@@ -19,41 +19,36 @@ package org.onosproject.yangutils.plugin.manager;
19 import java.io.File; 19 import java.io.File;
20 import java.io.FileOutputStream; 20 import java.io.FileOutputStream;
21 import java.io.IOException; 21 import java.io.IOException;
22 -import java.io.InputStream;
23 import java.io.ObjectOutputStream; 22 import java.io.ObjectOutputStream;
24 import java.nio.file.Files; 23 import java.nio.file.Files;
25 import java.nio.file.StandardCopyOption; 24 import java.nio.file.StandardCopyOption;
26 import java.util.ArrayList; 25 import java.util.ArrayList;
27 -import java.util.Enumeration;
28 import java.util.Iterator; 26 import java.util.Iterator;
29 import java.util.List; 27 import java.util.List;
30 import java.util.Set; 28 import java.util.Set;
31 -import java.util.jar.JarEntry;
32 -import java.util.jar.JarFile;
33 29
34 import org.apache.maven.artifact.repository.ArtifactRepository; 30 import org.apache.maven.artifact.repository.ArtifactRepository;
35 import org.apache.maven.model.Dependency; 31 import org.apache.maven.model.Dependency;
36 import org.apache.maven.model.Resource; 32 import org.apache.maven.model.Resource;
37 import org.apache.maven.project.MavenProject; 33 import org.apache.maven.project.MavenProject;
38 import org.onosproject.yangutils.datamodel.YangNode; 34 import org.onosproject.yangutils.datamodel.YangNode;
35 +import org.onosproject.yangutils.datamodel.utils.DataModelUtils;
39 import org.slf4j.Logger; 36 import org.slf4j.Logger;
40 import org.sonatype.plexus.build.incremental.BuildContext; 37 import org.sonatype.plexus.build.incremental.BuildContext;
41 38
42 -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.deSerializeDataModel;
43 import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; 39 import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
44 import static org.onosproject.yangutils.utils.UtilConstants.JAR; 40 import static org.onosproject.yangutils.utils.UtilConstants.JAR;
45 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 41 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
46 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 42 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
47 import static org.onosproject.yangutils.utils.UtilConstants.TEMP; 43 import static org.onosproject.yangutils.utils.UtilConstants.TEMP;
48 import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES; 44 import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES;
49 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
50 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; 45 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
51 import static org.slf4j.LoggerFactory.getLogger; 46 import static org.slf4j.LoggerFactory.getLogger;
52 47
53 /** 48 /**
54 * Represents YANG plugin utilities. 49 * Represents YANG plugin utilities.
55 */ 50 */
56 -public final class YangPluginUtils { 51 +final class YangPluginUtils {
57 52
58 private static final Logger log = getLogger(YangPluginUtils.class); 53 private static final Logger log = getLogger(YangPluginUtils.class);
59 54
...@@ -71,7 +66,7 @@ public final class YangPluginUtils { ...@@ -71,7 +66,7 @@ public final class YangPluginUtils {
71 * @param project current maven project 66 * @param project current maven project
72 * @param context current build context 67 * @param context current build context
73 */ 68 */
74 - public static void addToCompilationRoot(String source, MavenProject project, BuildContext context) { 69 + static void addToCompilationRoot(String source, MavenProject project, BuildContext context) {
75 project.addCompileSourceRoot(source); 70 project.addCompileSourceRoot(source);
76 context.refresh(project.getBasedir()); 71 context.refresh(project.getBasedir());
77 log.info("Source directory added to compilation root: " + source); 72 log.info("Source directory added to compilation root: " + source);
...@@ -85,7 +80,7 @@ public final class YangPluginUtils { ...@@ -85,7 +80,7 @@ public final class YangPluginUtils {
85 * @param project maven project 80 * @param project maven project
86 * @throws IOException when fails to copy files to destination resource directory 81 * @throws IOException when fails to copy files to destination resource directory
87 */ 82 */
88 - public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project) 83 + static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
89 throws IOException { 84 throws IOException {
90 85
91 List<File> files = getListOfFile(yangFileInfo); 86 List<File> files = getListOfFile(yangFileInfo);
...@@ -129,8 +124,8 @@ public final class YangPluginUtils { ...@@ -129,8 +124,8 @@ public final class YangPluginUtils {
129 * @param operation true if need to add to resource 124 * @param operation true if need to add to resource
130 * @throws IOException when fails to do IO operations 125 * @throws IOException when fails to do IO operations
131 */ 126 */
132 - public static void serializeDataModel(String directory, Set<YangFileInfo> fileInfoSet, 127 + static void serializeDataModel(String directory, Set<YangFileInfo> fileInfoSet,
133 - MavenProject project, boolean operation) throws IOException { 128 + MavenProject project, boolean operation) throws IOException {
134 129
135 String serFileDirPath = directory + TARGET_RESOURCE_PATH; 130 String serFileDirPath = directory + TARGET_RESOURCE_PATH;
136 File dir = new File(serFileDirPath); 131 File dir = new File(serFileDirPath);
...@@ -142,7 +137,7 @@ public final class YangPluginUtils { ...@@ -142,7 +137,7 @@ public final class YangPluginUtils {
142 137
143 for (YangFileInfo fileInfo : fileInfoSet) { 138 for (YangFileInfo fileInfo : fileInfoSet) {
144 139
145 - String serFileName = serFileDirPath + getCamelCase(fileInfo.getRootNode().getName(), null) 140 + String serFileName = serFileDirPath + fileInfo.getRootNode().getName()
146 + SERIALIZED_FILE_EXTENSION; 141 + SERIALIZED_FILE_EXTENSION;
147 fileInfo.setSerializedFile(serFileName); 142 fileInfo.setSerializedFile(serFileName);
148 FileOutputStream fileOutputStream = new FileOutputStream(serFileName); 143 FileOutputStream fileOutputStream = new FileOutputStream(serFileName);
...@@ -201,67 +196,18 @@ public final class YangPluginUtils { ...@@ -201,67 +196,18 @@ public final class YangPluginUtils {
201 * @return list of resolved datamodel nodes 196 * @return list of resolved datamodel nodes
202 * @throws IOException when fails to do IO operations 197 * @throws IOException when fails to do IO operations
203 */ 198 */
204 - public static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository, 199 + static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository,
205 - List<ArtifactRepository> remoteRepos, String directory) 200 + List<ArtifactRepository> remoteRepos, String directory)
206 throws IOException { 201 throws IOException {
207 202
208 - List<String> dependeciesJarPaths = resolveDependencyJarPath(project, localRepository, remoteRepos); 203 + List<String> dependenciesJarPaths = resolveDependencyJarPath(project, localRepository, remoteRepos);
209 List<YangNode> resolvedDataModelNodes = new ArrayList<>(); 204 List<YangNode> resolvedDataModelNodes = new ArrayList<>();
210 - for (String dependecy : dependeciesJarPaths) { 205 + for (String dependency : dependenciesJarPaths) {
211 - resolvedDataModelNodes.addAll(deSerializeDataModel(parseJarFile(dependecy, directory))); 206 + resolvedDataModelNodes.addAll(DataModelUtils.parseJarFile(dependency, directory));
212 } 207 }
213 return resolvedDataModelNodes; 208 return resolvedDataModelNodes;
214 } 209 }
215 210
216 - /**
217 - * Parses jar file and returns list of serialized file names.
218 - *
219 - * @param jarFile jar file to be parsed
220 - * @param directory directory for keeping the searized files
221 - * @return list of serialized files
222 - * @throws IOException when fails to do IO operations
223 - */
224 - public static List<String> parseJarFile(String jarFile, String directory)
225 - throws IOException {
226 -
227 - List<String> serailizedFiles = new ArrayList<>();
228 - JarFile jar = new JarFile(jarFile);
229 - Enumeration<?> enumEntries = jar.entries();
230 -
231 - File serializedFileDir = new File(directory);
232 - serializedFileDir.mkdirs();
233 - while (enumEntries.hasMoreElements()) {
234 - JarEntry file = (JarEntry) enumEntries.nextElement();
235 - if (file.getName().endsWith(SERIALIZED_FILE_EXTENSION)) {
236 - if (file.getName().contains(SLASH)) {
237 - String[] strArray = file.getName().split(SLASH);
238 - String tempPath = "";
239 - for (int i = 0; i < strArray.length - 1; i++) {
240 - tempPath = SLASH + tempPath + SLASH + strArray[i];
241 - }
242 - File dir = new File(directory + tempPath);
243 - dir.mkdirs();
244 - }
245 - File serailizedFile = new File(directory + SLASH + file.getName());
246 - if (file.isDirectory()) {
247 - serailizedFile.mkdirs();
248 - continue;
249 - }
250 - InputStream inputStream = jar.getInputStream(file);
251 -
252 - FileOutputStream fileOutputStream = new FileOutputStream(serailizedFile);
253 - while (inputStream.available() > 0) {
254 - fileOutputStream.write(inputStream.read());
255 - }
256 - fileOutputStream.close();
257 - inputStream.close();
258 - serailizedFiles.add(serailizedFile.toString());
259 - }
260 - }
261 - jar.close();
262 - return serailizedFiles;
263 - }
264 -
265 /* Adds directory to resources of project */ 211 /* Adds directory to resources of project */
266 private static void addToProjectResource(String dir, MavenProject project) { 212 private static void addToProjectResource(String dir, MavenProject project) {
267 Resource rsc = new Resource(); 213 Resource rsc = new Resource();
......
...@@ -32,6 +32,8 @@ import org.apache.maven.plugins.annotations.Mojo; ...@@ -32,6 +32,8 @@ import org.apache.maven.plugins.annotations.Mojo;
32 import org.apache.maven.plugins.annotations.Parameter; 32 import org.apache.maven.plugins.annotations.Parameter;
33 import org.apache.maven.project.MavenProject; 33 import org.apache.maven.project.MavenProject;
34 import org.onosproject.yangutils.datamodel.YangNode; 34 import org.onosproject.yangutils.datamodel.YangNode;
35 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
36 +import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflictUtil;
35 import org.onosproject.yangutils.linker.YangLinker; 37 import org.onosproject.yangutils.linker.YangLinker;
36 import org.onosproject.yangutils.linker.exceptions.LinkerException; 38 import org.onosproject.yangutils.linker.exceptions.LinkerException;
37 import org.onosproject.yangutils.linker.impl.YangLinkerManager; 39 import org.onosproject.yangutils.linker.impl.YangLinkerManager;
...@@ -39,8 +41,6 @@ import org.onosproject.yangutils.parser.YangUtilsParser; ...@@ -39,8 +41,6 @@ import org.onosproject.yangutils.parser.YangUtilsParser;
39 import org.onosproject.yangutils.parser.exceptions.ParserException; 41 import org.onosproject.yangutils.parser.exceptions.ParserException;
40 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 42 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
41 import org.onosproject.yangutils.utils.io.impl.YangFileScanner; 43 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
42 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
43 -import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflictUtil;
44 import org.sonatype.plexus.build.incremental.BuildContext; 44 import org.sonatype.plexus.build.incremental.BuildContext;
45 45
46 import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES; 46 import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES;
...@@ -70,7 +70,7 @@ public class YangUtilManager ...@@ -70,7 +70,7 @@ public class YangUtilManager
70 extends AbstractMojo { 70 extends AbstractMojo {
71 71
72 private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG); 72 private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG);
73 - YangPluginConfig yangPlugin = new YangPluginConfig(); 73 + private YangPluginConfig yangPlugin = new YangPluginConfig();
74 private YangNode rootNode; 74 private YangNode rootNode;
75 // YANG file information set. 75 // YANG file information set.
76 private Set<YangFileInfo> yangFileInfoSet = new HashSet<>(); 76 private Set<YangFileInfo> yangFileInfoSet = new HashSet<>();
...@@ -91,12 +91,6 @@ public class YangUtilManager ...@@ -91,12 +91,6 @@ public class YangUtilManager
91 private String classFileDir; 91 private String classFileDir;
92 92
93 /** 93 /**
94 - * Source directory for manager's generated files.
95 - */
96 - @Parameter(property = "managerFileDir", defaultValue = "src/main/java")
97 - private String managerFileDir;
98 -
99 - /**
100 * Base directory for project. 94 * Base directory for project.
101 */ 95 */
102 @Parameter(property = "basedir", defaultValue = "${basedir}") 96 @Parameter(property = "basedir", defaultValue = "${basedir}")
...@@ -159,8 +153,8 @@ public class YangUtilManager ...@@ -159,8 +153,8 @@ public class YangUtilManager
159 /** 153 /**
160 * Code generation is for nbi or sbi. 154 * Code generation is for nbi or sbi.
161 */ 155 */
162 - @Parameter(property = "generateJavaFileForsbi", defaultValue = "nbi") 156 + @Parameter(property = "generateJavaFileForSbi", defaultValue = "nbi")
163 - private String generateJavaFileForsbi; 157 + private String generateJavaFileForSbi;
164 158
165 @Override 159 @Override
166 public void execute() 160 public void execute()
...@@ -171,12 +165,10 @@ public class YangUtilManager ...@@ -171,12 +165,10 @@ public class YangUtilManager
171 /* 165 /*
172 * For deleting the generated code in previous build. 166 * For deleting the generated code in previous build.
173 */ 167 */
174 - deleteDirectory(getDirectory(baseDir, classFileDir) + DEFAULT_PKG);
175 deleteDirectory(getDirectory(baseDir, outputDirectory)); 168 deleteDirectory(getDirectory(baseDir, outputDirectory));
176 169
177 String searchDir = getDirectory(baseDir, yangFilesDir); 170 String searchDir = getDirectory(baseDir, yangFilesDir);
178 String codeGenDir = getDirectory(baseDir, classFileDir) + SLASH; 171 String codeGenDir = getDirectory(baseDir, classFileDir) + SLASH;
179 - String managerCodeGenDir = getDirectory(baseDir, managerFileDir) + SLASH;
180 172
181 // Creates conflict resolver and set values to it. 173 // Creates conflict resolver and set values to it.
182 YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil(); 174 YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil();
...@@ -185,10 +177,9 @@ public class YangUtilManager ...@@ -185,10 +177,9 @@ public class YangUtilManager
185 conflictResolver.setReplacementForUnderscore(replacementForUnderscore); 177 conflictResolver.setReplacementForUnderscore(replacementForUnderscore);
186 conflictResolver.setPrefixForIdentifier(prefixForIdentifier); 178 conflictResolver.setPrefixForIdentifier(prefixForIdentifier);
187 yangPlugin.setCodeGenDir(codeGenDir); 179 yangPlugin.setCodeGenDir(codeGenDir);
188 - yangPlugin.setManagerCodeGenDir(managerCodeGenDir);
189 yangPlugin.setConflictResolver(conflictResolver); 180 yangPlugin.setConflictResolver(conflictResolver);
190 181
191 - yangPlugin.setCodeGenerateForsbi(generateJavaFileForsbi.toLowerCase()); 182 + yangPlugin.setCodeGenerateForsbi(generateJavaFileForSbi.toLowerCase());
192 /* 183 /*
193 * Obtain the YANG files at a path mentioned in plugin and creates 184 * Obtain the YANG files at a path mentioned in plugin and creates
194 * YANG file information set. 185 * YANG file information set.
...@@ -216,7 +207,6 @@ public class YangUtilManager ...@@ -216,7 +207,6 @@ public class YangUtilManager
216 serializeDataModel(getDirectory(baseDir, outputDirectory), getYangFileInfoSet(), project, true); 207 serializeDataModel(getDirectory(baseDir, outputDirectory), getYangFileInfoSet(), project, true);
217 208
218 addToCompilationRoot(codeGenDir, project, context); 209 addToCompilationRoot(codeGenDir, project, context);
219 - addToCompilationRoot(managerCodeGenDir, project, context);
220 210
221 copyYangFilesToTarget(getYangFileInfoSet(), getDirectory(baseDir, outputDirectory), project); 211 copyYangFilesToTarget(getYangFileInfoSet(), getDirectory(baseDir, outputDirectory), project);
222 } catch (IOException | ParserException e) { 212 } catch (IOException | ParserException e) {
...@@ -232,7 +222,7 @@ public class YangUtilManager ...@@ -232,7 +222,7 @@ public class YangUtilManager
232 "Error handler failed to delete files for data model node."); 222 "Error handler failed to delete files for data model node.");
233 } 223 }
234 throw new MojoExecutionException( 224 throw new MojoExecutionException(
235 - "Exception occured due to " + e.getLocalizedMessage() + " in " + fileName 225 + "Exception occurred due to " + e.getLocalizedMessage() + " in " + fileName
236 + " YANG file."); 226 + " YANG file.");
237 } 227 }
238 } 228 }
...@@ -264,14 +254,14 @@ public class YangUtilManager ...@@ -264,14 +254,14 @@ public class YangUtilManager
264 getYangFileInfoSet().add(dependentFileInfo); 254 getYangFileInfoSet().add(dependentFileInfo);
265 } 255 }
266 } catch (IOException e) { 256 } catch (IOException e) {
267 - throw new IOException("failed to resolve in interjar scenario."); 257 + throw new IOException("failed to resolve in inter-jar scenario.");
268 } 258 }
269 } 259 }
270 260
271 /** 261 /**
272 * Links all the provided with the YANG file info set. 262 * Links all the provided with the YANG file info set.
273 * 263 *
274 - * @throws MojoExecutionException a violation in mojo excecution 264 + * @throws MojoExecutionException a violation in mojo execution
275 */ 265 */
276 public void resolveDependenciesUsingLinker() 266 public void resolveDependenciesUsingLinker()
277 throws MojoExecutionException { 267 throws MojoExecutionException {
...@@ -378,7 +368,7 @@ public class YangUtilManager ...@@ -378,7 +368,7 @@ public class YangUtilManager
378 * 368 *
379 * @return the YANG file info set 369 * @return the YANG file info set
380 */ 370 */
381 - public Set<YangFileInfo> getYangFileInfoSet() { 371 + Set<YangFileInfo> getYangFileInfoSet() {
382 return yangFileInfoSet; 372 return yangFileInfoSet;
383 } 373 }
384 374
......
...@@ -39,7 +39,7 @@ public final class GeneratedJavaFileType { ...@@ -39,7 +39,7 @@ public final class GeneratedJavaFileType {
39 /** 39 /**
40 * Impl class file. 40 * Impl class file.
41 */ 41 */
42 - public static final int IMPL_CLASS_MASK = 8; 42 + public static final int DEFAULT_CLASS_MASK = 8;
43 43
44 /** 44 /**
45 * Interface and class file. 45 * Interface and class file.
...@@ -69,7 +69,7 @@ public final class GeneratedJavaFileType { ...@@ -69,7 +69,7 @@ public final class GeneratedJavaFileType {
69 /** 69 /**
70 * Java class corresponding to typedef. 70 * Java class corresponding to typedef.
71 */ 71 */
72 - public static final int GENERATE_TYPE_CLASS = GENERATE_TYPEDEF_CLASS 72 + static final int GENERATE_TYPE_CLASS = GENERATE_TYPEDEF_CLASS
73 | GENERATE_UNION_CLASS; 73 | GENERATE_UNION_CLASS;
74 74
75 /** 75 /**
...@@ -99,16 +99,6 @@ public final class GeneratedJavaFileType { ...@@ -99,16 +99,6 @@ public final class GeneratedJavaFileType {
99 public static final int GENERATE_IDENTITY_CLASS = 2048; 99 public static final int GENERATE_IDENTITY_CLASS = 2048;
100 100
101 /** 101 /**
102 - * Operation class file.
103 - */
104 - public static final int OPERATION_CLASS_MASK = 4096;
105 -
106 - /**
107 - * Operation class builder file.
108 - */
109 - public static final int OPERATION_BUILDER_CLASS_MASK = 8192;
110 -
111 - /**
112 * Creates an instance of generate java file type. 102 * Creates an instance of generate java file type.
113 */ 103 */
114 private GeneratedJavaFileType() { 104 private GeneratedJavaFileType() {
......
...@@ -122,6 +122,21 @@ public final class GeneratedTempFileType { ...@@ -122,6 +122,21 @@ public final class GeneratedTempFileType {
122 public static final int EVENT_SUBJECT_SETTER_MASK = 524288; 122 public static final int EVENT_SUBJECT_SETTER_MASK = 524288;
123 123
124 /** 124 /**
125 + * Add to list method interface for class.
126 + */
127 + public static final int ADD_TO_LIST_INTERFACE_MASK = 1048576;
128 +
129 + /**
130 + * Add to list method implementation for class.
131 + */
132 + public static final int ADD_TO_LIST_IMPL_MASK = 2097152;
133 +
134 + /**
135 + * Leaf identifier enum attributes for class.
136 + */
137 + public static final int LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK = 4194304;
138 +
139 + /**
125 * Creates an instance of generated temp file type. 140 * Creates an instance of generated temp file type.
126 */ 141 */
127 private GeneratedTempFileType() { 142 private GeneratedTempFileType() {
......
...@@ -90,10 +90,6 @@ public final class JavaAttributeInfo { ...@@ -90,10 +90,6 @@ public final class JavaAttributeInfo {
90 * @return the data type info of attribute 90 * @return the data type info of attribute
91 */ 91 */
92 public YangType<?> getAttributeType() { 92 public YangType<?> getAttributeType() {
93 -
94 - if (attrType == null) {
95 - throw new TranslatorException("Expected java attribute type is null");
96 - }
97 return attrType; 93 return attrType;
98 } 94 }
99 95
......
...@@ -17,11 +17,18 @@ ...@@ -17,11 +17,18 @@
17 package org.onosproject.yangutils.translator.tojava; 17 package org.onosproject.yangutils.translator.tojava;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 +import java.util.ArrayList;
21 +import java.util.List;
22 +
20 import org.onosproject.yangutils.datamodel.TraversalType; 23 import org.onosproject.yangutils.datamodel.TraversalType;
24 +import org.onosproject.yangutils.datamodel.YangAugment;
25 +import org.onosproject.yangutils.datamodel.YangCase;
26 +import org.onosproject.yangutils.datamodel.YangChoice;
21 import org.onosproject.yangutils.datamodel.YangInput; 27 import org.onosproject.yangutils.datamodel.YangInput;
22 import org.onosproject.yangutils.datamodel.YangNode; 28 import org.onosproject.yangutils.datamodel.YangNode;
23 import org.onosproject.yangutils.datamodel.YangNodeType; 29 import org.onosproject.yangutils.datamodel.YangNodeType;
24 import org.onosproject.yangutils.datamodel.YangOutput; 30 import org.onosproject.yangutils.datamodel.YangOutput;
31 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
25 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 32 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
26 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 33 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
27 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException; 34 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException;
...@@ -31,6 +38,11 @@ import static org.onosproject.yangutils.datamodel.TraversalType.CHILD; ...@@ -31,6 +38,11 @@ import static org.onosproject.yangutils.datamodel.TraversalType.CHILD;
31 import static org.onosproject.yangutils.datamodel.TraversalType.PARENT; 38 import static org.onosproject.yangutils.datamodel.TraversalType.PARENT;
32 import static org.onosproject.yangutils.datamodel.TraversalType.ROOT; 39 import static org.onosproject.yangutils.datamodel.TraversalType.ROOT;
33 import static org.onosproject.yangutils.datamodel.TraversalType.SIBILING; 40 import static org.onosproject.yangutils.datamodel.TraversalType.SIBILING;
41 +import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
42 +import static org.onosproject.yangutils.translator.tojava.YangDataModelFactory.getYangCaseNode;
43 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getAugmentClassName;
44 +import static org.onosproject.yangutils.utils.UtilConstants.CASE;
45 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
34 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; 46 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
35 47
36 /** 48 /**
...@@ -88,6 +100,11 @@ public final class JavaCodeGeneratorUtil { ...@@ -88,6 +100,11 @@ public final class JavaCodeGeneratorUtil {
88 TraversalType curTraversal = ROOT; 100 TraversalType curTraversal = ROOT;
89 101
90 while (codeGenNode != null) { 102 while (codeGenNode != null) {
103 + if (codeGenNode instanceof YangAugment) {
104 + if (((YangAugment) codeGenNode).getAugmentedNode() instanceof YangChoice) {
105 + addCaseNodeToChoiceTarget((YangAugment) codeGenNode);
106 + }
107 + }
91 if (curTraversal != PARENT) { 108 if (curTraversal != PARENT) {
92 if (!(codeGenNode instanceof JavaCodeGenerator)) { 109 if (!(codeGenNode instanceof JavaCodeGenerator)) {
93 throw new TranslatorException("Unsupported node to generate code"); 110 throw new TranslatorException("Unsupported node to generate code");
...@@ -126,8 +143,8 @@ public final class JavaCodeGeneratorUtil { ...@@ -126,8 +143,8 @@ public final class JavaCodeGeneratorUtil {
126 try { 143 try {
127 generateCodeExit(codeGenNode, yangPlugin); 144 generateCodeExit(codeGenNode, yangPlugin);
128 } catch (Exception e) { 145 } catch (Exception e) {
129 - close(codeGenNode, yangPlugin); 146 + close(codeGenNode, yangPlugin);
130 - throw new TranslatorException(e.getMessage()); 147 + throw new TranslatorException(e.getMessage());
131 } 148 }
132 curTraversal = PARENT; 149 curTraversal = PARENT;
133 codeGenNode = codeGenNode.getParent(); 150 codeGenNode = codeGenNode.getParent();
...@@ -285,7 +302,7 @@ public final class JavaCodeGeneratorUtil { ...@@ -285,7 +302,7 @@ public final class JavaCodeGeneratorUtil {
285 searchAndDeleteTempDir(javaFileInfo.getBaseCodeGenPath() + 302 searchAndDeleteTempDir(javaFileInfo.getBaseCodeGenPath() +
286 javaFileInfo.getPackageFilePath()); 303 javaFileInfo.getPackageFilePath());
287 } else { 304 } else {
288 - searchAndDeleteTempDir(yangPlugin.getManagerCodeGenDir()); 305 + searchAndDeleteTempDir(yangPlugin.getCodeGenDir());
289 } 306 }
290 } 307 }
291 } 308 }
...@@ -347,4 +364,43 @@ public final class JavaCodeGeneratorUtil { ...@@ -347,4 +364,43 @@ public final class JavaCodeGeneratorUtil {
347 } 364 }
348 return null; 365 return null;
349 } 366 }
367 +
368 + /**
369 + * Adds a case node in augment when augmenting a choice node.
370 + *
371 + * @param augment augment node
372 + */
373 + private static void addCaseNodeToChoiceTarget(YangAugment augment) {
374 + YangCase javaCase = getYangCaseNode(JAVA_GENERATION);
375 +
376 + YangPluginConfig pluginConfig = new YangPluginConfig();
377 + javaCase.setName(getAugmentClassName(augment, pluginConfig) + getCapitalCase(CASE));
378 +
379 + if (augment.getListOfLeaf() != null) {
380 + augment.getListOfLeaf().forEach(javaCase::addLeaf);
381 + augment.getListOfLeaf().clear();
382 + }
383 + if (augment.getListOfLeafList() != null) {
384 + augment.getListOfLeafList().forEach(javaCase::addLeafList);
385 + augment.getListOfLeafList().clear();
386 + }
387 + YangNode child = augment.getChild();
388 + List<YangNode> childNodes = new ArrayList<>();
389 + while (child != null) {
390 + child.setParent(javaCase);
391 + childNodes.add(child);
392 + child = child.getNextSibling();
393 + }
394 + augment.setChild(null);
395 + try {
396 + augment.addChild(javaCase);
397 + for (YangNode node : childNodes) {
398 + node.setNextSibling(null);
399 + node.setPreviousSibling(null);
400 + javaCase.addChild(node);
401 + }
402 + } catch (DataModelException e) {
403 + System.out.print("failed to add child node due to " + javaCase.getName() + " " + e.getLocalizedMessage());
404 + }
405 + }
350 } 406 }
......
...@@ -42,9 +42,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; ...@@ -42,9 +42,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
42 import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG; 42 import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG;
43 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 43 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
44 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 44 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
45 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS;
46 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG;
47 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO_CLASS;
48 import static java.util.Collections.sort; 45 import static java.util.Collections.sort;
49 46
50 /** 47 /**
...@@ -226,7 +223,7 @@ public class JavaImportData { ...@@ -226,7 +223,7 @@ public class JavaImportData {
226 * 223 *
227 * @return import for list attribute 224 * @return import for list attribute
228 */ 225 */
229 - private String getImportForList() { 226 + String getImportForList() {
230 return IMPORT + COLLECTION_IMPORTS + PERIOD + LIST + SEMI_COLAN + NEW_LINE; 227 return IMPORT + COLLECTION_IMPORTS + PERIOD + LIST + SEMI_COLAN + NEW_LINE;
231 } 228 }
232 229
...@@ -285,25 +282,6 @@ public class JavaImportData { ...@@ -285,25 +282,6 @@ public class JavaImportData {
285 } 282 }
286 283
287 /** 284 /**
288 - * Returns import string for hash map class.
289 - *
290 - * @return import string for hash map class
291 - */
292 - String getYangAugmentedInfoImport() {
293 - return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS;
294 - }
295 -
296 - /**
297 - * Returns import string for YangAugmentedOpParamInfo class.
298 - *
299 - * @return import string for YangAugmentedOpParamInfo class
300 - */
301 - String getYangAugmentedOpParamInfoImport() {
302 - return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD +
303 - YANG_AUGMENTED_OP_PARAM_INFO_CLASS;
304 - }
305 -
306 - /**
307 * Returns import for big integer. 285 * Returns import for big integer.
308 * 286 *
309 * @return import for big integer 287 * @return import for big integer
......
...@@ -36,7 +36,6 @@ import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJa ...@@ -36,7 +36,6 @@ import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJa
36 */ 36 */
37 public class JavaQualifiedTypeInfoTranslator extends JavaQualifiedTypeInfo 37 public class JavaQualifiedTypeInfoTranslator extends JavaQualifiedTypeInfo
38 implements Comparable<JavaQualifiedTypeInfoTranslator>, Serializable { 38 implements Comparable<JavaQualifiedTypeInfoTranslator>, Serializable {
39 -
40 private static final long serialVersionUID = 806201634L; 39 private static final long serialVersionUID = 806201634L;
41 40
42 /** 41 /**
...@@ -98,7 +97,7 @@ public class JavaQualifiedTypeInfoTranslator extends JavaQualifiedTypeInfo ...@@ -98,7 +97,7 @@ public class JavaQualifiedTypeInfoTranslator extends JavaQualifiedTypeInfo
98 * Current leaves holder is adding a leaf info as a attribute to the 97 * Current leaves holder is adding a leaf info as a attribute to the
99 * current class. 98 * current class.
100 */ 99 */
101 - String className = AttributesJavaDataType.getJavaImportClass(leaf.getDataType(), leaf.isLeafList(), 100 + String className = getJavaImportClass(leaf.getDataType(), leaf.isLeafList(),
102 leaf.getConflictResolveConfig()); 101 leaf.getConflictResolveConfig());
103 if (className != null) { 102 if (className != null) {
104 /* 103 /*
...@@ -106,7 +105,7 @@ public class JavaQualifiedTypeInfoTranslator extends JavaQualifiedTypeInfo ...@@ -106,7 +105,7 @@ public class JavaQualifiedTypeInfoTranslator extends JavaQualifiedTypeInfo
106 * since it can be a derived type or a usage of wrapper classes. 105 * since it can be a derived type or a usage of wrapper classes.
107 */ 106 */
108 importInfo.setClassInfo(className); 107 importInfo.setClassInfo(className);
109 - String classPkg = AttributesJavaDataType.getJavaImportPackage(leaf.getDataType(), 108 + String classPkg = getJavaImportPackage(leaf.getDataType(),
110 leaf.isLeafList(), leaf.getConflictResolveConfig()); 109 leaf.isLeafList(), leaf.getConflictResolveConfig());
111 if (classPkg == null) { 110 if (classPkg == null) {
112 throw new TranslatorException("import package cannot be null when the class is used"); 111 throw new TranslatorException("import package cannot be null when the class is used");
...@@ -222,5 +221,4 @@ public class JavaQualifiedTypeInfoTranslator extends JavaQualifiedTypeInfo ...@@ -222,5 +221,4 @@ public class JavaQualifiedTypeInfoTranslator extends JavaQualifiedTypeInfo
222 public int compareTo(JavaQualifiedTypeInfoTranslator other) { 221 public int compareTo(JavaQualifiedTypeInfoTranslator other) {
223 return getClassInfo().compareTo(other.getClassInfo()); 222 return getClassInfo().compareTo(other.getClassInfo());
224 } 223 }
225 -
226 } 224 }
......
...@@ -29,6 +29,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -29,6 +29,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
30 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 30 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
31 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS; 31 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS;
32 +import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
32 33
33 /** 34 /**
34 * Represents implementation of java code fragments temporary implementations. 35 * Represents implementation of java code fragments temporary implementations.
...@@ -263,18 +264,24 @@ public class TempJavaCodeFragmentFiles { ...@@ -263,18 +264,24 @@ public class TempJavaCodeFragmentFiles {
263 * @param modifier modifier for constructor. 264 * @param modifier modifier for constructor.
264 * @param toAppend string which need to be appended with the class name 265 * @param toAppend string which need to be appended with the class name
265 * @param pluginConfig plugin configurations 266 * @param pluginConfig plugin configurations
267 + * @param curNode YANG node
266 * @return default constructor for class 268 * @return default constructor for class
267 * @throws IOException when fails to append to file 269 * @throws IOException when fails to append to file
268 */ 270 */
269 - public String addDefaultConstructor(String modifier, String toAppend, YangPluginConfig pluginConfig) 271 + public String addDefaultConstructor(String modifier, String toAppend, YangPluginConfig pluginConfig,
272 + YangNode curNode)
270 throws IOException { 273 throws IOException {
274 + boolean isSuffix = false;
275 + if (toAppend.equals(BUILDER)) {
276 + isSuffix = true;
277 + }
271 if (getTypeTempFiles() != null) { 278 if (getTypeTempFiles() != null) {
272 return getTypeTempFiles() 279 return getTypeTempFiles()
273 - .addDefaultConstructor(modifier, toAppend, pluginConfig); 280 + .addDefaultConstructor(modifier, toAppend, pluginConfig, isSuffix);
274 } 281 }
275 282
276 if (getBeanTempFiles() != null) { 283 if (getBeanTempFiles() != null) {
277 - return getBeanTempFiles().addDefaultConstructor(modifier, toAppend, pluginConfig); 284 + return getBeanTempFiles().addDefaultConstructor(modifier, toAppend, pluginConfig, isSuffix);
278 } 285 }
279 286
280 throw new TranslatorException("default constructor should not be added"); 287 throw new TranslatorException("default constructor should not be added");
...@@ -283,10 +290,11 @@ public class TempJavaCodeFragmentFiles { ...@@ -283,10 +290,11 @@ public class TempJavaCodeFragmentFiles {
283 /** 290 /**
284 * Adds build method's implementation for class. 291 * Adds build method's implementation for class.
285 * 292 *
293 + * @param curNode YANG node
286 * @return build method implementation for class 294 * @return build method implementation for class
287 * @throws IOException when fails to append to temporary file 295 * @throws IOException when fails to append to temporary file
288 */ 296 */
289 - public String addBuildMethodImpl() 297 + public String addBuildMethodImpl(YangNode curNode)
290 throws IOException { 298 throws IOException {
291 if (getBeanTempFiles() != null) { 299 if (getBeanTempFiles() != null) {
292 return getBeanTempFiles().addBuildMethodImpl(); 300 return getBeanTempFiles().addBuildMethodImpl();
......
...@@ -22,26 +22,27 @@ import java.util.HashMap; ...@@ -22,26 +22,27 @@ import java.util.HashMap;
22 import java.util.List; 22 import java.util.List;
23 import java.util.Map; 23 import java.util.Map;
24 24
25 -import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
26 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
27 import org.onosproject.yangutils.datamodel.YangEnum; 25 import org.onosproject.yangutils.datamodel.YangEnum;
28 import org.onosproject.yangutils.datamodel.YangEnumeration; 26 import org.onosproject.yangutils.datamodel.YangEnumeration;
29 import org.onosproject.yangutils.datamodel.YangNode; 27 import org.onosproject.yangutils.datamodel.YangNode;
28 +import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
29 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
30 import org.onosproject.yangutils.translator.exception.TranslatorException; 30 import org.onosproject.yangutils.translator.exception.TranslatorException;
31 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeTranslator; 31 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeTranslator;
32 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
33 32
33 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32;
34 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; 34 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK;
35 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; 35 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
36 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString; 36 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString;
37 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile; 37 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile;
38 +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
38 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; 39 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
39 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPrefixForIdentifier;
40 -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
41 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 40 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
41 +import static org.onosproject.yangutils.utils.UtilConstants.INT;
42 import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT; 42 import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT;
43 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; 43 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX;
44 -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 44 +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
45 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPrefixForIdentifier;
45 46
46 /** 47 /**
47 * Represents implementation of java code fragments temporary implementations. Maintains the temp files required 48 * Represents implementation of java code fragments temporary implementations. Maintains the temp files required
...@@ -227,8 +228,8 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles { ...@@ -227,8 +228,8 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
227 */ 228 */
228 public JavaAttributeInfo getJavaAttributeForEnum(YangPluginConfig pluginConfig) { 229 public JavaAttributeInfo getJavaAttributeForEnum(YangPluginConfig pluginConfig) {
229 YangJavaTypeTranslator<?> javaType = new YangJavaTypeTranslator<>(); 230 YangJavaTypeTranslator<?> javaType = new YangJavaTypeTranslator<>();
230 - javaType.setDataType(YangDataTypes.INT32); 231 + javaType.setDataType(INT32);
231 - javaType.setDataTypeName("int"); 232 + javaType.setDataTypeName(INT);
232 javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver()); 233 javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver());
233 return getAttributeInfoForTheData( 234 return getAttributeInfoForTheData(
234 javaType.getJavaQualifiedInfo(), 235 javaType.getJavaQualifiedInfo(),
......
...@@ -20,6 +20,7 @@ import java.io.File; ...@@ -20,6 +20,7 @@ import java.io.File;
20 import java.io.IOException; 20 import java.io.IOException;
21 import java.util.ArrayList; 21 import java.util.ArrayList;
22 import java.util.List; 22 import java.util.List;
23 +
23 import org.onosproject.yangutils.datamodel.YangNode; 24 import org.onosproject.yangutils.datamodel.YangNode;
24 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 25 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
25 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 26 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
...@@ -489,7 +490,7 @@ public class TempJavaEventFragmentFiles ...@@ -489,7 +490,7 @@ public class TempJavaEventFragmentFiles
489 490
490 JavaFileInfo parentInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); 491 JavaFileInfo parentInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
491 return getFileObject(getDirPath(parentInfo), name, JAVA_FILE_EXTENSION, 492 return getFileObject(getDirPath(parentInfo), name, JAVA_FILE_EXTENSION,
492 - parentInfo.getPluginConfig().getCodeGenDir()); 493 + parentInfo);
493 } 494 }
494 495
495 /** 496 /**
......
...@@ -19,7 +19,6 @@ import java.io.File; ...@@ -19,7 +19,6 @@ import java.io.File;
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.List; 20 import java.util.List;
21 21
22 -import org.onosproject.yangutils.datamodel.YangAugment;
23 import org.onosproject.yangutils.datamodel.YangAugmentableNode; 22 import org.onosproject.yangutils.datamodel.YangAugmentableNode;
24 import org.onosproject.yangutils.datamodel.YangCase; 23 import org.onosproject.yangutils.datamodel.YangCase;
25 import org.onosproject.yangutils.datamodel.YangLeaf; 24 import org.onosproject.yangutils.datamodel.YangLeaf;
...@@ -38,19 +37,21 @@ import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; ...@@ -38,19 +37,21 @@ import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
38 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; 37 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
39 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; 38 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
40 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; 39 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
40 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
41 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; 41 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
42 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 42 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
43 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 43 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
44 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS; 44 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS;
45 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
46 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; 45 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
47 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK; 46 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK;
47 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK;
48 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; 48 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
49 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; 49 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
50 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; 50 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK;
51 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; 51 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
52 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK; 52 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
53 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK; 53 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK;
54 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK;
54 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; 55 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
55 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; 56 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
56 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; 57 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
...@@ -58,18 +59,18 @@ import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getA ...@@ -58,18 +59,18 @@ import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getA
58 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedInfoOfFromString; 59 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedInfoOfFromString;
59 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode; 60 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
60 import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo; 61 import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo;
61 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination; 62 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString;
63 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefinition;
62 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; 64 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
63 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports; 65 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports;
64 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile; 66 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile;
65 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile; 67 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile;
66 -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; 68 +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateDefaultClassFile;
67 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; 69 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile;
68 -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateOpParamBuilderClassFile;
69 -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateOpParamImplClassFile;
70 -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports;
71 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; 70 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
72 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 71 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
72 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddToListMethodImpl;
73 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddToListMethodInterface;
73 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; 74 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString;
74 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; 75 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
75 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod; 76 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
...@@ -82,29 +83,25 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator ...@@ -82,29 +83,25 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator
82 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString; 83 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
83 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod; 84 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod;
84 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString; 85 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString;
85 -import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; 86 +import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST_IMPORT;
86 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 87 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
87 -import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT;
88 -import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE;
89 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; 88 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
90 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 89 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
91 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; 90 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
92 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; 91 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
93 import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; 92 import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE;
94 -import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; 93 +import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION_IMPORT;
95 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 94 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
96 -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; 95 +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
97 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 96 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
98 import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; 97 import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
99 import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED; 98 import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
100 -import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE;
101 -import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALITY;
102 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 99 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
103 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; 100 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
104 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 101 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
105 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
106 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; 102 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
107 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; 103 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile;
104 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ADD_TO_LIST;
108 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; 105 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
109 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; 106 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
110 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; 107 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
...@@ -182,6 +179,21 @@ public class TempJavaFragmentFiles { ...@@ -182,6 +179,21 @@ public class TempJavaFragmentFiles {
182 private static final String FROM_STRING_METHOD_FILE_NAME = "FromString"; 179 private static final String FROM_STRING_METHOD_FILE_NAME = "FromString";
183 180
184 /** 181 /**
182 + * File name for from add to list interface method.
183 + */
184 + private static final String ADD_TO_LIST_INTERFACE_METHOD_FILE_NAME = "addToList";
185 +
186 + /**
187 + * File name for from add to list impl method.
188 + */
189 + private static final String ADD_TO_LIST_IMPL_METHOD_FILE_NAME = "addToListImpl";
190 +
191 + /**
192 + * File name for from leaf identifier attributes.
193 + */
194 + private static final String LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME = "leafIdentifierAtr";
195 +
196 + /**
185 * File name for interface java file name suffix. 197 * File name for interface java file name suffix.
186 */ 198 */
187 private static final String INTERFACE_FILE_NAME_SUFFIX = EMPTY_STRING; 199 private static final String INTERFACE_FILE_NAME_SUFFIX = EMPTY_STRING;
...@@ -237,21 +249,11 @@ public class TempJavaFragmentFiles { ...@@ -237,21 +249,11 @@ public class TempJavaFragmentFiles {
237 private File builderClassJavaFileHandle; 249 private File builderClassJavaFileHandle;
238 250
239 /** 251 /**
240 - * Java file handle for builder op param class file.
241 - */
242 - private File builderOpParamClassJavaFileHandle;
243 -
244 - /**
245 * Java file handle for impl class file. 252 * Java file handle for impl class file.
246 */ 253 */
247 private File implClassJavaFileHandle; 254 private File implClassJavaFileHandle;
248 255
249 /** 256 /**
250 - * Java file handle for op param class file.
251 - */
252 - private File opParamClassJavaFileHandle;
253 -
254 - /**
255 * Temporary file handle for attribute. 257 * Temporary file handle for attribute.
256 */ 258 */
257 private File attributesTempFileHandle; 259 private File attributesTempFileHandle;
...@@ -297,19 +299,39 @@ public class TempJavaFragmentFiles { ...@@ -297,19 +299,39 @@ public class TempJavaFragmentFiles {
297 private File fromStringImplTempFileHandle; 299 private File fromStringImplTempFileHandle;
298 300
299 /** 301 /**
302 + * Temporary file handle for add to list interface method of class.
303 + */
304 + private File addToListInterfaceTempFileHandle;
305 +
306 + /**
307 + * Temporary file handle for add to list impl method of class.
308 + */
309 + private File addToListImplTempFileHandle;
310 +
311 + /**
312 + * Temporary file handle for leaf id attributes of enum.
313 + */
314 + private File leafIdAttributeTempFileHandle;
315 +
316 + /**
300 * Import info for case. 317 * Import info for case.
301 */ 318 */
302 private JavaQualifiedTypeInfoTranslator caseImportInfo; 319 private JavaQualifiedTypeInfoTranslator caseImportInfo;
303 320
304 /** 321 /**
305 - * Is attribute added. 322 + * Leaf count.
306 */ 323 */
307 - private boolean isAttributePresent; 324 + private int leafCount = 0;
325 +
326 + /**
327 + * If current node is root node.
328 + */
329 + private boolean isRooNode;
308 330
309 /** 331 /**
310 - * Base code gen path. 332 + * Is attribute added.
311 */ 333 */
312 - private String baseCodePath; 334 + private boolean isAttributePresent;
313 335
314 TempJavaFragmentFiles() { 336 TempJavaFragmentFiles() {
315 } 337 }
...@@ -325,21 +347,17 @@ public class TempJavaFragmentFiles { ...@@ -325,21 +347,17 @@ public class TempJavaFragmentFiles {
325 setJavaExtendsListHolder(new JavaExtendsListHolder()); 347 setJavaExtendsListHolder(new JavaExtendsListHolder());
326 setJavaImportData(new JavaImportData()); 348 setJavaImportData(new JavaImportData());
327 setJavaFileInfo(javaFileInfo); 349 setJavaFileInfo(javaFileInfo);
328 - if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_SERVICE_AND_MANAGER) != 0) { 350 + setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
329 - setBaseCodePath(getJavaFileInfo().getPluginConfig().getCodeGenDir()); 351 + getJavaFileInfo().getPackageFilePath()));
330 - setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getPluginConfig().getCodeGenDir(), 352 +
331 - getJavaFileInfo().getPackageFilePath()));
332 - } else {
333 - setBaseCodePath(getJavaFileInfo().getBaseCodeGenPath());
334 - setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
335 - getJavaFileInfo().getPackageFilePath()));
336 - }
337 /* 353 /*
338 * Initialize getter when generation file type matches to interface 354 * Initialize getter when generation file type matches to interface
339 * mask. 355 * mask.
340 */ 356 */
341 if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) { 357 if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) {
342 addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK); 358 addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK);
359 + addGeneratedTempFile(ADD_TO_LIST_INTERFACE_MASK);
360 + addGeneratedTempFile(LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK);
343 } 361 }
344 362
345 /* 363 /*
...@@ -365,12 +383,13 @@ public class TempJavaFragmentFiles { ...@@ -365,12 +383,13 @@ public class TempJavaFragmentFiles {
365 * Initialize getterImpl, attributes, constructor, hash code, equals and 383 * Initialize getterImpl, attributes, constructor, hash code, equals and
366 * to strings when generation file type matches to impl class mask. 384 * to strings when generation file type matches to impl class mask.
367 */ 385 */
368 - if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) { 386 + if ((getGeneratedJavaFiles() & DEFAULT_CLASS_MASK) != 0) {
369 addGeneratedTempFile(ATTRIBUTES_MASK); 387 addGeneratedTempFile(ATTRIBUTES_MASK);
370 addGeneratedTempFile(GETTER_FOR_CLASS_MASK); 388 addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
371 addGeneratedTempFile(HASH_CODE_IMPL_MASK); 389 addGeneratedTempFile(HASH_CODE_IMPL_MASK);
372 addGeneratedTempFile(EQUALS_IMPL_MASK); 390 addGeneratedTempFile(EQUALS_IMPL_MASK);
373 addGeneratedTempFile(TO_STRING_IMPL_MASK); 391 addGeneratedTempFile(TO_STRING_IMPL_MASK);
392 + addGeneratedTempFile(ADD_TO_LIST_IMPL_MASK);
374 } 393 }
375 394
376 /* 395 /*
...@@ -398,23 +417,18 @@ public class TempJavaFragmentFiles { ...@@ -398,23 +417,18 @@ public class TempJavaFragmentFiles {
398 if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) { 417 if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) {
399 setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME)); 418 setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME));
400 } 419 }
401 -
402 if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) { 420 if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) {
403 setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME)); 421 setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME));
404 } 422 }
405 -
406 if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) { 423 if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) {
407 setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME)); 424 setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME));
408 } 425 }
409 -
410 if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) { 426 if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
411 setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME)); 427 setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME));
412 } 428 }
413 -
414 if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) { 429 if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) {
415 setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME)); 430 setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME));
416 } 431 }
417 -
418 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { 432 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
419 setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME)); 433 setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME));
420 } 434 }
...@@ -427,6 +441,15 @@ public class TempJavaFragmentFiles { ...@@ -427,6 +441,15 @@ public class TempJavaFragmentFiles {
427 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { 441 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
428 setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME)); 442 setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME));
429 } 443 }
444 + if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0) {
445 + setAddToListInterfaceTempFileHandle(getTemporaryFileHandle(ADD_TO_LIST_INTERFACE_METHOD_FILE_NAME));
446 + }
447 + if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0) {
448 + setAddToListImplTempFileHandle(getTemporaryFileHandle(ADD_TO_LIST_IMPL_METHOD_FILE_NAME));
449 + }
450 + if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) {
451 + setLeafIdAttributeTempFileHandle(getTemporaryFileHandle(LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME));
452 + }
430 } 453 }
431 454
432 /** 455 /**
...@@ -457,8 +480,7 @@ public class TempJavaFragmentFiles { ...@@ -457,8 +480,7 @@ public class TempJavaFragmentFiles {
457 480
458 JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode, 481 JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode,
459 parent, isList, tempJavaBeanFragmentFiles); 482 parent, isList, tempJavaBeanFragmentFiles);
460 - 483 + tempJavaBeanFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig);
461 - getNodesInterfaceFragmentFiles(parent, javaAttributeInfo, pluginConfig);
462 } 484 }
463 485
464 /** 486 /**
...@@ -493,20 +515,14 @@ public class TempJavaFragmentFiles { ...@@ -493,20 +515,14 @@ public class TempJavaFragmentFiles {
493 515
494 boolean isQualified; 516 boolean isQualified;
495 if ((tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles) 517 if ((tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles)
496 - && (qualifiedTypeInfo.getClassInfo().contentEquals(SERVICE) 518 + && (qualifiedTypeInfo.getClassInfo().contentEquals(SERVICE))
497 - || qualifiedTypeInfo.getClassInfo().contentEquals(COMPONENT) 519 + || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))) {
498 - || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(ACTIVATE))
499 - || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(DEACTIVATE))
500 - || qualifiedTypeInfo.getClassInfo().contentEquals(REFERENCE_CARDINALITY)
501 - || qualifiedTypeInfo.getClassInfo().contentEquals(REFERENCE))
502 - || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))
503 - || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + MANAGER))) {
504 520
505 isQualified = true; 521 isQualified = true;
506 } else { 522 } else {
507 String className; 523 String className;
508 if (tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles) { 524 if (tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles) {
509 - className = getCapitalCase(fileInfo.getJavaName()) + "Service"; 525 + className = getCapitalCase(fileInfo.getJavaName()) + SERVICE;
510 } else { 526 } else {
511 className = getCapitalCase(fileInfo.getJavaName()); 527 className = getCapitalCase(fileInfo.getJavaName());
512 } 528 }
...@@ -523,33 +539,6 @@ public class TempJavaFragmentFiles { ...@@ -523,33 +539,6 @@ public class TempJavaFragmentFiles {
523 } 539 }
524 540
525 /** 541 /**
526 - * Adds java code snippet for corresponding files.
527 - *
528 - * @param node java node
529 - * @param attr attribute info
530 - * @param config plugin configurations
531 - * @throws IOException when fails to do IO operations
532 - */
533 - private static void getNodesInterfaceFragmentFiles(YangNode node, JavaAttributeInfo attr,
534 - YangPluginConfig config) throws IOException {
535 - TempJavaFragmentFiles tempJavaFragmentFiles;
536 - JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo();
537 - if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_SERVICE_AND_MANAGER) != 0) {
538 - tempJavaFragmentFiles = ((TempJavaCodeFragmentFilesContainer) node)
539 - .getTempJavaCodeFragmentFiles()
540 - .getServiceTempFiles();
541 - tempJavaFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(attr, config);
542 - }
543 - if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_INTERFACE_WITH_BUILDER) != 0) {
544 - tempJavaFragmentFiles = ((TempJavaCodeFragmentFilesContainer) node)
545 - .getTempJavaCodeFragmentFiles()
546 - .getBeanTempFiles();
547 - tempJavaFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(attr, config);
548 - }
549 -
550 - }
551 -
552 - /**
553 * Returns java attribute for leaf. 542 * Returns java attribute for leaf.
554 * 543 *
555 * @param tempJavaFragmentFiles temporary generated file 544 * @param tempJavaFragmentFiles temporary generated file
...@@ -593,42 +582,6 @@ public class TempJavaFragmentFiles { ...@@ -593,42 +582,6 @@ public class TempJavaFragmentFiles {
593 true); 582 true);
594 } 583 }
595 584
596 - /**
597 - * Retrieves the temporary file handle of op param builder class.
598 - *
599 - * @return op param builder temporary file handle
600 - */
601 - private File getBuilderOpParamClassJavaFileHandle() {
602 - return builderOpParamClassJavaFileHandle;
603 - }
604 -
605 - /**
606 - * Sets the java file handle for op param builder class.
607 - *
608 - * @param builderOpParamClassJavaFileHandle java file handle
609 - */
610 - private void setBuilderOpParamClassJavaFileHandle(File builderOpParamClassJavaFileHandle) {
611 - this.builderOpParamClassJavaFileHandle = builderOpParamClassJavaFileHandle;
612 - }
613 -
614 - /**
615 - * Returns base code path.
616 - *
617 - * @return base code path
618 - */
619 - private String getBaseCodePath() {
620 - return baseCodePath;
621 - }
622 -
623 - /**
624 - * Sets base code path.
625 - *
626 - * @param baseCodePath base code path
627 - */
628 - void setBaseCodePath(String baseCodePath) {
629 - this.baseCodePath = baseCodePath;
630 - }
631 -
632 /* 585 /*
633 * Retrieves the absolute path where the file needs to be generated. 586 * Retrieves the absolute path where the file needs to be generated.
634 * 587 *
...@@ -1047,9 +1000,15 @@ public class TempJavaFragmentFiles { ...@@ -1047,9 +1000,15 @@ public class TempJavaFragmentFiles {
1047 */ 1000 */
1048 private void addSetterImpl(JavaAttributeInfo attr) 1001 private void addSetterImpl(JavaAttributeInfo attr)
1049 throws IOException { 1002 throws IOException {
1050 - appendToFile(getSetterImplTempFileHandle(), 1003 + if (isRooNode()) {
1051 - getOverRideString() + getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles()) 1004 + appendToFile(getSetterImplTempFileHandle(),
1052 - + NEW_LINE); 1005 + getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles())
1006 + + NEW_LINE);
1007 + } else {
1008 + appendToFile(getSetterImplTempFileHandle(), getOverRideString() +
1009 + getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles())
1010 + + NEW_LINE);
1011 + }
1053 } 1012 }
1054 1013
1055 /** 1014 /**
...@@ -1063,8 +1022,13 @@ public class TempJavaFragmentFiles { ...@@ -1063,8 +1022,13 @@ public class TempJavaFragmentFiles {
1063 throws IOException { 1022 throws IOException {
1064 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0 1023 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0
1065 || (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) { 1024 || (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) {
1066 - appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr, 1025 + if (!isRooNode()) {
1067 - getGeneratedJavaFiles()) + NEW_LINE); 1026 + appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr,
1027 + getGeneratedJavaFiles()) + NEW_LINE);
1028 + } else {
1029 + appendToFile(getGetterImplTempFileHandle(), getGetterForClass(attr,
1030 + getGeneratedJavaFiles()) + NEW_LINE);
1031 + }
1068 } else { 1032 } else {
1069 appendToFile(getGetterImplTempFileHandle(), 1033 appendToFile(getGetterImplTempFileHandle(),
1070 getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) 1034 getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig)
...@@ -1073,6 +1037,45 @@ public class TempJavaFragmentFiles { ...@@ -1073,6 +1037,45 @@ public class TempJavaFragmentFiles {
1073 } 1037 }
1074 1038
1075 /** 1039 /**
1040 + * Adds add to list interface method.
1041 + *
1042 + * @param attr attribute
1043 + * @param pluginConfig plugin configurations
1044 + * @throws IOException when fails to do IO operations
1045 + */
1046 + private void addAddToListInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) throws IOException {
1047 + appendToFile(getAddToListInterfaceTempFileHandle(),
1048 + getJavaDoc(ADD_TO_LIST, getCapitalCase(attr.getAttributeName()), false, pluginConfig)
1049 + + getAddToListMethodInterface(attr) + NEW_LINE);
1050 + }
1051 +
1052 + /**
1053 + * Adds add to list interface method.
1054 + *
1055 + * @param attr attribute
1056 + * @throws IOException when fails to do IO operations
1057 + */
1058 + private void addAddToListImpl(JavaAttributeInfo attr) throws IOException {
1059 + appendToFile(getAddToListImplTempFileHandle(),
1060 + getAddToListMethodImpl(attr) + NEW_LINE);
1061 + }
1062 +
1063 + /**
1064 + * Adds leaf identifier enum attributes.
1065 + *
1066 + * @param attr attribute
1067 + * @param value value
1068 + * @param yangPluginConfig plugin config
1069 + * @throws IOException when fails to do IO operations
1070 + */
1071 + private void addLeafIdAttributes(JavaAttributeInfo attr, int value, YangPluginConfig yangPluginConfig)
1072 + throws IOException {
1073 + appendToFile(getLeafIdAttributeTempFileHandle(),
1074 + FOUR_SPACE_INDENTATION + generateEnumAttributeString(attr.getAttributeName(),
1075 + value, yangPluginConfig));
1076 + }
1077 +
1078 + /**
1076 * Adds build method for interface. 1079 * Adds build method for interface.
1077 * 1080 *
1078 * @param pluginConfig plugin configurations 1081 * @param pluginConfig plugin configurations
...@@ -1092,7 +1095,7 @@ public class TempJavaFragmentFiles { ...@@ -1092,7 +1095,7 @@ public class TempJavaFragmentFiles {
1092 */ 1095 */
1093 String addBuildMethodImpl() 1096 String addBuildMethodImpl()
1094 throws IOException { 1097 throws IOException {
1095 - return getBuildString(getGeneratedJavaClassName()) + NEW_LINE; 1098 + return getBuildString(getGeneratedJavaClassName(), isRooNode()) + NEW_LINE;
1096 } 1099 }
1097 1100
1098 /** 1101 /**
...@@ -1101,13 +1104,32 @@ public class TempJavaFragmentFiles { ...@@ -1101,13 +1104,32 @@ public class TempJavaFragmentFiles {
1101 * @param modifier modifier for constructor. 1104 * @param modifier modifier for constructor.
1102 * @param toAppend string which need to be appended with the class name 1105 * @param toAppend string which need to be appended with the class name
1103 * @param pluginConfig plugin configurations 1106 * @param pluginConfig plugin configurations
1107 + * @param isSuffix is value need to be appended as suffix
1104 * @return default constructor for class 1108 * @return default constructor for class
1105 * @throws IOException when fails to append to file 1109 * @throws IOException when fails to append to file
1106 */ 1110 */
1107 - String addDefaultConstructor(String modifier, String toAppend, YangPluginConfig pluginConfig) 1111 + String addDefaultConstructor(String modifier, String toAppend, YangPluginConfig pluginConfig, boolean isSuffix)
1108 throws IOException { 1112 throws IOException {
1113 + String name = getGeneratedJavaClassName();
1114 + if (isRooNode() && !toAppend.equals(BUILDER)) {
1115 + name = name + OP_PARAM;
1116 + return NEW_LINE
1117 + + getDefaultConstructorString(name, modifier,
1118 + pluginConfig);
1119 + }
1120 + if (isSuffix) {
1121 + return NEW_LINE +
1122 + getDefaultConstructorString(name + toAppend, modifier, pluginConfig);
1123 + }
1124 + String appended;
1125 + if (toAppend.equals(DEFAULT)) {
1126 + appended = getCapitalCase(toAppend);
1127 + } else {
1128 + appended = toAppend;
1129 + }
1109 return NEW_LINE 1130 return NEW_LINE
1110 - + getDefaultConstructorString(getGeneratedJavaClassName() + toAppend, modifier, pluginConfig); 1131 + + getDefaultConstructorString(appended + name, modifier,
1132 + pluginConfig);
1111 } 1133 }
1112 1134
1113 /** 1135 /**
...@@ -1168,17 +1190,18 @@ public class TempJavaFragmentFiles { ...@@ -1168,17 +1190,18 @@ public class TempJavaFragmentFiles {
1168 throws IOException { 1190 throws IOException {
1169 String path = getTempDirPath(getAbsoluteDirPath()); 1191 String path = getTempDirPath(getAbsoluteDirPath());
1170 File dir = new File(path); 1192 File dir = new File(path);
1193 + boolean isCreated;
1171 if (!dir.exists()) { 1194 if (!dir.exists()) {
1172 - boolean isCreated = dir.mkdirs(); 1195 + isCreated = dir.mkdirs();
1173 if (!isCreated) { 1196 if (!isCreated) {
1174 throw new IOException("failed to create temporary directory for " + fileName); 1197 throw new IOException("failed to create temporary directory for " + fileName);
1175 } 1198 }
1176 } 1199 }
1177 File file = new File(path + fileName + TEMP_FILE_EXTENSION); 1200 File file = new File(path + fileName + TEMP_FILE_EXTENSION);
1178 if (!file.exists()) { 1201 if (!file.exists()) {
1179 - boolean isCreated = file.createNewFile(); 1202 + isCreated = file.createNewFile();
1180 if (!isCreated) { 1203 if (!isCreated) {
1181 - throw new IOException("failed to create temporary files for " + fileName); 1204 + throw new IOException("failed to create temporary file for " + fileName);
1182 } 1205 }
1183 } else { 1206 } else {
1184 throw new IOException(fileName + " is reused due to YANG naming"); 1207 throw new IOException(fileName + " is reused due to YANG naming");
...@@ -1195,7 +1218,7 @@ public class TempJavaFragmentFiles { ...@@ -1195,7 +1218,7 @@ public class TempJavaFragmentFiles {
1195 */ 1218 */
1196 File getJavaFileHandle(String fileName) 1219 File getJavaFileHandle(String fileName)
1197 throws IOException { 1220 throws IOException {
1198 - return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getBaseCodePath()); 1221 + return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getJavaFileInfo());
1199 } 1222 }
1200 1223
1201 /** 1224 /**
...@@ -1246,11 +1269,11 @@ public class TempJavaFragmentFiles { ...@@ -1246,11 +1269,11 @@ public class TempJavaFragmentFiles {
1246 attributeAccessType = PROTECTED; 1269 attributeAccessType = PROTECTED;
1247 } 1270 }
1248 if (attr.isQualifiedName()) { 1271 if (attr.isQualifiedName()) {
1249 - return getJavaAttributeDefination(attr.getImportInfo().getPkgInfo(), 1272 + return getJavaAttributeDefinition(attr.getImportInfo().getPkgInfo(),
1250 attr.getImportInfo().getClassInfo(), 1273 attr.getImportInfo().getClassInfo(),
1251 attributeName, attr.isListAttr(), attributeAccessType); 1274 attributeName, attr.isListAttr(), attributeAccessType);
1252 } else { 1275 } else {
1253 - return getJavaAttributeDefination(null, attr.getImportInfo().getClassInfo(), attributeName, 1276 + return getJavaAttributeDefinition(null, attr.getImportInfo().getClassInfo(), attributeName,
1254 attr.isListAttr(), attributeAccessType); 1277 attr.isListAttr(), attributeAccessType);
1255 } 1278 }
1256 } 1279 }
...@@ -1408,6 +1431,17 @@ public class TempJavaFragmentFiles { ...@@ -1408,6 +1431,17 @@ public class TempJavaFragmentFiles {
1408 if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) { 1431 if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) {
1409 addToStringMethod(newAttrInfo); 1432 addToStringMethod(newAttrInfo);
1410 } 1433 }
1434 + if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0 && newAttrInfo.isListAttr()) {
1435 + addAddToListImpl(newAttrInfo);
1436 + }
1437 + if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0 && newAttrInfo.isListAttr()) {
1438 + addAddToListInterface(newAttrInfo, pluginConfig);
1439 + }
1440 + if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0 && !newAttrInfo.isListAttr()
1441 + && newAttrInfo.getAttributeType() != null) {
1442 + leafCount++;
1443 + addLeafIdAttributes(newAttrInfo, leafCount, pluginConfig);
1444 + }
1411 1445
1412 if (!newAttrInfo.isIntConflict() && 1446 if (!newAttrInfo.isIntConflict() &&
1413 !newAttrInfo.isLongConflict()) { 1447 !newAttrInfo.isLongConflict()) {
...@@ -1445,31 +1479,17 @@ public class TempJavaFragmentFiles { ...@@ -1445,31 +1479,17 @@ public class TempJavaFragmentFiles {
1445 /** 1479 /**
1446 * Returns java class name. 1480 * Returns java class name.
1447 * 1481 *
1482 + * @param node YANG node
1448 * @return java class name 1483 * @return java class name
1449 */ 1484 */
1450 - private String getImplClassName() { 1485 + private String getImplClassName(YangNode node) {
1486 + if (node instanceof YangModule || node instanceof YangSubModule) {
1487 + return getCapitalCase(getJavaFileInfo().getJavaName()) + OP_PARAM;
1488 + }
1451 return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName()); 1489 return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName());
1452 } 1490 }
1453 1491
1454 /** 1492 /**
1455 - * Returns op param java class name.
1456 - *
1457 - * @return op param java class name
1458 - */
1459 - private String getOpParamImplClassName() {
1460 - return getCapitalCase(getJavaFileInfo().getJavaName()) + OPERATION;
1461 - }
1462 -
1463 - /**
1464 - * Returns op param builder java class name.
1465 - *
1466 - * @return op param builder java class name
1467 - */
1468 - private String getOpParamBuilderImplClassName() {
1469 - return getCapitalCase(getJavaFileInfo().getJavaName()) + OPERATION + BUILDER;
1470 - }
1471 -
1472 - /**
1473 * Returns the directory path. 1493 * Returns the directory path.
1474 * 1494 *
1475 * @return directory path 1495 * @return directory path
...@@ -1487,15 +1507,11 @@ public class TempJavaFragmentFiles { ...@@ -1487,15 +1507,11 @@ public class TempJavaFragmentFiles {
1487 */ 1507 */
1488 public void generateJavaFile(int fileType, YangNode curNode) 1508 public void generateJavaFile(int fileType, YangNode curNode)
1489 throws IOException { 1509 throws IOException {
1490 -
1491 - if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
1492 - addResolvedAugmentedDataNodeImports(curNode);
1493 - }
1494 - TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
1495 - .getTempJavaCodeFragmentFiles().getBeanTempFiles();
1496 List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles() 1510 List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles()
1497 .getJavaImportData().getImports(); 1511 .getJavaImportData().getImports();
1498 - 1512 + if (curNode instanceof YangAugmentableNode) {
1513 + addImportsForAugmentableClass(imports, true, true);
1514 + }
1499 createPackage(curNode); 1515 createPackage(curNode);
1500 1516
1501 /* 1517 /*
...@@ -1510,45 +1526,48 @@ public class TempJavaFragmentFiles { ...@@ -1510,45 +1526,48 @@ public class TempJavaFragmentFiles {
1510 setInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(INTERFACE_FILE_NAME_SUFFIX))); 1526 setInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(INTERFACE_FILE_NAME_SUFFIX)));
1511 setInterfaceJavaFileHandle( 1527 setInterfaceJavaFileHandle(
1512 generateInterfaceFile(getInterfaceJavaFileHandle(), imports, curNode, isAttributePresent())); 1528 generateInterfaceFile(getInterfaceJavaFileHandle(), imports, curNode, isAttributePresent()));
1529 + if (!(curNode instanceof YangModule) && !(curNode instanceof YangSubModule)) {
1513 /* 1530 /*
1514 * Create builder interface file. 1531 * Create builder interface file.
1515 */ 1532 */
1516 - if ((fileType & BUILDER_INTERFACE_MASK) != 0) { 1533 + if ((fileType & BUILDER_INTERFACE_MASK) != 0) {
1517 - setBuilderInterfaceJavaFileHandle( 1534 + setBuilderInterfaceJavaFileHandle(
1518 - getJavaFileHandle(getJavaClassName(BUILDER_INTERFACE_FILE_NAME_SUFFIX))); 1535 + getJavaFileHandle(getJavaClassName(BUILDER_INTERFACE_FILE_NAME_SUFFIX)));
1519 - setBuilderInterfaceJavaFileHandle( 1536 + setBuilderInterfaceJavaFileHandle(
1520 - generateBuilderInterfaceFile(getBuilderInterfaceJavaFileHandle(), curNode, 1537 + generateBuilderInterfaceFile(getBuilderInterfaceJavaFileHandle(), curNode,
1521 - isAttributePresent())); 1538 + isAttributePresent()));
1522 /* 1539 /*
1523 * Append builder interface file to interface file and close it. 1540 * Append builder interface file to interface file and close it.
1524 */ 1541 */
1525 - mergeJavaFiles(getBuilderInterfaceJavaFileHandle(), getInterfaceJavaFileHandle()); 1542 + mergeJavaFiles(getBuilderInterfaceJavaFileHandle(), getInterfaceJavaFileHandle());
1526 - validateLineLength(getInterfaceJavaFileHandle()); 1543 + validateLineLength(getInterfaceJavaFileHandle());
1544 + }
1527 } 1545 }
1528 insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose()); 1546 insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose());
1529 1547
1530 if (curNode instanceof YangCase) { 1548 if (curNode instanceof YangCase) {
1531 removeCaseImport(imports); 1549 removeCaseImport(imports);
1532 } 1550 }
1533 - 1551 + if (curNode instanceof YangAugmentableNode) {
1534 - if (curNode instanceof YangAugment) { 1552 + addImportsForAugmentableClass(imports, false, true);
1535 - removeAugmentedInfoImport(imports);
1536 } 1553 }
1537 } 1554 }
1538 - if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & IMPL_CLASS_MASK) != 0) { 1555 + if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & DEFAULT_CLASS_MASK) != 0) {
1539 if (isAttributePresent()) { 1556 if (isAttributePresent()) {
1540 addImportsToStringAndHasCodeMethods(imports, true); 1557 addImportsToStringAndHasCodeMethods(imports, true);
1558 + addArrayListImport(imports);
1541 } 1559 }
1560 + addBitsetImport(imports);
1542 if (curNode instanceof YangAugmentableNode) { 1561 if (curNode instanceof YangAugmentableNode) {
1543 - addImportsForAugmentableClass(imports, true); 1562 + addImportsForAugmentableClass(imports, true, false);
1544 } 1563 }
1545 sortImports(imports); 1564 sortImports(imports);
1546 /* 1565 /*
1547 * Create impl class file. 1566 * Create impl class file.
1548 */ 1567 */
1549 - setImplClassJavaFileHandle(getJavaFileHandle(getImplClassName())); 1568 + setImplClassJavaFileHandle(getJavaFileHandle(getImplClassName(curNode)));
1550 setImplClassJavaFileHandle( 1569 setImplClassJavaFileHandle(
1551 - generateImplClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent(), imports)); 1570 + generateDefaultClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent(), imports));
1552 1571
1553 /* 1572 /*
1554 * Create builder class file. 1573 * Create builder class file.
...@@ -1565,53 +1584,7 @@ public class TempJavaFragmentFiles { ...@@ -1565,53 +1584,7 @@ public class TempJavaFragmentFiles {
1565 validateLineLength(getImplClassJavaFileHandle()); 1584 validateLineLength(getImplClassJavaFileHandle());
1566 } 1585 }
1567 insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose()); 1586 insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose());
1568 - if (curNode instanceof YangAugmentableNode) {
1569 - addImportsForAugmentableClass(imports, false);
1570 - }
1571 - if (!(curNode instanceof YangModule)) {
1572 - if (isAttributePresent()) {
1573 - addImportsToStringAndHasCodeMethods(imports, false);
1574 - }
1575 - if (curNode instanceof YangAugmentableNode) {
1576 - addYangAugmentedOpParamInfoImport(imports);
1577 - }
1578 - JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = new JavaQualifiedTypeInfoTranslator();
1579 - qualifiedTypeInfo.setClassInfo(getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo()
1580 - .getJavaName()));
1581 - qualifiedTypeInfo.setPkgInfo(getJavaFileInfo().getPackage());
1582 - getJavaExtendsListHolder().addToExtendsList(qualifiedTypeInfo, curNode,
1583 - tempJavaBeanFragmentFiles);
1584 - addBitSetImport(imports, true);
1585 - if (curNode instanceof YangAugment) {
1586 - addYangAugmentedOpParamInfoImport(imports);
1587 - }
1588 - /*
1589 - * Create impl class file.
1590 - */
1591 - setOpParamClassJavaFileHandle(getJavaFileHandle(getOpParamImplClassName()));
1592 - setOpParamClassJavaFileHandle(
1593 - generateOpParamImplClassFile(getOpParamClassJavaFileHandle(), curNode,
1594 - isAttributePresent(), imports));
1595 1587
1596 - /*
1597 - * Create builder class file.
1598 - */
1599 - if ((fileType & BUILDER_CLASS_MASK) != 0) {
1600 - setBuilderOpParamClassJavaFileHandle(getJavaFileHandle(getOpParamBuilderImplClassName()));
1601 - setBuilderOpParamClassJavaFileHandle(
1602 - generateOpParamBuilderClassFile(getBuilderOpParamClassJavaFileHandle(), curNode,
1603 - isAttributePresent()));
1604 - /*
1605 - * Append impl class to builder class and close it.
1606 - */
1607 - mergeJavaFiles(getBuilderOpParamClassJavaFileHandle(), getOpParamClassJavaFileHandle());
1608 - validateLineLength(getOpParamClassJavaFileHandle());
1609 -
1610 - addBitSetImport(imports, false);
1611 - }
1612 - insertDataIntoJavaFile(getOpParamClassJavaFileHandle(), getJavaClassDefClose());
1613 -
1614 - }
1615 } 1588 }
1616 /* 1589 /*
1617 * Close all the file handles. 1590 * Close all the file handles.
...@@ -1619,9 +1592,16 @@ public class TempJavaFragmentFiles { ...@@ -1619,9 +1592,16 @@ public class TempJavaFragmentFiles {
1619 freeTemporaryResources(false); 1592 freeTemporaryResources(false);
1620 } 1593 }
1621 1594
1622 - /*Adds import for YANG augmented op param info.*/ 1595 + /*Adds import for array list.*/
1623 - private void addYangAugmentedOpParamInfoImport(List<String> imports) { 1596 + private void addArrayListImport(List<String> imports) {
1624 - imports.add(getJavaImportData().getYangAugmentedOpParamInfoImport()); 1597 + if (imports.contains(getJavaImportData().getImportForList())) {
1598 + imports.add(ARRAY_LIST_IMPORT);
1599 + }
1600 + }
1601 +
1602 + /*Adds import for bitset list.*/
1603 + private void addBitsetImport(List<String> imports) {
1604 + imports.add(getJavaImportData().getImportForToBitSet());
1625 } 1605 }
1626 1606
1627 /** 1607 /**
...@@ -1641,35 +1621,26 @@ public class TempJavaFragmentFiles { ...@@ -1641,35 +1621,26 @@ public class TempJavaFragmentFiles {
1641 } 1621 }
1642 1622
1643 /** 1623 /**
1644 - * Adds imports for bitSet method.
1645 - *
1646 - * @param imports import list
1647 - * @param operation add or remove
1648 - */
1649 - private void addBitSetImport(List<String> imports, boolean operation) {
1650 - if (operation) {
1651 - imports.add(getJavaImportData().getImportForToBitSet());
1652 - } else {
1653 - imports.remove(getJavaImportData().getImportForToBitSet());
1654 - }
1655 - }
1656 -
1657 -
1658 - /**
1659 * Adds import for map and hash map. 1624 * Adds import for map and hash map.
1660 * 1625 *
1661 - * @param imports import list 1626 + * @param imports import list
1662 - * @param operations true for adding and false for deletion 1627 + * @param operations true for adding and false for deletion
1628 + * @param isInterfaceFile if need to add in interface file
1663 */ 1629 */
1664 - private void addImportsForAugmentableClass(List<String> imports, boolean operations) { 1630 + private void addImportsForAugmentableClass(List<String> imports, boolean operations, boolean isInterfaceFile) {
1665 if (operations) { 1631 if (operations) {
1666 - imports.add(getJavaImportData().getHashMapImport()); 1632 + if (!isInterfaceFile) {
1633 + imports.add(getJavaImportData().getHashMapImport());
1634 + }
1667 imports.add(getJavaImportData().getMapImport()); 1635 imports.add(getJavaImportData().getMapImport());
1668 - imports.add(getJavaImportData().getYangAugmentedInfoImport()); 1636 + addInvocationExceptionImport(imports);
1669 } else { 1637 } else {
1670 - imports.remove(getJavaImportData().getHashMapImport()); 1638 + if (!isInterfaceFile) {
1639 + imports.remove(getJavaImportData().getHashMapImport());
1640 + }
1671 imports.remove(getJavaImportData().getMapImport()); 1641 imports.remove(getJavaImportData().getMapImport());
1672 } 1642 }
1643 + sortImports(imports);
1673 } 1644 }
1674 1645
1675 /** 1646 /**
...@@ -1688,18 +1659,12 @@ public class TempJavaFragmentFiles { ...@@ -1688,18 +1659,12 @@ public class TempJavaFragmentFiles {
1688 } 1659 }
1689 1660
1690 /** 1661 /**
1691 - * Removes case import info from import list. 1662 + * Adds invocation exception import.
1692 * 1663 *
1693 * @param imports list of imports 1664 * @param imports list of imports
1694 */ 1665 */
1695 - private void removeAugmentedInfoImport(List<String> imports) { 1666 + private void addInvocationExceptionImport(List<String> imports) {
1696 - imports.remove(getJavaImportData().getYangAugmentedInfoImport()); 1667 + imports.add(INVOCATION_TARGET_EXCEPTION_IMPORT);
1697 - for (JavaQualifiedTypeInfoTranslator type : getJavaImportData().getImportSet()) {
1698 - if (type.getClassInfo().equals(YANG_AUGMENTED_INFO)) {
1699 - getJavaImportData().getImportSet().remove(type);
1700 - getJavaExtendsListHolder().getExtendsList().remove(type);
1701 - }
1702 - }
1703 } 1668 }
1704 1669
1705 /** 1670 /**
...@@ -1719,13 +1684,10 @@ public class TempJavaFragmentFiles { ...@@ -1719,13 +1684,10 @@ public class TempJavaFragmentFiles {
1719 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { 1684 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) {
1720 closeFile(getBuilderClassJavaFileHandle(), true); 1685 closeFile(getBuilderClassJavaFileHandle(), true);
1721 } 1686 }
1722 - if ((getGeneratedJavaFiles() & OPERATION_BUILDER_CLASS_MASK) != 0) {
1723 - closeFile(getBuilderOpParamClassJavaFileHandle(), true);
1724 - }
1725 if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) { 1687 if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) {
1726 closeFile(getBuilderInterfaceJavaFileHandle(), true); 1688 closeFile(getBuilderInterfaceJavaFileHandle(), true);
1727 } 1689 }
1728 - if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) { 1690 + if ((getGeneratedJavaFiles() & DEFAULT_CLASS_MASK) != 0) {
1729 closeFile(getImplClassJavaFileHandle(), isErrorOccurred); 1691 closeFile(getImplClassJavaFileHandle(), isErrorOccurred);
1730 } 1692 }
1731 1693
...@@ -1750,6 +1712,15 @@ public class TempJavaFragmentFiles { ...@@ -1750,6 +1712,15 @@ public class TempJavaFragmentFiles {
1750 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { 1712 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
1751 closeFile(getFromStringImplTempFileHandle(), true); 1713 closeFile(getFromStringImplTempFileHandle(), true);
1752 } 1714 }
1715 + if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0) {
1716 + closeFile(getAddToListImplTempFileHandle(), true);
1717 + }
1718 + if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0) {
1719 + closeFile(getAddToListInterfaceTempFileHandle(), true);
1720 + }
1721 + if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) {
1722 + closeFile(getLeafIdAttributeTempFileHandle(), true);
1723 + }
1753 } 1724 }
1754 1725
1755 /** 1726 /**
...@@ -1767,20 +1738,74 @@ public class TempJavaFragmentFiles { ...@@ -1767,20 +1738,74 @@ public class TempJavaFragmentFiles {
1767 } 1738 }
1768 1739
1769 /** 1740 /**
1770 - * Returns java file handle for op param class file. 1741 + * Returns temp file handle for add to list interface.
1742 + *
1743 + * @return temp file handle for add to list interface
1744 + */
1745 + public File getAddToListInterfaceTempFileHandle() {
1746 + return addToListInterfaceTempFileHandle;
1747 + }
1748 +
1749 + /**
1750 + * Sets temp file handle for add to list interface.
1751 + *
1752 + * @param addToListInterfaceTempFileHandle temp file handle for add to list interface
1753 + */
1754 + private void setAddToListInterfaceTempFileHandle(File addToListInterfaceTempFileHandle) {
1755 + this.addToListInterfaceTempFileHandle = addToListInterfaceTempFileHandle;
1756 + }
1757 +
1758 + /**
1759 + * Returns temp file handle for add to list impl.
1760 + *
1761 + * @return temp file handle for add to list impl
1762 + */
1763 + public File getAddToListImplTempFileHandle() {
1764 + return addToListImplTempFileHandle;
1765 + }
1766 +
1767 + /**
1768 + * Sets temp file handle for add to list impl.
1769 + *
1770 + * @param addToListImplTempFileHandle temp file handle for add to list impl
1771 + */
1772 + private void setAddToListImplTempFileHandle(File addToListImplTempFileHandle) {
1773 + this.addToListImplTempFileHandle = addToListImplTempFileHandle;
1774 + }
1775 +
1776 + /**
1777 + * Returns temp file handle for leaf identifier attributes.
1778 + *
1779 + * @return temp file handle for leaf identifier attributes
1780 + */
1781 + public File getLeafIdAttributeTempFileHandle() {
1782 + return leafIdAttributeTempFileHandle;
1783 + }
1784 +
1785 + /**
1786 + * Sets temp file handle for leaf identifier attributes.
1787 + *
1788 + * @param leafIdAttributeTempFileHandle temp file handle for leaf identifier attributes.
1789 + */
1790 + private void setLeafIdAttributeTempFileHandle(File leafIdAttributeTempFileHandle) {
1791 + this.leafIdAttributeTempFileHandle = leafIdAttributeTempFileHandle;
1792 + }
1793 +
1794 + /**
1795 + * Returns if root node is set.
1771 * 1796 *
1772 - * @return java file handle for op param class file 1797 + * @return true if root node
1773 */ 1798 */
1774 - private File getOpParamClassJavaFileHandle() { 1799 + private boolean isRooNode() {
1775 - return opParamClassJavaFileHandle; 1800 + return isRooNode;
1776 } 1801 }
1777 1802
1778 /** 1803 /**
1779 - * Sets the java file handle for op param class file. 1804 + * Sets true if root node.
1780 * 1805 *
1781 - * @param opParamClassJavaFileHandle java file handle 1806 + * @param rooNode true if root node
1782 */ 1807 */
1783 - private void setOpParamClassJavaFileHandle(File opParamClassJavaFileHandle) { 1808 + public void setRooNode(boolean rooNode) {
1784 - this.opParamClassJavaFileHandle = opParamClassJavaFileHandle; 1809 + isRooNode = rooNode;
1785 } 1810 }
1786 } 1811 }
......
...@@ -22,23 +22,20 @@ import java.util.List; ...@@ -22,23 +22,20 @@ import java.util.List;
22 22
23 import org.onosproject.yangutils.datamodel.YangNode; 23 import org.onosproject.yangutils.datamodel.YangNode;
24 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 24 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
25 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
25 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModuleTranslator; 26 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModuleTranslator;
26 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModuleTranslator; 27 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModuleTranslator;
27 import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; 28 import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
28 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
29 29
30 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK; 30 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK;
31 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK; 31 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK;
32 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAnnotationsImports;
33 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addListenersImport; 32 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addListenersImport;
34 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
35 -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile;
36 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile; 33 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile;
34 +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports;
37 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 35 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
38 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; 36 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod;
39 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; 37 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod;
40 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 38 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
41 -import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_REG;
42 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; 39 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE;
43 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 40 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
44 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; 41 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
...@@ -47,7 +44,6 @@ import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; ...@@ -47,7 +44,6 @@ import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
47 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc; 44 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc;
48 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; 45 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
49 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 46 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
50 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
51 47
52 /** 48 /**
53 * Represents implementation of java service code fragments temporary implementations. Maintains the temp files required 49 * Represents implementation of java service code fragments temporary implementations. Maintains the temp files required
...@@ -72,16 +68,6 @@ public class TempJavaServiceFragmentFiles ...@@ -72,16 +68,6 @@ public class TempJavaServiceFragmentFiles
72 private static final String SERVICE_FILE_NAME_SUFFIX = "Service"; 68 private static final String SERVICE_FILE_NAME_SUFFIX = "Service";
73 69
74 /** 70 /**
75 - * File name for generated class file for manager suffix.
76 - */
77 - private static final String MANAGER_FILE_NAME_SUFFIX = "Manager";
78 -
79 - /**
80 - * Flag to set the manager files generation.
81 - */
82 - private boolean isManagerNeedToBeGenerated = false;
83 -
84 - /**
85 * Temporary file handle for rpc interface. 71 * Temporary file handle for rpc interface.
86 */ 72 */
87 private File rpcInterfaceTempFileHandle; 73 private File rpcInterfaceTempFileHandle;
...@@ -97,16 +83,6 @@ public class TempJavaServiceFragmentFiles ...@@ -97,16 +83,6 @@ public class TempJavaServiceFragmentFiles
97 private File serviceInterfaceJavaFileHandle; 83 private File serviceInterfaceJavaFileHandle;
98 84
99 /** 85 /**
100 - * Path for service file to be generated.
101 - */
102 - private String serviceGenPath;
103 -
104 - /**
105 - * Java file handle for manager impl file.
106 - */
107 - private File managerJavaFileHandle;
108 -
109 - /**
110 * Creates an instance of temporary java code fragment. 86 * Creates an instance of temporary java code fragment.
111 * 87 *
112 * @param javaFileInfo generated file information 88 * @param javaFileInfo generated file information
...@@ -117,8 +93,6 @@ public class TempJavaServiceFragmentFiles ...@@ -117,8 +93,6 @@ public class TempJavaServiceFragmentFiles
117 setJavaExtendsListHolder(new JavaExtendsListHolder()); 93 setJavaExtendsListHolder(new JavaExtendsListHolder());
118 setJavaImportData(new JavaImportData()); 94 setJavaImportData(new JavaImportData());
119 setJavaFileInfo(javaFileInfo); 95 setJavaFileInfo(javaFileInfo);
120 - setBaseCodePath(getJavaFileInfo().getBaseCodeGenPath());
121 - setServiceGenPath(getJavaFileInfo().getPluginConfig().getCodeGenDir());
122 setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(), 96 setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
123 getJavaFileInfo().getPackageFilePath())); 97 getJavaFileInfo().getPackageFilePath()));
124 addGeneratedTempFile(RPC_INTERFACE_MASK); 98 addGeneratedTempFile(RPC_INTERFACE_MASK);
...@@ -147,24 +121,6 @@ public class TempJavaServiceFragmentFiles ...@@ -147,24 +121,6 @@ public class TempJavaServiceFragmentFiles
147 } 121 }
148 122
149 /** 123 /**
150 - * Returns managers java file handle.
151 - *
152 - * @return java file handle
153 - */
154 - private File getManagerJavaFileHandle() {
155 - return managerJavaFileHandle;
156 - }
157 -
158 - /**
159 - * Sets manager java file handle.
160 - *
161 - * @param managerJavaFileHandle file handle for to manager
162 - */
163 - private void setManagerJavaFileHandle(File managerJavaFileHandle) {
164 - this.managerJavaFileHandle = managerJavaFileHandle;
165 - }
166 -
167 - /**
168 * Returns rpc method's temporary file handle. 124 * Returns rpc method's temporary file handle.
169 * 125 *
170 * @return temporary file handle 126 * @return temporary file handle
...@@ -210,6 +166,8 @@ public class TempJavaServiceFragmentFiles ...@@ -210,6 +166,8 @@ public class TempJavaServiceFragmentFiles
210 @Override 166 @Override
211 public void generateJavaFile(int fileType, YangNode curNode) 167 public void generateJavaFile(int fileType, YangNode curNode)
212 throws IOException { 168 throws IOException {
169 +
170 + addResolvedAugmentedDataNodeImports(curNode);
213 List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() 171 List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles()
214 .getJavaImportData().getImports(); 172 .getJavaImportData().getImports();
215 createPackage(curNode); 173 createPackage(curNode);
...@@ -228,28 +186,8 @@ public class TempJavaServiceFragmentFiles ...@@ -228,28 +186,8 @@ public class TempJavaServiceFragmentFiles
228 addListenersImport(curNode, imports, true, LISTENER_SERVICE); 186 addListenersImport(curNode, imports, true, LISTENER_SERVICE);
229 } 187 }
230 188
231 - // Creates rpc interface file.
232 - setBaseCodePath(getServiceGenPath());
233 setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX))); 189 setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX)));
234 generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports); 190 generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports);
235 - setBaseCodePath(getJavaFileInfo().getBaseCodeGenPath());
236 - if (isNotification) {
237 - addListenersImport(curNode, imports, false, LISTENER_SERVICE);
238 - addListenersImport(curNode, imports, true, LISTENER_REG);
239 - }
240 - addAnnotationsImports(imports, true);
241 -
242 - // Create builder class file.
243 - if (isManagerNeedToBeGenerated()) {
244 - setManagerJavaFileHandle(getJavaFileHandle(getJavaClassName(MANAGER_FILE_NAME_SUFFIX)));
245 - generateManagerClassFile(getManagerJavaFileHandle(), imports, curNode);
246 - insertDataIntoJavaFile(getManagerJavaFileHandle(), getJavaClassDefClose());
247 - }
248 - if (isNotification) {
249 - addListenersImport(curNode, imports, false, LISTENER_REG);
250 - }
251 - addAnnotationsImports(imports, false);
252 -
253 191
254 // Close all the file handles. 192 // Close all the file handles.
255 freeTemporaryResources(false); 193 freeTemporaryResources(false);
...@@ -314,7 +252,6 @@ public class TempJavaServiceFragmentFiles ...@@ -314,7 +252,6 @@ public class TempJavaServiceFragmentFiles
314 throws IOException { 252 throws IOException {
315 253
316 closeFile(getServiceInterfaceJavaFileHandle(), isErrorOccurred); 254 closeFile(getServiceInterfaceJavaFileHandle(), isErrorOccurred);
317 - closeFile(getManagerJavaFileHandle(), isErrorOccurred);
318 255
319 closeFile(getRpcInterfaceTempFileHandle(), true); 256 closeFile(getRpcInterfaceTempFileHandle(), true);
320 closeFile(getRpcImplTempFileHandle(), true); 257 closeFile(getRpcImplTempFileHandle(), true);
...@@ -325,41 +262,4 @@ public class TempJavaServiceFragmentFiles ...@@ -325,41 +262,4 @@ public class TempJavaServiceFragmentFiles
325 super.freeTemporaryResources(isErrorOccurred); 262 super.freeTemporaryResources(isErrorOccurred);
326 263
327 } 264 }
328 -
329 - /**
330 - * Returns the path where service file should be generated.
331 - *
332 - * @return path where service file should be generated
333 - */
334 - private String getServiceGenPath() {
335 - return serviceGenPath;
336 - }
337 -
338 - /**
339 - * Sets path where service file should be generated.
340 - *
341 - * @param serviceGenPath path where service file should be generated
342 - */
343 - private void setServiceGenPath(String serviceGenPath) {
344 - this.serviceGenPath = serviceGenPath;
345 - }
346 -
347 - /**
348 - * Returns true if manager needs to be generated.
349 - *
350 - * @return true if manager needs to be generated
351 - */
352 - private boolean isManagerNeedToBeGenerated() {
353 - return isManagerNeedToBeGenerated;
354 - }
355 -
356 - /**
357 - * Sets true if manager needs to be generated.
358 - *
359 - * @param managerNeedToBeGenerated true if manager needs to be generated
360 - */
361 - public void setManagerNeedToBeGenerated(boolean managerNeedToBeGenerated) {
362 - isManagerNeedToBeGenerated = managerNeedToBeGenerated;
363 - }
364 -
365 } 265 }
......
...@@ -36,16 +36,9 @@ import org.onosproject.yangutils.datamodel.YangUnion; ...@@ -36,16 +36,9 @@ import org.onosproject.yangutils.datamodel.YangUnion;
36 import org.onosproject.yangutils.datamodel.YangUses; 36 import org.onosproject.yangutils.datamodel.YangUses;
37 import org.onosproject.yangutils.datamodel.utils.GeneratedLanguage; 37 import org.onosproject.yangutils.datamodel.utils.GeneratedLanguage;
38 import org.onosproject.yangutils.translator.exception.TranslatorException; 38 import org.onosproject.yangutils.translator.exception.TranslatorException;
39 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugmentTranslator;
40 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCaseTranslator;
41 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoiceTranslator; 39 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoiceTranslator;
42 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainerTranslator; 40 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainerTranslator;
43 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumerationTranslator; 41 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumerationTranslator;
44 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGroupingTranslator;
45 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaIdentityTranslator;
46 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInputTranslator;
47 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeafTranslator;
48 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeafListTranslator;
49 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaListTranslator; 42 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaListTranslator;
50 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModuleTranslator; 43 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModuleTranslator;
51 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotificationTranslator; 44 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotificationTranslator;
...@@ -56,6 +49,13 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeTransla ...@@ -56,6 +49,13 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeTransla
56 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDefTranslator; 49 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDefTranslator;
57 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnionTranslator; 50 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnionTranslator;
58 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUsesTranslator; 51 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUsesTranslator;
52 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugmentTranslator;
53 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCaseTranslator;
54 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGroupingTranslator;
55 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaIdentityTranslator;
56 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInputTranslator;
57 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeafTranslator;
58 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeafListTranslator;
59 59
60 /** 60 /**
61 * Represents factory to create data model objects based on the target file type. 61 * Represents factory to create data model objects based on the target file type.
......
...@@ -16,18 +16,20 @@ ...@@ -16,18 +16,20 @@
16 16
17 package org.onosproject.yangutils.translator.tojava; 17 package org.onosproject.yangutils.translator.tojava;
18 18
19 -import java.io.File;
20 import java.io.IOException; 19 import java.io.IOException;
21 import java.util.ArrayList; 20 import java.util.ArrayList;
22 import java.util.List; 21 import java.util.List;
23 22
24 import org.onosproject.yangutils.datamodel.RpcNotificationContainer; 23 import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
24 +import org.onosproject.yangutils.datamodel.YangAtomicPath;
25 import org.onosproject.yangutils.datamodel.YangAugment; 25 import org.onosproject.yangutils.datamodel.YangAugment;
26 import org.onosproject.yangutils.datamodel.YangCase; 26 import org.onosproject.yangutils.datamodel.YangCase;
27 import org.onosproject.yangutils.datamodel.YangChoice; 27 import org.onosproject.yangutils.datamodel.YangChoice;
28 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 28 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
29 +import org.onosproject.yangutils.datamodel.YangModule;
29 import org.onosproject.yangutils.datamodel.YangNode; 30 import org.onosproject.yangutils.datamodel.YangNode;
30 import org.onosproject.yangutils.datamodel.YangNodeIdentifier; 31 import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
32 +import org.onosproject.yangutils.datamodel.YangSubModule;
31 import org.onosproject.yangutils.datamodel.YangTranslatorOperatorNode; 33 import org.onosproject.yangutils.datamodel.YangTranslatorOperatorNode;
32 import org.onosproject.yangutils.datamodel.YangTypeHolder; 34 import org.onosproject.yangutils.datamodel.YangTypeHolder;
33 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 35 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
...@@ -44,13 +46,11 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -44,13 +46,11 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
44 import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile; 46 import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile;
45 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 47 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
46 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED; 48 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
47 -import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
48 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 49 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
49 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
50 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG;
51 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 50 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
52 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 51 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
53 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; 52 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
53 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
54 54
55 /** 55 /**
56 * Represents utility class for YANG java model. 56 * Represents utility class for YANG java model.
...@@ -74,19 +74,62 @@ public final class YangJavaModelUtils { ...@@ -74,19 +74,62 @@ public final class YangJavaModelUtils {
74 YangPluginConfig yangPluginConfig) 74 YangPluginConfig yangPluginConfig)
75 throws IOException { 75 throws IOException {
76 if (javaCodeGeneratorInfo instanceof YangJavaAugmentTranslator) { 76 if (javaCodeGeneratorInfo instanceof YangJavaAugmentTranslator) {
77 - javaCodeGeneratorInfo.getJavaFileInfo() 77 + updatePackageForAugmentInfo(javaCodeGeneratorInfo, yangPluginConfig);
78 - .setJavaName(getAugmentClassName((YangJavaAugmentTranslator) javaCodeGeneratorInfo,
79 - yangPluginConfig));
80 } else { 78 } else {
81 javaCodeGeneratorInfo.getJavaFileInfo() 79 javaCodeGeneratorInfo.getJavaFileInfo()
82 .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), 80 .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(),
83 yangPluginConfig.getConflictResolver())); 81 yangPluginConfig.getConflictResolver()));
82 + javaCodeGeneratorInfo.getJavaFileInfo().setPackage(getCurNodePackage((YangNode) javaCodeGeneratorInfo));
84 } 83 }
85 - javaCodeGeneratorInfo.getJavaFileInfo().setPackage(getCurNodePackage((YangNode) javaCodeGeneratorInfo));
86 javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath( 84 javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath(
87 getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage())); 85 getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage()));
86 +
88 javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(yangPluginConfig.getCodeGenDir()); 87 javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(yangPluginConfig.getCodeGenDir());
89 javaCodeGeneratorInfo.getJavaFileInfo().setPluginConfig(yangPluginConfig); 88 javaCodeGeneratorInfo.getJavaFileInfo().setPluginConfig(yangPluginConfig);
89 +
90 + }
91 +
92 + /**
93 + * Updates YANG java file package information.
94 + *
95 + * @param javaCodeGeneratorInfo YANG java file info node
96 + * @param yangPluginConfig YANG plugin config
97 + * @throws IOException IO operations fails
98 + */
99 + private static void updatePackageForAugmentInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
100 + YangPluginConfig yangPluginConfig)
101 + throws IOException {
102 + javaCodeGeneratorInfo.getJavaFileInfo()
103 + .setJavaName(getAugmentClassName((YangJavaAugmentTranslator) javaCodeGeneratorInfo,
104 + yangPluginConfig));
105 + javaCodeGeneratorInfo.getJavaFileInfo().setPackage(
106 + getAugmentsNodePackage((YangNode) javaCodeGeneratorInfo, yangPluginConfig));
107 + javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath(
108 + getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage()));
109 + javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(yangPluginConfig.getCodeGenDir());
110 + javaCodeGeneratorInfo.getJavaFileInfo().setPluginConfig(yangPluginConfig);
111 + }
112 +
113 + /**
114 + * Returns package for augment node.
115 + *
116 + * @param yangNode augment node
117 + * @param yangPluginConfig plugin configurations
118 + * @return package for augment node
119 + */
120 + private static String getAugmentsNodePackage(YangNode yangNode, YangPluginConfig yangPluginConfig) {
121 + YangAugment augment = (YangAugment) yangNode;
122 + StringBuilder augmentPkg = new StringBuilder();
123 + augmentPkg.append(getCurNodePackage(augment));
124 +
125 + String pkg = PERIOD;
126 + for (YangAtomicPath atomicPath : augment.getTargetNode()) {
127 + pkg = pkg + getCamelCase(atomicPath.getNodeIdentifier().getName(), yangPluginConfig.getConflictResolver())
128 + + PERIOD;
129 + }
130 + pkg = trimAtLast(pkg, PERIOD);
131 + augmentPkg.append(pkg.toLowerCase());
132 + return augmentPkg.toString();
90 } 133 }
91 134
92 /** 135 /**
...@@ -104,7 +147,7 @@ public final class YangJavaModelUtils { ...@@ -104,7 +147,7 @@ public final class YangJavaModelUtils {
104 javaCodeGeneratorInfo.getJavaFileInfo().setPackage(pkg); 147 javaCodeGeneratorInfo.getJavaFileInfo().setPackage(pkg);
105 javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath( 148 javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath(
106 getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage())); 149 getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage()));
107 - javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getManagerCodeGenDir()); 150 + javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getCodeGenDir());
108 javaCodeGeneratorInfo.getJavaFileInfo().setPluginConfig(yangPlugin); 151 javaCodeGeneratorInfo.getJavaFileInfo().setPluginConfig(yangPlugin);
109 } 152 }
110 153
...@@ -129,6 +172,12 @@ public final class YangJavaModelUtils { ...@@ -129,6 +172,12 @@ public final class YangJavaModelUtils {
129 private static void updateTempFragmentFiles(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 172 private static void updateTempFragmentFiles(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
130 YangPluginConfig yangPluginConfig) 173 YangPluginConfig yangPluginConfig)
131 throws IOException { 174 throws IOException {
175 +
176 + if (javaCodeGeneratorInfo instanceof YangModule
177 + || javaCodeGeneratorInfo instanceof YangSubModule) {
178 + javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().setRooNode(true);
179 + }
180 +
132 if (javaCodeGeneratorInfo instanceof RpcNotificationContainer) { 181 if (javaCodeGeneratorInfo instanceof RpcNotificationContainer) {
133 /* 182 /*
134 * Module / sub module node code generation. 183 * Module / sub module node code generation.
...@@ -268,20 +317,23 @@ public final class YangJavaModelUtils { ...@@ -268,20 +317,23 @@ public final class YangJavaModelUtils {
268 317
269 generateCodeOfNode(javaCodeGeneratorInfo, yangPlugin); 318 generateCodeOfNode(javaCodeGeneratorInfo, yangPlugin);
270 TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles(); 319 TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles();
271 - if (javaCodeGeneratorInfo instanceof YangJavaAugmentTranslator) {
272 320
273 - JavaQualifiedTypeInfoTranslator yangAugmentedInfo = new JavaQualifiedTypeInfoTranslator();
274 - yangAugmentedInfo.setClassInfo(YANG_AUGMENTED_INFO);
275 - yangAugmentedInfo.setPkgInfo(YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG);
276 - javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder()
277 - .addToExtendsList(yangAugmentedInfo, (YangNode) javaCodeGeneratorInfo,
278 - tempJavaCodeFragmentFiles.getBeanTempFiles());
279 - }
280 if (javaCodeGeneratorInfo instanceof YangCase) { 321 if (javaCodeGeneratorInfo instanceof YangCase) {
281 YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent(); 322 YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent();
323 + if (parent instanceof YangAugment) {
324 + parent = ((YangAugment) parent).getAugmentedNode();
325 + }
282 JavaQualifiedTypeInfoTranslator parentsInfo = new JavaQualifiedTypeInfoTranslator(); 326 JavaQualifiedTypeInfoTranslator parentsInfo = new JavaQualifiedTypeInfoTranslator();
283 - String parentName = getCapitalCase(((JavaFileInfoContainer) parent).getJavaFileInfo().getJavaName()); 327 + JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
284 - String parentPkg = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage(); 328 + String parentName;
329 + String parentPkg;
330 + if (parentInfo.getPackage() != null) {
331 + parentName = getCapitalCase(((JavaFileInfoContainer) parent).getJavaFileInfo().getJavaName());
332 + parentPkg = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage();
333 + } else {
334 + parentName = getCapitalCase(getCamelCase(parent.getName(), yangPlugin.getConflictResolver()));
335 + parentPkg = getNodesPackage(parent, yangPlugin);
336 + }
285 parentsInfo.setClassInfo(parentName); 337 parentsInfo.setClassInfo(parentName);
286 parentsInfo.setPkgInfo(parentPkg); 338 parentsInfo.setPkgInfo(parentPkg);
287 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() 339 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder()
...@@ -363,17 +415,18 @@ public final class YangJavaModelUtils { ...@@ -363,17 +415,18 @@ public final class YangJavaModelUtils {
363 * @param node root YANG node 415 * @param node root YANG node
364 * @return true if root node contains any data node 416 * @return true if root node contains any data node
365 */ 417 */
366 - public static boolean isManagerCodeGenRequired(YangNode node) { 418 + public static boolean isRootNodesCodeGenRequired(YangNode node) {
367 419
368 List<YangNode> childNodes = new ArrayList<>(); 420 List<YangNode> childNodes = new ArrayList<>();
369 - node = node.getChild(); 421 + YangNode tempNode = node.getChild();
370 - while (node != null) { 422 + while (tempNode != null) {
371 - childNodes.add(node); 423 + childNodes.add(tempNode);
372 - node = node.getNextSibling(); 424 + tempNode = tempNode.getNextSibling();
373 } 425 }
374 426
375 if (childNodes.size() == 0) { 427 if (childNodes.size() == 0) {
376 - return false; 428 + YangLeavesHolder leavesHolder = (YangLeavesHolder) node;
429 + return !leavesHolder.getListOfLeaf().isEmpty() || !leavesHolder.getListOfLeafList().isEmpty();
377 } else if (childNodes.size() == 1) { 430 } else if (childNodes.size() == 1) {
378 return !(childNodes.get(0) instanceof YangTranslatorOperatorNode); 431 return !(childNodes.get(0) instanceof YangTranslatorOperatorNode);
379 } 432 }
...@@ -389,33 +442,13 @@ public final class YangJavaModelUtils { ...@@ -389,33 +442,13 @@ public final class YangJavaModelUtils {
389 } 442 }
390 443
391 /** 444 /**
392 - * Return false if files are already present. 445 + * Returns nodes package.
393 * 446 *
394 - * @param info java file info 447 + * @param node YANG node
395 - * @return false if files already present
396 - */
397 - public static boolean isGenerationOfCodeReq(JavaFileInfo info) {
398 - File codeGenDir = new File(info.getBaseCodeGenPath()
399 - + info.getPackageFilePath());
400 - File[] files = codeGenDir.listFiles();
401 - if (files != null && files.length >= 1) {
402 - for (File file : files) {
403 - if (file.getName().contentEquals(getCapitalCase(info.getJavaName() + MANAGER + ".java"))) {
404 - return false;
405 - }
406 - }
407 - }
408 - return true;
409 - }
410 -
411 - /**
412 - * Returns augmented nodes package.
413 - *
414 - * @param node augmented node
415 * @param yangPluginConfig plugin config 448 * @param yangPluginConfig plugin config
416 * @return java package 449 * @return java package
417 */ 450 */
418 - public static String getAugmentedNodesPackage(YangNode node, YangPluginConfig yangPluginConfig) { 451 + public static String getNodesPackage(YangNode node, YangPluginConfig yangPluginConfig) {
419 452
420 List<String> clsInfo = new ArrayList<>(); 453 List<String> clsInfo = new ArrayList<>();
421 while (node.getParent() != null) { 454 while (node.getParent() != null) {
...@@ -424,7 +457,6 @@ public final class YangJavaModelUtils { ...@@ -424,7 +457,6 @@ public final class YangJavaModelUtils {
424 } else { 457 } else {
425 clsInfo.add(getCamelCase(node.getName(), yangPluginConfig.getConflictResolver())); 458 clsInfo.add(getCamelCase(node.getName(), yangPluginConfig.getConflictResolver()));
426 } 459 }
427 -
428 node = node.getParent(); 460 node = node.getParent();
429 } 461 }
430 462
...@@ -434,10 +466,10 @@ public final class YangJavaModelUtils { ...@@ -434,10 +466,10 @@ public final class YangJavaModelUtils {
434 pkg.append(getRootPackage(module.getVersion(), module.getNameSpace().getUri(), module 466 pkg.append(getRootPackage(module.getVersion(), module.getNameSpace().getUri(), module
435 .getRevision().getRevDate(), yangPluginConfig.getConflictResolver())); 467 .getRevision().getRevDate(), yangPluginConfig.getConflictResolver()));
436 } else if (node instanceof YangJavaSubModuleTranslator) { 468 } else if (node instanceof YangJavaSubModuleTranslator) {
437 - YangJavaSubModuleTranslator submodule = (YangJavaSubModuleTranslator) node; 469 + YangJavaSubModuleTranslator subModule = (YangJavaSubModuleTranslator) node;
438 - pkg.append(getRootPackage(submodule.getVersion(), 470 + pkg.append(getRootPackage(subModule.getVersion(),
439 - submodule.getNameSpaceFromModule(submodule.getBelongsTo()), 471 + subModule.getNameSpaceFromModule(subModule.getBelongsTo()),
440 - submodule.getRevision().getRevDate(), yangPluginConfig.getConflictResolver())); 472 + subModule.getRevision().getRevDate(), yangPluginConfig.getConflictResolver()));
441 } 473 }
442 String concat = ""; 474 String concat = "";
443 for (int i = 1; i <= clsInfo.size(); i++) { 475 for (int i = 1; i <= clsInfo.size(); i++) {
...@@ -456,12 +488,15 @@ public final class YangJavaModelUtils { ...@@ -456,12 +488,15 @@ public final class YangJavaModelUtils {
456 * @return augment class name 488 * @return augment class name
457 */ 489 */
458 public static String getAugmentClassName(YangAugment augment, YangPluginConfig yangPluginConfig) { 490 public static String getAugmentClassName(YangAugment augment, YangPluginConfig yangPluginConfig) {
459 - YangNodeIdentifier nodeId = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier(); 491 + YangNodeIdentifier yangNodeIdentifier = augment.getTargetNode().get(augment.getTargetNode().size() - 1)
460 - String name = getCapitalCase(getCamelCase(nodeId.getName(), yangPluginConfig.getConflictResolver())); 492 + .getNodeIdentifier();
461 - if (nodeId.getPrefix() != null) { 493 + String name = getCapitalCase(getCamelCase(yangNodeIdentifier.getName(), yangPluginConfig
462 - return AUGMENTED + getCapitalCase(nodeId.getPrefix()) + name; 494 + .getConflictResolver()));
495 + if (yangNodeIdentifier.getPrefix() != null) {
496 + return AUGMENTED + getCapitalCase(yangNodeIdentifier.getPrefix()) + name;
463 } else { 497 } else {
464 return AUGMENTED + name; 498 return AUGMENTED + name;
465 } 499 }
466 } 500 }
501 +
467 } 502 }
......
...@@ -262,7 +262,7 @@ public final class AttributesJavaDataType { ...@@ -262,7 +262,7 @@ public final class AttributesJavaDataType {
262 case INSTANCE_IDENTIFIER: 262 case INSTANCE_IDENTIFIER:
263 return JAVA_LANG; 263 return JAVA_LANG;
264 case DERIVED: 264 case DERIVED:
265 - return getTypDefsPackage(yangType, conflictResolver); 265 + return getTypeDefsPackage(yangType, conflictResolver);
266 default: 266 default:
267 throw new TranslatorException("given data type is not supported."); 267 throw new TranslatorException("given data type is not supported.");
268 } 268 }
...@@ -288,7 +288,7 @@ public final class AttributesJavaDataType { ...@@ -288,7 +288,7 @@ public final class AttributesJavaDataType {
288 case INSTANCE_IDENTIFIER: 288 case INSTANCE_IDENTIFIER:
289 return JAVA_LANG; 289 return JAVA_LANG;
290 case DERIVED: 290 case DERIVED:
291 - return getTypDefsPackage(yangType, conflictResolver); 291 + return getTypeDefsPackage(yangType, conflictResolver);
292 default: 292 default:
293 return null; 293 return null;
294 } 294 }
...@@ -302,7 +302,7 @@ public final class AttributesJavaDataType { ...@@ -302,7 +302,7 @@ public final class AttributesJavaDataType {
302 * @param conflictResolver object of YANG to java naming conflict util 302 * @param conflictResolver object of YANG to java naming conflict util
303 * @return java package for typedef node 303 * @return java package for typedef node
304 */ 304 */
305 - private static String getTypDefsPackage(YangType<?> type, YangToJavaNamingConflictUtil conflictResolver) { 305 + private static String getTypeDefsPackage(YangType<?> type, YangToJavaNamingConflictUtil conflictResolver) {
306 Object var = type.getDataTypeExtendedInfo(); 306 Object var = type.getDataTypeExtendedInfo();
307 if (!(var instanceof YangDerivedInfo)) { 307 if (!(var instanceof YangDerivedInfo)) {
308 throw new TranslatorException("type should have been derived."); 308 throw new TranslatorException("type should have been derived.");
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
16 package org.onosproject.yangutils.translator.tojava.javamodel; 16 package org.onosproject.yangutils.translator.tojava.javamodel;
17 17
18 import org.onosproject.yangutils.datamodel.YangType; 18 import org.onosproject.yangutils.datamodel.YangType;
19 -import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer;
20 import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflictUtil; 19 import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflictUtil;
20 +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer;
21 21
22 /** 22 /**
23 * Represent java based identification of the YANG leaves. 23 * Represent java based identification of the YANG leaves.
...@@ -25,21 +25,21 @@ import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflic ...@@ -25,21 +25,21 @@ import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflic
25 public interface JavaLeafInfoContainer 25 public interface JavaLeafInfoContainer
26 extends JavaQualifiedTypeInfoContainer { 26 extends JavaQualifiedTypeInfoContainer {
27 /** 27 /**
28 - * Retreives the data type of the leaf. 28 + * Retrieves the data type of the leaf.
29 * 29 *
30 * @return data type of the leaf 30 * @return data type of the leaf
31 */ 31 */
32 YangType<?> getDataType(); 32 YangType<?> getDataType();
33 33
34 /** 34 /**
35 - * Retreives the name of the leaf. 35 + * Retrieves the name of the leaf.
36 * 36 *
37 * @return name of the leaf 37 * @return name of the leaf
38 */ 38 */
39 String getName(); 39 String getName();
40 40
41 /** 41 /**
42 - * Retreives the java name of the leaf. 42 + * Retrieves the java name of the leaf.
43 * 43 *
44 * @param conflictResolveConfig user config to resolve conflicts 44 * @param conflictResolveConfig user config to resolve conflicts
45 * @return name of the leaf 45 * @return name of the leaf
...@@ -61,14 +61,14 @@ public interface JavaLeafInfoContainer ...@@ -61,14 +61,14 @@ public interface JavaLeafInfoContainer
61 /** 61 /**
62 * Returns java naming conflict resolver. 62 * Returns java naming conflict resolver.
63 * 63 *
64 - * @return java naming conflict resolver 64 + * @return java naming conflict resolver
65 */ 65 */
66 YangToJavaNamingConflictUtil getConflictResolveConfig(); 66 YangToJavaNamingConflictUtil getConflictResolveConfig();
67 67
68 /** 68 /**
69 * Sets java naming conflict resolver. 69 * Sets java naming conflict resolver.
70 * 70 *
71 - * @param conflictResolveConfig java naming conflict resolver 71 + * @param conflictResolveConfig java naming conflict resolver
72 */ 72 */
73 void setConflictResolveConfig(YangToJavaNamingConflictUtil conflictResolveConfig); 73 void setConflictResolveConfig(YangToJavaNamingConflictUtil conflictResolveConfig);
74 74
......
...@@ -21,7 +21,7 @@ import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContaine ...@@ -21,7 +21,7 @@ import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContaine
21 /** 21 /**
22 * Represent java based identification of the YANG leaves. 22 * Represent java based identification of the YANG leaves.
23 */ 23 */
24 -public interface JavaQualifiedTypeResolver 24 +interface JavaQualifiedTypeResolver
25 extends JavaQualifiedTypeInfoContainer { 25 extends JavaQualifiedTypeInfoContainer {
26 26
27 /** 27 /**
......
...@@ -17,6 +17,7 @@ package org.onosproject.yangutils.translator.tojava.javamodel; ...@@ -17,6 +17,7 @@ package org.onosproject.yangutils.translator.tojava.javamodel;
17 17
18 import java.io.IOException; 18 import java.io.IOException;
19 19
20 +import org.onosproject.yangutils.datamodel.YangChoice;
20 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 21 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
21 import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaAugment; 22 import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaAugment;
22 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 23 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
...@@ -118,10 +119,21 @@ public class YangJavaAugmentTranslator ...@@ -118,10 +119,21 @@ public class YangJavaAugmentTranslator
118 @Override 119 @Override
119 public void generateCodeExit() throws TranslatorException { 120 public void generateCodeExit() throws TranslatorException {
120 try { 121 try {
121 - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); 122 + if (validateAugmentNode()) {
123 + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
124 + }
122 } catch (IOException e) { 125 } catch (IOException e) {
123 throw new TranslatorException("Failed to generate code for augmentable node " + getName()); 126 throw new TranslatorException("Failed to generate code for augmentable node " + getName());
124 } 127 }
125 } 128 }
126 129
130 + /**
131 + * Returns true if augment does not have choice as target node.
132 + *
133 + * @return true if augment does not have choice as target node
134 + */
135 + private boolean validateAugmentNode() {
136 + return !(getAugmentedNode() instanceof YangChoice);
137 + }
138 +
127 } 139 }
......
...@@ -123,4 +123,5 @@ public class YangJavaCaseTranslator ...@@ -123,4 +123,5 @@ public class YangJavaCaseTranslator
123 throw new TranslatorException("Failed to generate code for case node " + getName()); 123 throw new TranslatorException("Failed to generate code for case node " + getName());
124 } 124 }
125 } 125 }
126 +
126 } 127 }
......
...@@ -20,8 +20,8 @@ import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaGrouping; ...@@ -20,8 +20,8 @@ import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaGrouping;
20 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 20 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
21 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException; 21 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException;
22 import org.onosproject.yangutils.translator.exception.TranslatorException; 22 import org.onosproject.yangutils.translator.exception.TranslatorException;
23 -import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
24 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; 23 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
24 +import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
25 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 25 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 26
27 /** 27 /**
......
...@@ -47,7 +47,7 @@ public class YangJavaIdentityTranslator extends YangJavaIdentity ...@@ -47,7 +47,7 @@ public class YangJavaIdentityTranslator extends YangJavaIdentity
47 //File type extension for java classes. 47 //File type extension for java classes.
48 private static final String JAVA_FILE_EXTENSION = ".java"; 48 private static final String JAVA_FILE_EXTENSION = ".java";
49 49
50 - //Contains the information of the importd. 50 + //Contains the information of the imported.
51 private transient JavaImportData importData; 51 private transient JavaImportData importData;
52 52
53 /** 53 /**
...@@ -118,6 +118,7 @@ public class YangJavaIdentityTranslator extends YangJavaIdentity ...@@ -118,6 +118,7 @@ public class YangJavaIdentityTranslator extends YangJavaIdentity
118 @Override 118 @Override
119 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { 119 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException {
120 try { 120 try {
121 +
121 updatePackageInfo(this, yangPlugin); 122 updatePackageInfo(this, yangPlugin);
122 JavaQualifiedTypeInfoTranslator basePkgInfo = new JavaQualifiedTypeInfoTranslator(); 123 JavaQualifiedTypeInfoTranslator basePkgInfo = new JavaQualifiedTypeInfoTranslator();
123 String className = getCapitalCase(getJavaFileInfo().getJavaName()); 124 String className = getCapitalCase(getJavaFileInfo().getJavaName());
...@@ -142,7 +143,7 @@ public class YangJavaIdentityTranslator extends YangJavaIdentity ...@@ -142,7 +143,7 @@ public class YangJavaIdentityTranslator extends YangJavaIdentity
142 } 143 }
143 } 144 }
144 145
145 - File file = getFileObject(path, className, JAVA_FILE_EXTENSION, getJavaFileInfo().getBaseCodeGenPath()); 146 + File file = getFileObject(path, className, JAVA_FILE_EXTENSION, getJavaFileInfo());
146 147
147 initiateJavaFileGeneration(file, GENERATE_IDENTITY_CLASS, imports, this, className); 148 initiateJavaFileGeneration(file, GENERATE_IDENTITY_CLASS, imports, this, className);
148 closeFile(file, false); 149 closeFile(file, false);
......
...@@ -33,8 +33,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -33,8 +33,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
34 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 34 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
35 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode; 35 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode;
36 -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; 36 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isRootNodesCodeGenRequired;
37 -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
38 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 37 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
39 import static org.onosproject.yangutils.utils.UtilConstants.SBI; 38 import static org.onosproject.yangutils.utils.UtilConstants.SBI;
40 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; 39 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
...@@ -140,7 +139,7 @@ public class YangJavaModuleTranslator ...@@ -140,7 +139,7 @@ public class YangJavaModuleTranslator
140 */ 139 */
141 @Override 140 @Override
142 public void generateCodeExit() throws TranslatorException { 141 public void generateCodeExit() throws TranslatorException {
143 - /** 142 + /*
144 * As part of the notification support the following files needs to be generated. 143 * As part of the notification support the following files needs to be generated.
145 * 1) Subject of the notification(event), this is simple interface with builder class. 144 * 1) Subject of the notification(event), this is simple interface with builder class.
146 * 2) Event class extending "AbstractEvent" and defining event type enum. 145 * 2) Event class extending "AbstractEvent" and defining event type enum.
...@@ -153,17 +152,15 @@ public class YangJavaModuleTranslator ...@@ -153,17 +152,15 @@ public class YangJavaModuleTranslator
153 if ((getJavaFileInfo().getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) { 152 if ((getJavaFileInfo().getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) {
154 getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, this); 153 getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, this);
155 } 154 }
156 - getTempJavaCodeFragmentFiles() 155 +
157 - .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); 156 + if (isRootNodesCodeGenRequired(this)) {
158 - if (isManagerCodeGenRequired(this)) { 157 + getTempJavaCodeFragmentFiles()
159 - if (isGenerationOfCodeReq(getJavaFileInfo())) { 158 + .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
160 - if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null) 159 + if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null)
161 - || (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) { 160 + || (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) {
162 - getTempJavaCodeFragmentFiles().getServiceTempFiles().setManagerNeedToBeGenerated(true); 161 + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
163 - }
164 } 162 }
165 } 163 }
166 - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
167 164
168 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + 165 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() +
169 getJavaFileInfo().getPackageFilePath()); 166 getJavaFileInfo().getPackageFilePath());
...@@ -197,22 +194,22 @@ public class YangJavaModuleTranslator ...@@ -197,22 +194,22 @@ public class YangJavaModuleTranslator
197 * 194 *
198 * @param curNode notification node 195 * @param curNode notification node
199 */ 196 */
200 - private void addToNotificaitonList(YangNode curNode) { 197 + private void addToNotificationList(YangNode curNode) {
201 getNotificationNodes().add(curNode); 198 getNotificationNodes().add(curNode);
202 } 199 }
203 200
204 /** 201 /**
205 - * Checks if there is any rpc defined in the module or sub-module. 202 + * Checks if there is any notification node present.
206 * 203 *
207 * @param rootNode root node of the data model 204 * @param rootNode root node of the data model
208 - * @return status of rpc's existence 205 + * @return status of notification's existence
209 */ 206 */
210 private boolean isNotificationChildNodePresent(YangNode rootNode) { 207 private boolean isNotificationChildNodePresent(YangNode rootNode) {
211 YangNode childNode = rootNode.getChild(); 208 YangNode childNode = rootNode.getChild();
212 209
213 while (childNode != null) { 210 while (childNode != null) {
214 if (childNode instanceof YangNotification) { 211 if (childNode instanceof YangNotification) {
215 - addToNotificaitonList(childNode); 212 + addToNotificationList(childNode);
216 } 213 }
217 childNode = childNode.getNextSibling(); 214 childNode = childNode.getNextSibling();
218 } 215 }
......
...@@ -116,7 +116,7 @@ public class YangJavaNotificationTranslator ...@@ -116,7 +116,7 @@ public class YangJavaNotificationTranslator
116 @Override 116 @Override
117 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { 117 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException {
118 118
119 - /** 119 + /*
120 * As part of the notification support the following files needs to be generated. 120 * As part of the notification support the following files needs to be generated.
121 * 1) Subject of the notification(event), this is simple interface with builder class. 121 * 1) Subject of the notification(event), this is simple interface with builder class.
122 * 2) Event class extending "AbstractEvent" and defining event type enum. 122 * 2) Event class extending "AbstractEvent" and defining event type enum.
......
...@@ -23,28 +23,22 @@ import org.onosproject.yangutils.datamodel.YangInput; ...@@ -23,28 +23,22 @@ import org.onosproject.yangutils.datamodel.YangInput;
23 import org.onosproject.yangutils.datamodel.YangNode; 23 import org.onosproject.yangutils.datamodel.YangNode;
24 import org.onosproject.yangutils.datamodel.YangOutput; 24 import org.onosproject.yangutils.datamodel.YangOutput;
25 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 25 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
26 +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator;
26 import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaRpc; 27 import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaRpc;
27 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 28 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
28 import org.onosproject.yangutils.translator.exception.TranslatorException; 29 import org.onosproject.yangutils.translator.exception.TranslatorException;
30 +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
29 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; 31 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
30 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; 32 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
31 -import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
32 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 33 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
33 -import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator;
34 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 34 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
35 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; 35 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
36 import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; 36 import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles;
37 37
38 +import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
38 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; 39 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
39 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; 40 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
40 -import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
41 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.updatePackageInfo; 41 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.updatePackageInfo;
42 -import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE;
43 -import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT;
44 -import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE;
45 -import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
46 -import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE;
47 -import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALITY;
48 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; 42 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
49 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 43 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
50 44
...@@ -58,7 +52,7 @@ public class YangJavaRpcTranslator ...@@ -58,7 +52,7 @@ public class YangJavaRpcTranslator
58 private static final long serialVersionUID = 806201622L; 52 private static final long serialVersionUID = 806201622L;
59 53
60 /** 54 /**
61 - * Temproary file for code generation. 55 + * Temporary file for code generation.
62 */ 56 */
63 private transient TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles; 57 private transient TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles;
64 58
...@@ -191,7 +185,7 @@ public class YangJavaRpcTranslator ...@@ -191,7 +185,7 @@ public class YangJavaRpcTranslator
191 * @return AttributeInfo attribute details required to add in temporary 185 * @return AttributeInfo attribute details required to add in temporary
192 * files 186 * files
193 */ 187 */
194 - public JavaAttributeInfo getChildNodeAsAttributeInParentService( 188 + private JavaAttributeInfo getChildNodeAsAttributeInParentService(
195 YangNode childNode, YangNode currentNode) { 189 YangNode childNode, YangNode currentNode) {
196 190
197 YangNode parentNode = getParentNodeInGenCode(currentNode); 191 YangNode parentNode = getParentNodeInGenCode(currentNode);
...@@ -229,13 +223,7 @@ public class YangJavaRpcTranslator ...@@ -229,13 +223,7 @@ public class YangJavaRpcTranslator
229 JavaFileInfo fileInfo = ((JavaFileInfoContainer) getParent()).getJavaFileInfo(); 223 JavaFileInfo fileInfo = ((JavaFileInfoContainer) getParent()).getJavaFileInfo();
230 224
231 if (importInfo.getClassInfo().contentEquals(SERVICE) 225 if (importInfo.getClassInfo().contentEquals(SERVICE)
232 - || importInfo.getClassInfo().contentEquals(COMPONENT) 226 + || importInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))) {
233 - || importInfo.getClassInfo().contentEquals(getCapitalCase(ACTIVATE))
234 - || importInfo.getClassInfo().contentEquals(getCapitalCase(DEACTIVATE))
235 - || importInfo.getClassInfo().contentEquals(REFERENCE_CARDINALITY)
236 - || importInfo.getClassInfo().contentEquals(REFERENCE)
237 - || importInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))
238 - || importInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + MANAGER))) {
239 return true; 227 return true;
240 } 228 }
241 229
......
...@@ -35,8 +35,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -35,8 +35,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
35 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 35 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
36 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 36 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
37 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode; 37 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode;
38 -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; 38 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isRootNodesCodeGenRequired;
39 -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
40 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 39 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
41 import static org.onosproject.yangutils.utils.UtilConstants.SBI; 40 import static org.onosproject.yangutils.utils.UtilConstants.SBI;
42 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; 41 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
...@@ -66,11 +65,11 @@ public class YangJavaSubModuleTranslator ...@@ -66,11 +65,11 @@ public class YangJavaSubModuleTranslator
66 public YangJavaSubModuleTranslator() { 65 public YangJavaSubModuleTranslator() {
67 super(); 66 super();
68 setJavaFileInfo(new JavaFileInfo()); 67 setJavaFileInfo(new JavaFileInfo());
69 - int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER; 68 + int genType = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER;
70 if (isNotificationChildNodePresent(this)) { 69 if (isNotificationChildNodePresent(this)) {
71 - gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_ALL_EVENT_CLASS_MASK; 70 + genType = GENERATE_SERVICE_AND_MANAGER | GENERATE_ALL_EVENT_CLASS_MASK;
72 } 71 }
73 - getJavaFileInfo().setGeneratedFileTypes(gentype); 72 + getJavaFileInfo().setGeneratedFileTypes(genType);
74 } 73 }
75 74
76 /** 75 /**
...@@ -168,17 +167,14 @@ public class YangJavaSubModuleTranslator ...@@ -168,17 +167,14 @@ public class YangJavaSubModuleTranslator
168 if ((getJavaFileInfo().getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) { 167 if ((getJavaFileInfo().getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) {
169 getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, this); 168 getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, this);
170 } 169 }
171 - getTempJavaCodeFragmentFiles() 170 + if (isRootNodesCodeGenRequired(this)) {
172 - .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); 171 + getTempJavaCodeFragmentFiles()
173 - if (isManagerCodeGenRequired(this)) { 172 + .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
174 - if (isGenerationOfCodeReq(getJavaFileInfo())) { 173 + if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null)
175 - if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null) 174 + || (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) {
176 - || (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) { 175 + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
177 - getTempJavaCodeFragmentFiles().getServiceTempFiles().setManagerNeedToBeGenerated(true);
178 - }
179 } 176 }
180 } 177 }
181 - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
182 178
183 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + 179 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() +
184 getJavaFileInfo().getPackageFilePath()); 180 getJavaFileInfo().getPackageFilePath());
...@@ -203,22 +199,22 @@ public class YangJavaSubModuleTranslator ...@@ -203,22 +199,22 @@ public class YangJavaSubModuleTranslator
203 * 199 *
204 * @param curNode notification node 200 * @param curNode notification node
205 */ 201 */
206 - private void addToNotificaitonList(YangNode curNode) { 202 + private void addToNotificationList(YangNode curNode) {
207 getNotificationNodes().add(curNode); 203 getNotificationNodes().add(curNode);
208 } 204 }
209 205
210 /** 206 /**
211 - * Checks if there is any rpc defined in the module or sub-module. 207 + * Checks if there is any notification node present.
212 * 208 *
213 * @param rootNode root node of the data model 209 * @param rootNode root node of the data model
214 - * @return status of rpc's existence 210 + * @return status of notification's existence
215 */ 211 */
216 private boolean isNotificationChildNodePresent(YangNode rootNode) { 212 private boolean isNotificationChildNodePresent(YangNode rootNode) {
217 YangNode childNode = rootNode.getChild(); 213 YangNode childNode = rootNode.getChild();
218 214
219 while (childNode != null) { 215 while (childNode != null) {
220 if (childNode instanceof YangNotification) { 216 if (childNode instanceof YangNotification) {
221 - addToNotificaitonList(childNode); 217 + addToNotificationList(childNode);
222 } 218 }
223 childNode = childNode.getNextSibling(); 219 childNode = childNode.getNextSibling();
224 } 220 }
......
...@@ -16,18 +16,20 @@ ...@@ -16,18 +16,20 @@
16 package org.onosproject.yangutils.translator.tojava.javamodel; 16 package org.onosproject.yangutils.translator.tojava.javamodel;
17 17
18 import java.io.IOException; 18 import java.io.IOException;
19 +
19 import org.onosproject.yangutils.datamodel.YangDerivedInfo; 20 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
20 import org.onosproject.yangutils.datamodel.YangType; 21 import org.onosproject.yangutils.datamodel.YangType;
21 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 22 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
22 import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaTypeDef; 23 import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaTypeDef;
23 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 24 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
24 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
25 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException; 25 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException;
26 import org.onosproject.yangutils.translator.exception.TranslatorException; 26 import org.onosproject.yangutils.translator.exception.TranslatorException;
27 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; 27 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
28 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; 28 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
30 30
31 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
32 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF;
31 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; 33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
32 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfNode; 34 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfNode;
33 35
...@@ -109,12 +111,12 @@ public class YangJavaTypeDefTranslator ...@@ -109,12 +111,12 @@ public class YangJavaTypeDefTranslator
109 @Override 111 @Override
110 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { 112 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException {
111 YangType typeInTypeDef = this.getTypeDefBaseType(); 113 YangType typeInTypeDef = this.getTypeDefBaseType();
112 - if (typeInTypeDef.getDataType() == YangDataTypes.DERIVED) { 114 + if (typeInTypeDef.getDataType() == DERIVED) {
113 YangDerivedInfo derivedInfo = (YangDerivedInfo) typeInTypeDef.getDataTypeExtendedInfo(); 115 YangDerivedInfo derivedInfo = (YangDerivedInfo) typeInTypeDef.getDataTypeExtendedInfo();
114 - if (derivedInfo.getEffectiveBuiltInType() == YangDataTypes.LEAFREF) { 116 + if (derivedInfo.getEffectiveBuiltInType() == LEAFREF) {
115 throw new InvalidNodeForTranslatorException(); 117 throw new InvalidNodeForTranslatorException();
116 } 118 }
117 - } else if (typeInTypeDef.getDataType() == YangDataTypes.LEAFREF) { 119 + } else if (typeInTypeDef.getDataType() == LEAFREF) {
118 throw new InvalidNodeForTranslatorException(); 120 throw new InvalidNodeForTranslatorException();
119 } 121 }
120 try { 122 try {
......
...@@ -16,10 +16,13 @@ ...@@ -16,10 +16,13 @@
16 package org.onosproject.yangutils.translator.tojava.javamodel; 16 package org.onosproject.yangutils.translator.tojava.javamodel;
17 17
18 import org.onosproject.yangutils.datamodel.YangType; 18 import org.onosproject.yangutils.datamodel.YangType;
19 -import org.onosproject.yangutils.datamodel.javadatamodel.JavaQualifiedTypeInfo;
20 -import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflictUtil;
21 import org.onosproject.yangutils.translator.exception.TranslatorException; 19 import org.onosproject.yangutils.translator.exception.TranslatorException;
22 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator; 20 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator;
21 +import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflictUtil;
22 +
23 +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaDataType;
24 +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportClass;
25 +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportPackage;
23 26
24 /** 27 /**
25 * Represents java information corresponding to the YANG type. 28 * Represents java information corresponding to the YANG type.
...@@ -30,7 +33,7 @@ public class YangJavaTypeTranslator<T> ...@@ -30,7 +33,7 @@ public class YangJavaTypeTranslator<T>
30 extends YangType<T> 33 extends YangType<T>
31 implements JavaQualifiedTypeResolver { 34 implements JavaQualifiedTypeResolver {
32 35
33 - private JavaQualifiedTypeInfo javaQualifiedAccess; 36 + private JavaQualifiedTypeInfoTranslator javaQualifiedAccess;
34 37
35 /** 38 /**
36 * Create a YANG leaf object with java qualified access details. 39 * Create a YANG leaf object with java qualified access details.
...@@ -47,15 +50,15 @@ public class YangJavaTypeTranslator<T> ...@@ -47,15 +50,15 @@ public class YangJavaTypeTranslator<T>
47 /* 50 /*
48 * Type is added as an attribute in the class. 51 * Type is added as an attribute in the class.
49 */ 52 */
50 - String className = AttributesJavaDataType.getJavaImportClass(this, false, conflictResolver); 53 + String className = getJavaImportClass(this, false, conflictResolver);
51 if (className != null) { 54 if (className != null) {
52 /* 55 /*
53 * Corresponding to the attribute type a class needs to be imported, 56 * Corresponding to the attribute type a class needs to be imported,
54 * since it can be a derived type or a usage of wrapper classes. 57 * since it can be a derived type or a usage of wrapper classes.
55 */ 58 */
56 importInfo.setClassInfo(className); 59 importInfo.setClassInfo(className);
57 - String classPkg = AttributesJavaDataType.getJavaImportPackage(this, 60 + String classPkg = getJavaImportPackage(this,
58 - false, conflictResolver); 61 + false, conflictResolver);
59 if (classPkg == null) { 62 if (classPkg == null) {
60 throw new TranslatorException("import package cannot be null when the class is used"); 63 throw new TranslatorException("import package cannot be null when the class is used");
61 } 64 }
...@@ -65,7 +68,7 @@ public class YangJavaTypeTranslator<T> ...@@ -65,7 +68,7 @@ public class YangJavaTypeTranslator<T>
65 * The attribute does not need a class to be imported, for example 68 * The attribute does not need a class to be imported, for example
66 * built in java types. 69 * built in java types.
67 */ 70 */
68 - String dataTypeName = AttributesJavaDataType.getJavaDataType(this); 71 + String dataTypeName = getJavaDataType(this);
69 if (dataTypeName == null) { 72 if (dataTypeName == null) {
70 throw new TranslatorException("not supported data type"); 73 throw new TranslatorException("not supported data type");
71 } 74 }
...@@ -76,7 +79,7 @@ public class YangJavaTypeTranslator<T> ...@@ -76,7 +79,7 @@ public class YangJavaTypeTranslator<T>
76 79
77 @Override 80 @Override
78 public JavaQualifiedTypeInfoTranslator getJavaQualifiedInfo() { 81 public JavaQualifiedTypeInfoTranslator getJavaQualifiedInfo() {
79 - return (JavaQualifiedTypeInfoTranslator) javaQualifiedAccess; 82 + return javaQualifiedAccess;
80 } 83 }
81 84
82 @Override 85 @Override
......
...@@ -20,8 +20,8 @@ import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaUses; ...@@ -20,8 +20,8 @@ import org.onosproject.yangutils.datamodel.javadatamodel.YangJavaUses;
20 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 20 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
21 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException; 21 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException;
22 import org.onosproject.yangutils.translator.exception.TranslatorException; 22 import org.onosproject.yangutils.translator.exception.TranslatorException;
23 -import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
24 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; 23 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
24 +import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
25 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 25 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 26
27 /** 27 /**
......
...@@ -19,16 +19,19 @@ package org.onosproject.yangutils.translator.tojava.utils; ...@@ -19,16 +19,19 @@ package org.onosproject.yangutils.translator.tojava.utils;
19 import org.onosproject.yangutils.datamodel.YangAugment; 19 import org.onosproject.yangutils.datamodel.YangAugment;
20 import org.onosproject.yangutils.datamodel.YangCase; 20 import org.onosproject.yangutils.datamodel.YangCase;
21 import org.onosproject.yangutils.datamodel.YangIdentity; 21 import org.onosproject.yangutils.datamodel.YangIdentity;
22 +import org.onosproject.yangutils.datamodel.YangModule;
22 import org.onosproject.yangutils.datamodel.YangNode; 23 import org.onosproject.yangutils.datamodel.YangNode;
23 import org.onosproject.yangutils.datamodel.YangNotification; 24 import org.onosproject.yangutils.datamodel.YangNotification;
24 -import org.onosproject.yangutils.translator.exception.TranslatorException; 25 +import org.onosproject.yangutils.datamodel.YangSubModule;
25 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 26 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
27 +import org.onosproject.yangutils.translator.exception.TranslatorException;
26 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 28 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
27 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator; 29 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator;
28 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; 30 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
29 31
30 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; 32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
31 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; 33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
34 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; 35 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; 36 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
34 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; 37 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
...@@ -37,10 +40,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -37,10 +40,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
37 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 40 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
38 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; 41 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
39 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; 42 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
40 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
41 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; 43 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
42 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK;
43 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_CLASS_MASK;
44 import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT; 44 import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT;
45 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 45 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
46 import static org.onosproject.yangutils.utils.UtilConstants.CLASS; 46 import static org.onosproject.yangutils.utils.UtilConstants.CLASS;
...@@ -61,21 +61,21 @@ import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; ...@@ -61,21 +61,21 @@ import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE;
61 import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; 61 import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
62 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 62 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
63 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; 63 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
64 -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; 64 +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
65 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 65 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
66 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; 66 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
67 import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE; 67 import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE;
68 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; 68 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
69 import static org.onosproject.yangutils.utils.UtilConstants.SPACE; 69 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
70 +import static org.onosproject.yangutils.utils.UtilConstants.STATIC;
70 import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT; 71 import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT;
71 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO;
72 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 72 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
73 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; 73 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
74 74
75 /** 75 /**
76 * Represents generator for class definition of generated files. 76 * Represents generator for class definition of generated files.
77 */ 77 */
78 -public final class ClassDefinitionGenerator { 78 +final class ClassDefinitionGenerator {
79 79
80 /** 80 /**
81 * Creates an instance of class definition generator. 81 * Creates an instance of class definition generator.
...@@ -90,9 +90,9 @@ public final class ClassDefinitionGenerator { ...@@ -90,9 +90,9 @@ public final class ClassDefinitionGenerator {
90 * @param yangName class name 90 * @param yangName class name
91 * @return class definition 91 * @return class definition
92 */ 92 */
93 - public static String generateClassDefinition(int genFileTypes, String yangName) { 93 + static String generateClassDefinition(int genFileTypes, String yangName) {
94 94
95 - /** 95 + /*
96 * Based on the file type and the YANG name of the file, generate the 96 * Based on the file type and the YANG name of the file, generate the
97 * class / interface definition start. 97 * class / interface definition start.
98 */ 98 */
...@@ -115,9 +115,9 @@ public final class ClassDefinitionGenerator { ...@@ -115,9 +115,9 @@ public final class ClassDefinitionGenerator {
115 * @param curNode current YANG node 115 * @param curNode current YANG node
116 * @return class definition 116 * @return class definition
117 */ 117 */
118 - public static String generateClassDefinition(int genFileTypes, String yangName, YangNode curNode) { 118 + static String generateClassDefinition(int genFileTypes, String yangName, YangNode curNode) {
119 119
120 - /** 120 + /*
121 * Based on the file type and the YANG name of the file, generate the 121 * Based on the file type and the YANG name of the file, generate the
122 * class / interface definition start. 122 * class / interface definition start.
123 */ 123 */
...@@ -126,12 +126,8 @@ public final class ClassDefinitionGenerator { ...@@ -126,12 +126,8 @@ public final class ClassDefinitionGenerator {
126 return getInterfaceDefinition(yangName, curNode); 126 return getInterfaceDefinition(yangName, curNode);
127 case BUILDER_CLASS_MASK: 127 case BUILDER_CLASS_MASK:
128 return getBuilderClassDefinition(yangName, curNode); 128 return getBuilderClassDefinition(yangName, curNode);
129 - case OPERATION_BUILDER_CLASS_MASK: 129 + case DEFAULT_CLASS_MASK:
130 - return getOpParamBuilderClassDefinition(yangName, curNode);
131 - case IMPL_CLASS_MASK:
132 return getImplClassDefinition(yangName, curNode); 130 return getImplClassDefinition(yangName, curNode);
133 - case OPERATION_CLASS_MASK:
134 - return getOpPramImplClassDefinition(yangName, curNode);
135 case BUILDER_INTERFACE_MASK: 131 case BUILDER_INTERFACE_MASK:
136 return getBuilderInterfaceDefinition(yangName, curNode); 132 return getBuilderInterfaceDefinition(yangName, curNode);
137 case GENERATE_SERVICE_AND_MANAGER: 133 case GENERATE_SERVICE_AND_MANAGER:
...@@ -204,27 +200,12 @@ public final class ClassDefinitionGenerator { ...@@ -204,27 +200,12 @@ public final class ClassDefinitionGenerator {
204 return clsDef; 200 return clsDef;
205 } 201 }
206 } 202 }
207 - return PUBLIC + SPACE + CLASS + SPACE + yangName + BUILDER + SPACE + IMPLEMENTS + SPACE + yangName + PERIOD 203 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
208 - + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 204 + return PUBLIC + SPACE + STATIC + SPACE + CLASS + SPACE + yangName + BUILDER + SPACE
209 - } 205 + + OPEN_CURLY_BRACKET + NEW_LINE;
210 -
211 - /**
212 - * Returns operation param builder file class definition.
213 - *
214 - * @param yangName class name
215 - * @param curNode YANG node
216 - * @return definition returns operation param builder file class definition
217 - */
218 - private static String getOpParamBuilderClassDefinition(String yangName, YangNode curNode) {
219 - if (!(curNode instanceof YangCase)) {
220 - String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, OPERATION_BUILDER_CLASS_MASK);
221 - if (clsDef != null) {
222 - return clsDef + OPEN_CURLY_BRACKET + NEW_LINE;
223 - }
224 } 206 }
225 - return PUBLIC + SPACE + CLASS + SPACE + yangName + OPERATION + BUILDER + SPACE + EXTEND + 207 + return PUBLIC + SPACE + STATIC + SPACE + CLASS + SPACE + yangName + BUILDER + SPACE + IMPLEMENTS + SPACE +
226 - SPACE + getCapitalCase(DEFAULT) + yangName + PERIOD + yangName + BUILDER + SPACE + 208 + yangName + PERIOD + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
227 - OPEN_CURLY_BRACKET + NEW_LINE;
228 } 209 }
229 210
230 /** 211 /**
...@@ -235,42 +216,20 @@ public final class ClassDefinitionGenerator { ...@@ -235,42 +216,20 @@ public final class ClassDefinitionGenerator {
235 */ 216 */
236 private static String getImplClassDefinition(String yangName, YangNode curNode) { 217 private static String getImplClassDefinition(String yangName, YangNode curNode) {
237 if (!(curNode instanceof YangCase)) { 218 if (!(curNode instanceof YangCase)) {
238 - String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, IMPL_CLASS_MASK); 219 + String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, DEFAULT_CLASS_MASK);
239 if (clsDef != null) { 220 if (clsDef != null) {
240 return clsDef; 221 return clsDef;
241 } 222 }
242 } 223 }
224 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
225 + return PUBLIC + SPACE + CLASS + SPACE + yangName + OP_PARAM + SPACE + IMPLEMENTS + SPACE
226 + + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
227 + }
243 return PUBLIC + SPACE + CLASS + SPACE + getCapitalCase(DEFAULT) + yangName + SPACE + IMPLEMENTS + SPACE 228 return PUBLIC + SPACE + CLASS + SPACE + getCapitalCase(DEFAULT) + yangName + SPACE + IMPLEMENTS + SPACE
244 + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 229 + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
245 } 230 }
246 231
247 /** 232 /**
248 - * Returns operation param file class definition.
249 - *
250 - * @param yangName class name
251 - * @param curNode YANG node
252 - * @return definition returns operation param file class definition
253 - */
254 - private static String getOpPramImplClassDefinition(String yangName, YangNode curNode) {
255 - String clsDef = "";
256 - if (!(curNode instanceof YangCase)) {
257 - clsDef = getClassDefinitionForWhenExtended(curNode, yangName, OPERATION_CLASS_MASK);
258 - }
259 -
260 - if (clsDef.equals("")) {
261 - clsDef = PUBLIC + SPACE + CLASS + SPACE + yangName + OPERATION + SPACE + EXTEND + SPACE
262 - + getCapitalCase(DEFAULT) + yangName + SPACE;
263 - }
264 - if (curNode instanceof YangAugment) {
265 - clsDef = clsDef + IMPLEMENTS + SPACE + YANG_AUGMENTED_OP_PARAM_INFO + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
266 - } else {
267 - clsDef = clsDef + OPEN_CURLY_BRACKET + NEW_LINE;
268 - }
269 -
270 - return clsDef;
271 - }
272 -
273 - /**
274 * Returns impl file class definition. 233 * Returns impl file class definition.
275 * 234 *
276 * @param yangName file name 235 * @param yangName file name
...@@ -293,7 +252,7 @@ public final class ClassDefinitionGenerator { ...@@ -293,7 +252,7 @@ public final class ClassDefinitionGenerator {
293 YangIdentity identity = (YangIdentity) curNode; 252 YangIdentity identity = (YangIdentity) curNode;
294 if (identity.getBaseNode() != null) { 253 if (identity.getBaseNode() != null) {
295 YangIdentity baseIdentity = identity.getBaseNode().getReferredIdentity(); 254 YangIdentity baseIdentity = identity.getBaseNode().getReferredIdentity();
296 - if (!(baseIdentity instanceof YangIdentity)) { 255 + if (baseIdentity == null) {
297 throw new TranslatorException("Expected java identity instance node"); 256 throw new TranslatorException("Expected java identity instance node");
298 } 257 }
299 258
...@@ -367,10 +326,8 @@ public final class ClassDefinitionGenerator { ...@@ -367,10 +326,8 @@ public final class ClassDefinitionGenerator {
367 * @return definition 326 * @return definition
368 */ 327 */
369 private static String getEventDefinition(String javaName, String eventName) { 328 private static String getEventDefinition(String javaName, String eventName) {
370 - String classDef = PUBLIC + SPACE + CLASS + SPACE + javaName + SPACE + "extends AbstractEvent<" 329 + return PUBLIC + SPACE + CLASS + SPACE + javaName + SPACE + "extends AbstractEvent<"
371 + javaName + ".Type, " + eventName + ">" + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 330 + javaName + ".Type, " + eventName + ">" + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
372 -
373 - return classDef;
374 } 331 }
375 332
376 /** 333 /**
...@@ -380,15 +337,15 @@ public final class ClassDefinitionGenerator { ...@@ -380,15 +337,15 @@ public final class ClassDefinitionGenerator {
380 * @return definition 337 * @return definition
381 */ 338 */
382 private static String getEventListenerDefinition(String javaName) { 339 private static String getEventListenerDefinition(String javaName) {
383 - String intfDef = PUBLIC + SPACE + INTERFACE + SPACE + javaName + SPACE + "extends EventListener<" 340 + String interfaceDef = PUBLIC + SPACE + INTERFACE + SPACE + javaName + SPACE + "extends EventListener<"
384 + javaName; 341 + javaName;
385 - if (intfDef.length() < 8) { 342 + if (interfaceDef.length() < 8) {
386 throw new RuntimeException("Event listener interface name is error"); 343 throw new RuntimeException("Event listener interface name is error");
387 } 344 }
388 - intfDef = intfDef.substring(0, intfDef.length() - 8); 345 + interfaceDef = interfaceDef.substring(0, interfaceDef.length() - 8);
389 - intfDef = intfDef + ">" + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 346 + interfaceDef = interfaceDef + ">" + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
390 347
391 - return intfDef; 348 + return interfaceDef;
392 } 349 }
393 350
394 /** 351 /**
...@@ -415,21 +372,23 @@ public final class ClassDefinitionGenerator { ...@@ -415,21 +372,23 @@ public final class ClassDefinitionGenerator {
415 builderDef = getDefinitionString(builderDef, holder); 372 builderDef = getDefinitionString(builderDef, holder);
416 return builderDef + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 373 return builderDef + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
417 case BUILDER_CLASS_MASK: 374 case BUILDER_CLASS_MASK:
418 - def = def + CLASS + SPACE + yangName + BUILDER + SPACE + EXTEND + SPACE; 375 + def = def + STATIC + SPACE + CLASS + SPACE + yangName + BUILDER + SPACE + EXTEND + SPACE;
419 def = getDefinitionString(def, holder); 376 def = getDefinitionString(def, holder);
377 + if (curNode instanceof YangSubModule || curNode instanceof YangModule) {
378 + return def + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
379 + }
420 return def + SPACE + IMPLEMENTS + SPACE + yangName + PERIOD 380 return def + SPACE + IMPLEMENTS + SPACE + yangName + PERIOD
421 + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 381 + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
422 382
423 - case IMPL_CLASS_MASK: 383 + case DEFAULT_CLASS_MASK:
424 - def = def + SPACE + CLASS + SPACE + getCapitalCase(DEFAULT) + yangName + SPACE + EXTEND + SPACE; 384 + if (curNode instanceof YangSubModule || curNode instanceof YangModule) {
385 + def = def + CLASS + SPACE + yangName + OP_PARAM + SPACE + EXTEND + SPACE;
386 + } else {
387 + def = def + CLASS + SPACE + getCapitalCase(DEFAULT) + yangName + SPACE + EXTEND + SPACE;
388 + }
425 def = getDefinitionString(def, holder); 389 def = getDefinitionString(def, holder);
426 return def + SPACE + IMPLEMENTS + SPACE 390 return def + SPACE + IMPLEMENTS + SPACE
427 + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 391 + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
428 -
429 - case OPERATION_CLASS_MASK:
430 - def = def + CLASS + SPACE + yangName + OPERATION + SPACE + EXTEND + SPACE;
431 - def = getDefinitionString(def, holder);
432 - return def + SPACE;
433 default: 392 default:
434 return null; 393 return null;
435 } 394 }
......
...@@ -19,40 +19,36 @@ package org.onosproject.yangutils.translator.tojava.utils; ...@@ -19,40 +19,36 @@ package org.onosproject.yangutils.translator.tojava.utils;
19 import java.util.List; 19 import java.util.List;
20 20
21 import org.onosproject.yangutils.datamodel.YangNode; 21 import org.onosproject.yangutils.datamodel.YangNode;
22 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
22 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; 23 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
23 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator; 24 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator;
24 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; 25 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
25 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
26 26
27 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; 27 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
28 -import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION_IMPORT; 28 +import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST;
29 import static org.onosproject.yangutils.utils.UtilConstants.CLASS_STRING; 29 import static org.onosproject.yangutils.utils.UtilConstants.CLASS_STRING;
30 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 30 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
31 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; 31 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
32 import static org.onosproject.yangutils.utils.UtilConstants.COMMA; 32 import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
33 -import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION;
34 -import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION_IMPORT;
35 -import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE_ANNOTATION_IMPORT;
36 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; 33 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET;
37 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; 34 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET;
35 +import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
38 import static org.onosproject.yangutils.utils.UtilConstants.ENUM; 36 import static org.onosproject.yangutils.utils.UtilConstants.ENUM;
39 import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; 37 import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
40 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; 38 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
41 import static org.onosproject.yangutils.utils.UtilConstants.HASH_MAP; 39 import static org.onosproject.yangutils.utils.UtilConstants.HASH_MAP;
42 -import static org.onosproject.yangutils.utils.UtilConstants.IMMEDIATE;
43 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; 40 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
44 import static org.onosproject.yangutils.utils.UtilConstants.INT; 41 import static org.onosproject.yangutils.utils.UtilConstants.INT;
45 import static org.onosproject.yangutils.utils.UtilConstants.INT_MAX_RANGE_ATTR; 42 import static org.onosproject.yangutils.utils.UtilConstants.INT_MAX_RANGE_ATTR;
46 import static org.onosproject.yangutils.utils.UtilConstants.INT_MIN_RANGE_ATTR; 43 import static org.onosproject.yangutils.utils.UtilConstants.INT_MIN_RANGE_ATTR;
47 import static org.onosproject.yangutils.utils.UtilConstants.LIST; 44 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
48 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; 45 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE;
49 -import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_FACTORY_IMPORT;
50 -import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT;
51 import static org.onosproject.yangutils.utils.UtilConstants.LONG_MAX_RANGE_ATTR; 46 import static org.onosproject.yangutils.utils.UtilConstants.LONG_MAX_RANGE_ATTR;
52 import static org.onosproject.yangutils.utils.UtilConstants.LONG_MIN_RANGE_ATTR; 47 import static org.onosproject.yangutils.utils.UtilConstants.LONG_MIN_RANGE_ATTR;
53 import static org.onosproject.yangutils.utils.UtilConstants.MAP; 48 import static org.onosproject.yangutils.utils.UtilConstants.MAP;
54 import static org.onosproject.yangutils.utils.UtilConstants.NEW; 49 import static org.onosproject.yangutils.utils.UtilConstants.NEW;
55 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 50 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
51 +import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING;
56 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; 52 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
57 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; 53 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
58 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 54 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
...@@ -60,10 +56,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; ...@@ -60,10 +56,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
60 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; 56 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
61 import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK; 57 import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK;
62 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 58 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
63 -import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION;
64 -import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_IMPORT;
65 import static org.onosproject.yangutils.utils.UtilConstants.SPACE; 59 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
66 -import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
67 import static org.onosproject.yangutils.utils.UtilConstants.TYPE; 60 import static org.onosproject.yangutils.utils.UtilConstants.TYPE;
68 import static org.onosproject.yangutils.utils.UtilConstants.UINT_MAX_RANGE_ATTR; 61 import static org.onosproject.yangutils.utils.UtilConstants.UINT_MAX_RANGE_ATTR;
69 import static org.onosproject.yangutils.utils.UtilConstants.UINT_MIN_RANGE_ATTR; 62 import static org.onosproject.yangutils.utils.UtilConstants.UINT_MIN_RANGE_ATTR;
...@@ -93,7 +86,7 @@ public final class JavaCodeSnippetGen { ...@@ -93,7 +86,7 @@ public final class JavaCodeSnippetGen {
93 */ 86 */
94 public static String getFileHeaderComment() { 87 public static String getFileHeaderComment() {
95 88
96 - /** 89 + /*
97 * TODO return the file header. 90 * TODO return the file header.
98 */ 91 */
99 return null; 92 return null;
...@@ -119,39 +112,29 @@ public final class JavaCodeSnippetGen { ...@@ -119,39 +112,29 @@ public final class JavaCodeSnippetGen {
119 * @param attributeAccessType attribute access type 112 * @param attributeAccessType attribute access type
120 * @return the textual java code for attribute definition in class 113 * @return the textual java code for attribute definition in class
121 */ 114 */
122 - public static String getJavaAttributeDefination(String javaAttributeTypePkg, String javaAttributeType, 115 + public static String getJavaAttributeDefinition(String javaAttributeTypePkg, String javaAttributeType,
123 String javaAttributeName, boolean isList, 116 String javaAttributeName, boolean isList,
124 String attributeAccessType) { 117 String attributeAccessType) {
125 118
126 - String attributeDefination = attributeAccessType + SPACE; 119 + String attributeDefinition = attributeAccessType + SPACE;
127 120
128 if (!isList) { 121 if (!isList) {
129 if (javaAttributeTypePkg != null) { 122 if (javaAttributeTypePkg != null) {
130 - attributeDefination = attributeDefination + javaAttributeTypePkg + PERIOD; 123 + attributeDefinition = attributeDefinition + javaAttributeTypePkg + PERIOD;
131 } 124 }
132 125
133 - attributeDefination = attributeDefination + javaAttributeType + SPACE + javaAttributeName + SEMI_COLAN 126 + attributeDefinition = attributeDefinition + javaAttributeType + SPACE + javaAttributeName + SEMI_COLAN
134 + NEW_LINE; 127 + NEW_LINE;
135 } else { 128 } else {
136 - attributeDefination = attributeDefination + LIST + DIAMOND_OPEN_BRACKET; 129 + attributeDefinition = attributeDefinition + LIST + DIAMOND_OPEN_BRACKET;
137 if (javaAttributeTypePkg != null) { 130 if (javaAttributeTypePkg != null) {
138 - attributeDefination = attributeDefination + javaAttributeTypePkg + PERIOD; 131 + attributeDefinition = attributeDefinition + javaAttributeTypePkg + PERIOD;
139 } 132 }
140 133
141 - attributeDefination = attributeDefination + javaAttributeType + DIAMOND_CLOSE_BRACKET + SPACE 134 + attributeDefinition = attributeDefinition + javaAttributeType + DIAMOND_CLOSE_BRACKET + SPACE
142 - + javaAttributeName + SEMI_COLAN + NEW_LINE; 135 + + javaAttributeName + SPACE + EQUAL + SPACE + NEW + SPACE + ARRAY_LIST + SEMI_COLAN + NEW_LINE;
143 } 136 }
144 - return attributeDefination; 137 + return attributeDefinition;
145 - }
146 -
147 - /**
148 - * Returns list attribute string.
149 - *
150 - * @param type attribute type
151 - * @return list attribute string
152 - */
153 - public static String getListAttribute(String type) {
154 - return LIST + DIAMOND_OPEN_BRACKET + type + DIAMOND_CLOSE_BRACKET;
155 } 138 }
156 139
157 /** 140 /**
...@@ -172,37 +155,12 @@ public final class JavaCodeSnippetGen { ...@@ -172,37 +155,12 @@ public final class JavaCodeSnippetGen {
172 * @return string for enum's attribute 155 * @return string for enum's attribute
173 */ 156 */
174 public static String generateEnumAttributeString(String name, int value, YangPluginConfig pluginConfig) { 157 public static String generateEnumAttributeString(String name, int value, YangPluginConfig pluginConfig) {
175 - return getJavaDoc(ENUM_ATTRIBUTE, name, false, pluginConfig) + FOUR_SPACE_INDENTATION 158 + return NEW_LINE + getJavaDoc(ENUM_ATTRIBUTE, name, false, pluginConfig)
176 - + getEnumJavaAttribute(name).toUpperCase() + OPEN_PARENTHESIS 159 + + EIGHT_SPACE_INDENTATION + getEnumJavaAttribute(name).toUpperCase() + OPEN_PARENTHESIS
177 + value + CLOSE_PARENTHESIS + COMMA + NEW_LINE; 160 + value + CLOSE_PARENTHESIS + COMMA + NEW_LINE;
178 } 161 }
179 162
180 /** 163 /**
181 - * Adds annotations imports.
182 - *
183 - * @param imports list if imports
184 - * @param operation to add or to delete
185 - */
186 - public static void addAnnotationsImports(List<String> imports, boolean operation) {
187 - if (operation) {
188 - imports.add(ACTIVATE_ANNOTATION_IMPORT);
189 - imports.add(DEACTIVATE_ANNOTATION_IMPORT);
190 - imports.add(COMPONENT_ANNOTATION_IMPORT);
191 - imports.add(SERVICE_ANNOTATION_IMPORT);
192 - imports.add(LOGGER_FACTORY_IMPORT);
193 - imports.add(LOGGER_IMPORT);
194 - } else {
195 - imports.remove(ACTIVATE_ANNOTATION_IMPORT);
196 - imports.remove(DEACTIVATE_ANNOTATION_IMPORT);
197 - imports.remove(COMPONENT_ANNOTATION_IMPORT);
198 - imports.remove(SERVICE_ANNOTATION_IMPORT);
199 - imports.remove(LOGGER_FACTORY_IMPORT);
200 - imports.remove(LOGGER_IMPORT);
201 - }
202 - sortImports(imports);
203 - }
204 -
205 - /**
206 * Returns sorted import list. 164 * Returns sorted import list.
207 * 165 *
208 * @param imports import list 166 * @param imports import list
...@@ -233,7 +191,7 @@ public final class JavaCodeSnippetGen { ...@@ -233,7 +191,7 @@ public final class JavaCodeSnippetGen {
233 */ 191 */
234 public static void addListenersImport(YangNode curNode, List<String> imports, boolean operation, 192 public static void addListenersImport(YangNode curNode, List<String> imports, boolean operation,
235 String classInfo) { 193 String classInfo) {
236 - String thisImport = ""; 194 + String thisImport;
237 TempJavaServiceFragmentFiles tempJavaServiceFragmentFiles = ((JavaCodeGeneratorInfo) curNode) 195 TempJavaServiceFragmentFiles tempJavaServiceFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
238 .getTempJavaCodeFragmentFiles().getServiceTempFiles(); 196 .getTempJavaCodeFragmentFiles().getServiceTempFiles();
239 if (classInfo.equals(LISTENER_SERVICE)) { 197 if (classInfo.equals(LISTENER_SERVICE)) {
...@@ -276,23 +234,13 @@ public final class JavaCodeSnippetGen { ...@@ -276,23 +234,13 @@ public final class JavaCodeSnippetGen {
276 } 234 }
277 235
278 /** 236 /**
279 - * Returns component string.
280 - *
281 - * @return component string
282 - */
283 - static String addComponentString() {
284 - return NEW_LINE + COMPONENT_ANNOTATION + OPEN_PARENTHESIS + IMMEDIATE + SPACE
285 - + EQUAL + SPACE + TRUE + CLOSE_PARENTHESIS + NEW_LINE + SERVICE_ANNOTATION;
286 - }
287 -
288 - /**
289 * Returns attribute for augmentation. 237 * Returns attribute for augmentation.
290 * 238 *
291 * @return attribute for augmentation 239 * @return attribute for augmentation
292 */ 240 */
293 static String addAugmentationAttribute() { 241 static String addAugmentationAttribute() {
294 return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING 242 return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING
295 - + DIAMOND_OPEN_BRACKET + QUESTION_MARK + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + YANG_AUGMENTED_INFO 243 + + DIAMOND_OPEN_BRACKET + QUESTION_MARK + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + OBJECT_STRING
296 + DIAMOND_CLOSE_BRACKET + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SPACE + EQUAL + SPACE + 244 + DIAMOND_CLOSE_BRACKET + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SPACE + EQUAL + SPACE +
297 NEW + SPACE + HASH_MAP + DIAMOND_OPEN_BRACKET + DIAMOND_CLOSE_BRACKET + OPEN_PARENTHESIS 245 NEW + SPACE + HASH_MAP + DIAMOND_OPEN_BRACKET + DIAMOND_CLOSE_BRACKET + OPEN_PARENTHESIS
298 + CLOSE_PARENTHESIS + SEMI_COLAN; 246 + CLOSE_PARENTHESIS + SEMI_COLAN;
...@@ -332,4 +280,76 @@ public final class JavaCodeSnippetGen { ...@@ -332,4 +280,76 @@ public final class JavaCodeSnippetGen {
332 FOUR_SPACE_INDENTATION + modifier + SPACE + ULONG_MAX_RANGE_ATTR; 280 FOUR_SPACE_INDENTATION + modifier + SPACE + ULONG_MAX_RANGE_ATTR;
333 } 281 }
334 } 282 }
283 +
284 + /**
285 + * Returns operation type enum.
286 + *
287 + * @return operation type enum
288 + */
289 + static String getOperationTypeEnum() {
290 + return "\n" +
291 + " /**\n" +
292 + " * Specify the node specific operation in protocols like NETCONF.\n" +
293 + " * Applicable in protocol edit operation, not applicable in query operation\n" +
294 + " */\n" +
295 + " public enum OperationType {\n" +
296 + " MERGE,\n" +
297 + " REPLACE,\n" +
298 + " CREATE,\n" +
299 + " DELETE,\n" +
300 + " REMOVE\n" +
301 + " }\n";
302 + }
303 +
304 + /**
305 + * Returns operation type enum, leaf value set attribute and select leaf attribute.
306 + *
307 + * @return operation type enum, leaf value set attribute and select leaf attribute.
308 + */
309 + static String getOperationAttributes() {
310 + return " /**\n" +
311 + " * Identify the leafs whose value are explicitly set\n" +
312 + " * Applicable in protocol edit and query operation\n" +
313 + " */\n" +
314 + " private BitSet _valueLeafFlags = new BitSet();\n" +
315 + "\n" +
316 + " /**\n" +
317 + " * Identify the leafs to be selected, in a query operation\n" +
318 + " */\n" +
319 + " private BitSet _selectLeafFlags = new BitSet();\n";
320 + }
321 +
322 + /**
323 + * Returns operation type enum, leaf value set attribute and select leaf attribute.
324 + *
325 + * @return operation type enum, leaf value set attribute and select leaf attribute.
326 + */
327 + static String getOperationTypeAttr() {
328 + return "\n /**\n" +
329 + " * Specify the node specific operation in protocols like NETCONF.\n" +
330 + " * Applicable in protocol edit operation, will be ignored in query operation\n" +
331 + " */\n" +
332 + " private OperationType _operationType;\n" +
333 + "\n";
334 + }
335 +
336 + /**
337 + * Returns operation type enum, leaf value set attribute and select leaf attribute for constructor.
338 + *
339 + * @return operation type enum, leaf value set attribute and select leaf attribute for constructor
340 + */
341 + static String getOperationAttributeForConstructor() {
342 + return " this._valueLeafFlags = builderObject.get_valueLeafFlags();\n" +
343 + " this._selectLeafFlags = builderObject.get_selectLeafFlags();\n";
344 + }
345 +
346 + /**
347 + * Returns operation type enum, leaf value set attribute and select leaf attribute for constructor.
348 + *
349 + * @return operation type enum, leaf value set attribute and select leaf attribute for constructor
350 + */
351 + static String getOperationTypeForConstructor() {
352 + return " this._operationType = builderObject.get_operationType();\n";
353 + }
354 +
335 } 355 }
......
...@@ -52,7 +52,7 @@ public class JavaExtendsListHolder { ...@@ -52,7 +52,7 @@ public class JavaExtendsListHolder {
52 * 52 *
53 * @return extends list 53 * @return extends list
54 */ 54 */
55 - public Map<JavaQualifiedTypeInfoTranslator, Boolean> getExtendedClassStore() { 55 + Map<JavaQualifiedTypeInfoTranslator, Boolean> getExtendedClassStore() {
56 return extendedClassStore; 56 return extendedClassStore;
57 } 57 }
58 58
......
...@@ -21,21 +21,20 @@ import java.io.IOException; ...@@ -21,21 +21,20 @@ import java.io.IOException;
21 import java.util.ArrayList; 21 import java.util.ArrayList;
22 import java.util.List; 22 import java.util.List;
23 23
24 -import org.onosproject.yangutils.datamodel.YangAugment;
25 import org.onosproject.yangutils.datamodel.YangAugmentableNode; 24 import org.onosproject.yangutils.datamodel.YangAugmentableNode;
25 +import org.onosproject.yangutils.datamodel.YangChoice;
26 import org.onosproject.yangutils.datamodel.YangDerivedInfo; 26 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
27 -import org.onosproject.yangutils.datamodel.YangLeaf;
28 -import org.onosproject.yangutils.datamodel.YangLeafList;
29 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 27 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
30 import org.onosproject.yangutils.datamodel.YangModule; 28 import org.onosproject.yangutils.datamodel.YangModule;
31 import org.onosproject.yangutils.datamodel.YangNode; 29 import org.onosproject.yangutils.datamodel.YangNode;
32 import org.onosproject.yangutils.datamodel.YangSubModule; 30 import org.onosproject.yangutils.datamodel.YangSubModule;
33 import org.onosproject.yangutils.datamodel.YangType; 31 import org.onosproject.yangutils.datamodel.YangType;
34 import org.onosproject.yangutils.datamodel.YangTypeDef; 32 import org.onosproject.yangutils.datamodel.YangTypeDef;
33 +import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
34 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
35 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; 35 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
36 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; 36 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
37 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; 37 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
38 -import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
39 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 38 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
40 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator; 39 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator;
41 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; 40 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
...@@ -43,11 +42,12 @@ import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFi ...@@ -43,11 +42,12 @@ import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFi
43 import org.onosproject.yangutils.translator.tojava.TempJavaEventFragmentFiles; 42 import org.onosproject.yangutils.translator.tojava.TempJavaEventFragmentFiles;
44 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; 43 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
45 import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles; 44 import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles;
46 -import org.onosproject.yangutils.translator.tojava.YangJavaModelUtils;
47 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
48 45
46 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BINARY;
47 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BITS;
49 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; 48 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
50 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; 49 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
50 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
51 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; 51 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
52 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; 52 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
53 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; 53 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
...@@ -55,10 +55,9 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -55,10 +55,9 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
55 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 55 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
56 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; 56 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
57 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; 57 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
58 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
59 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; 58 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
60 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK; 59 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK;
61 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_CLASS_MASK; 60 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK;
62 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; 61 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
63 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; 62 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK;
64 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; 63 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
...@@ -73,8 +72,8 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. ...@@ -73,8 +72,8 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.
73 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; 72 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
74 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK; 73 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
75 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK; 74 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK;
75 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK;
76 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK; 76 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK;
77 -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK;
78 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK; 77 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK;
79 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; 78 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
80 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; 79 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
...@@ -82,19 +81,19 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. ...@@ -82,19 +81,19 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.
82 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; 81 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
83 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode; 82 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
84 import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getCurNodeAsAttributeInTarget; 83 import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getCurNodeAsAttributeInTarget;
85 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAugmentationAttribute;
86 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEnumsValueAttribute; 84 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEnumsValueAttribute;
87 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEventEnumTypeStart; 85 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEventEnumTypeStart;
86 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationAttributeForConstructor;
87 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationAttributes;
88 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationTypeAttr;
89 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationTypeEnum;
90 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getOperationTypeForConstructor;
88 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle; 91 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle;
89 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; 92 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
90 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addActivateMethod; 93 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.builderMethod;
91 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod;
92 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl; 94 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl;
93 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentInfoImpl; 95 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodInterface;
94 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentInfoMapImpl;
95 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForManager;
96 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForService; 96 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForService;
97 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBaseClassMethodImpl;
98 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart; 97 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart;
99 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstructor; 98 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstructor;
100 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfMethod; 99 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfMethod;
...@@ -103,78 +102,62 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator ...@@ -103,78 +102,62 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator
103 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodClose; 102 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodClose;
104 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodSignature; 103 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodSignature;
105 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetter; 104 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetter;
106 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; 105 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForOperationType;
107 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString; 106 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString;
107 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGettersForValueAndSelectLeaf;
108 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose; 108 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose;
109 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen; 109 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen;
110 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getInterfaceLeafIdEnumMethods;
111 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getInterfaceLeafIdEnumSignature;
110 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilterContentMatch; 112 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilterContentMatch;
111 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString; 113 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString;
112 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOpParamConstructorStart; 114 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOperationAttributesGetters;
113 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOperationTypeSetter;
114 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOperationTypegetter;
115 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString; 115 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
116 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; 116 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRangeValidatorMethodForUnion;
117 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForLeaf; 117 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForOperationType;
118 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForLeafList; 118 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForSelectLeaf;
119 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString; 119 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
120 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringLeafListgetter;
121 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringLeafgetter;
122 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodClose; 120 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodClose;
123 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen; 121 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen;
124 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafListgetter; 122 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoImpl;
125 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafgetter; 123 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoInterface;
124 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoMapImpl;
125 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getYangAugmentInfoMapInterface;
126 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.isFilterContentMatchInterface;
127 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.isLeafValueSetInterface;
128 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.isSelectLeafSetInterface;
129 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.setSelectLeafSetInterface;
126 import static org.onosproject.yangutils.utils.UtilConstants.BASE64; 130 import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
127 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; 131 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
128 -import static org.onosproject.yangutils.utils.UtilConstants.BITSET;
129 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 132 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
130 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 133 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
131 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; 134 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
132 import static org.onosproject.yangutils.utils.UtilConstants.COMMA; 135 import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
133 -import static org.onosproject.yangutils.utils.UtilConstants.CREATE;
134 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; 136 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
135 -import static org.onosproject.yangutils.utils.UtilConstants.DELETE;
136 import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; 137 import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
137 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 138 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
138 import static org.onosproject.yangutils.utils.UtilConstants.ENCODE_TO_STRING; 139 import static org.onosproject.yangutils.utils.UtilConstants.ENCODE_TO_STRING;
139 -import static org.onosproject.yangutils.utils.UtilConstants.ENUM;
140 -import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
141 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING; 140 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING;
142 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; 141 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
143 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_SUBJECT_NAME_SUFFIX; 142 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_SUBJECT_NAME_SUFFIX;
144 -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF;
145 -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF_LIST;
146 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; 143 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
147 import static org.onosproject.yangutils.utils.UtilConstants.GET_ENCODER; 144 import static org.onosproject.yangutils.utils.UtilConstants.GET_ENCODER;
148 -import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF;
149 -import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF_LIST;
150 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; 145 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
151 import static org.onosproject.yangutils.utils.UtilConstants.INT; 146 import static org.onosproject.yangutils.utils.UtilConstants.INT;
152 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_IMPORT_BASE64_CLASS; 147 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_IMPORT_BASE64_CLASS;
153 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_PKG; 148 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_PKG;
154 -import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_STATEMENT;
155 -import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
156 -import static org.onosproject.yangutils.utils.UtilConstants.MERGE;
157 -import static org.onosproject.yangutils.utils.UtilConstants.NEW;
158 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 149 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
159 -import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
160 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; 150 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
161 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; 151 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
162 -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION_ENUM; 152 +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
163 -import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_TYPE;
164 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 153 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
165 import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; 154 import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
166 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; 155 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
167 -import static org.onosproject.yangutils.utils.UtilConstants.REMOVE;
168 -import static org.onosproject.yangutils.utils.UtilConstants.REPLACE;
169 import static org.onosproject.yangutils.utils.UtilConstants.RETURN; 156 import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
170 -import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF;
171 -import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF_LIST;
172 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 157 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
173 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_METHOD_STRING; 158 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_METHOD_STRING;
174 import static org.onosproject.yangutils.utils.UtilConstants.SPACE; 159 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
175 -import static org.onosproject.yangutils.utils.UtilConstants.STATIC;
176 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; 160 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
177 -import static org.onosproject.yangutils.utils.UtilConstants.SUPER;
178 import static org.onosproject.yangutils.utils.UtilConstants.TO; 161 import static org.onosproject.yangutils.utils.UtilConstants.TO;
179 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; 162 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
180 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; 163 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR;
...@@ -218,21 +201,63 @@ public final class JavaFileGenerator { ...@@ -218,21 +201,63 @@ public final class JavaFileGenerator {
218 201
219 String className = getCapitalCase(javaFileInfo.getJavaName()); 202 String className = getCapitalCase(javaFileInfo.getJavaName());
220 203
221 - initiateJavaFileGeneration(file, INTERFACE_MASK, imports, curNode, className); 204 + boolean isLeavesPresent;
205 + YangLeavesHolder leavesHolder;
206 + if (curNode instanceof YangLeavesHolder) {
207 + leavesHolder = (YangLeavesHolder) curNode;
208 + isLeavesPresent = leavesHolder.getListOfLeaf() != null && !leavesHolder.getListOfLeaf().isEmpty()
209 + || leavesHolder.getListOfLeafList() != null && !leavesHolder.getListOfLeafList().isEmpty();
210 + } else {
211 + isLeavesPresent = false;
212 + }
222 213
214 + initiateJavaFileGeneration(file, INTERFACE_MASK, imports, curNode, className);
215 + List<String> methods = new ArrayList<>();
223 if (isAttrPresent) { 216 if (isAttrPresent) {
224 // Add getter methods to interface file. 217 // Add getter methods to interface file.
225 try { 218 try {
219 + //Leaf identifier enum.
220 + if (isLeavesPresent) {
221 + insertDataIntoJavaFile(file, NEW_LINE + getInterfaceLeafIdEnumSignature(className) + NEW_LINE +
222 + trimAtLast(trimAtLast(
223 + getDataFromTempFileHandle(LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK,
224 + ((TempJavaCodeFragmentFilesContainer) curNode)
225 + .getTempJavaCodeFragmentFiles()
226 + .getBeanTempFiles(), path), COMMA), NEW_LINE) + SEMI_COLAN
227 + + NEW_LINE + NEW_LINE + getInterfaceLeafIdEnumMethods());
228 + }
229 +
226 //Getter methods. 230 //Getter methods.
227 insertDataIntoJavaFile(file, getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, 231 insertDataIntoJavaFile(file, getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK,
228 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 232 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
229 .getBeanTempFiles(), path)); 233 .getBeanTempFiles(), path));
234 + //Add to list method.
235 + insertDataIntoJavaFile(file, getDataFromTempFileHandle(ADD_TO_LIST_INTERFACE_MASK,
236 + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
237 + .getBeanTempFiles(), path));
230 } catch (IOException e) { 238 } catch (IOException e) {
231 throw new IOException("No data found in temporary java code fragment files for " + className 239 throw new IOException("No data found in temporary java code fragment files for " + className
232 + " while interface file generation"); 240 + " while interface file generation");
233 } 241 }
234 } 242 }
243 +
244 + if (curNode instanceof YangAugmentableNode && !(curNode instanceof YangChoice)) {
245 + methods.add(getAddAugmentInfoMethodInterface());
246 + methods.add(getYangAugmentInfoInterface());
247 + methods.add(getYangAugmentInfoMapInterface(javaFileInfo.getPluginConfig()));
248 + }
249 + if (!(curNode instanceof YangChoice)) {
250 + methods.add(NEW_LINE + isFilterContentMatchInterface(className));
251 + }
252 + if (!(curNode instanceof YangChoice) && isLeavesPresent) {
253 + methods.add(NEW_LINE + isLeafValueSetInterface());
254 + methods.add(NEW_LINE + isSelectLeafSetInterface());
255 + }
256 + for (String method : methods) {
257 + insertDataIntoJavaFile(file, method);
258 + }
235 return validateLineLength(file); 259 return validateLineLength(file);
260 +
236 } 261 }
237 262
238 /** 263 /**
...@@ -250,6 +275,16 @@ public final class JavaFileGenerator { ...@@ -250,6 +275,16 @@ public final class JavaFileGenerator {
250 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); 275 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
251 YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); 276 YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig();
252 277
278 + boolean isLeavesPresent;
279 + YangLeavesHolder leavesHolder;
280 + if (curNode instanceof YangLeavesHolder) {
281 + leavesHolder = (YangLeavesHolder) curNode;
282 + isLeavesPresent = leavesHolder.getListOfLeaf() != null && !leavesHolder.getListOfLeaf().isEmpty()
283 + || leavesHolder.getListOfLeafList() != null && !leavesHolder.getListOfLeafList().isEmpty();
284 + } else {
285 + isLeavesPresent = false;
286 + }
287 +
253 String className = getCapitalCase(javaFileInfo.getJavaName()); 288 String className = getCapitalCase(javaFileInfo.getJavaName());
254 String path; 289 String path;
255 if (curNode instanceof YangModule || curNode instanceof YangSubModule) { 290 if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
...@@ -279,6 +314,9 @@ public final class JavaFileGenerator { ...@@ -279,6 +314,9 @@ public final class JavaFileGenerator {
279 } 314 }
280 } 315 }
281 316
317 + if (isLeavesPresent) {
318 + methods.add(NEW_LINE + setSelectLeafSetInterface(className));
319 + }
282 //Add build method to builder interface file. 320 //Add build method to builder interface file.
283 methods.add( 321 methods.add(
284 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 322 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
...@@ -303,16 +341,28 @@ public final class JavaFileGenerator { ...@@ -303,16 +341,28 @@ public final class JavaFileGenerator {
303 * @return builder class file 341 * @return builder class file
304 * @throws IOException when fails to write in file 342 * @throws IOException when fails to write in file
305 */ 343 */
344 +
306 public static File generateBuilderClassFile(File file, YangNode curNode, 345 public static File generateBuilderClassFile(File file, YangNode curNode,
307 boolean isAttrPresent) throws IOException { 346 boolean isAttrPresent) throws IOException {
308 347
309 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); 348 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
310 YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); 349 YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig();
311 350
312 - String className = getCapitalCase(javaFileInfo.getJavaName()); 351 + boolean isLeavesPresent;
352 + YangLeavesHolder leavesHolder;
353 + if (curNode instanceof YangLeavesHolder) {
354 + leavesHolder = (YangLeavesHolder) curNode;
355 + isLeavesPresent = leavesHolder.getListOfLeaf() != null && !leavesHolder.getListOfLeaf().isEmpty()
356 + || leavesHolder.getListOfLeafList() != null && !leavesHolder.getListOfLeafList().isEmpty();
357 + } else {
358 + isLeavesPresent = false;
359 + }
313 360
361 + String className = getCapitalCase(javaFileInfo.getJavaName());
362 + boolean isRootNode = false;
314 String path; 363 String path;
315 if (curNode instanceof YangModule || curNode instanceof YangSubModule) { 364 if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
365 + isRootNode = true;
316 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); 366 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath();
317 } else { 367 } else {
318 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 368 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
...@@ -334,6 +384,10 @@ public final class JavaFileGenerator { ...@@ -334,6 +384,10 @@ public final class JavaFileGenerator {
334 + " while builder class file generation"); 384 + " while builder class file generation");
335 } 385 }
336 386
387 + insertDataIntoJavaFile(file, getOperationTypeAttr());
388 + if (isLeavesPresent) {
389 + insertDataIntoJavaFile(file, getOperationAttributes());
390 + }
337 try { 391 try {
338 //Getter methods. 392 //Getter methods.
339 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, 393 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK,
...@@ -345,6 +399,14 @@ public final class JavaFileGenerator { ...@@ -345,6 +399,14 @@ public final class JavaFileGenerator {
345 .getBeanTempFiles(), path)); 399 .getBeanTempFiles(), path));
346 400
347 insertDataIntoJavaFile(file, NEW_LINE); 401 insertDataIntoJavaFile(file, NEW_LINE);
402 +
403 + methods.add(getGetterForOperationType());
404 + methods.add(getSetterForOperationType(className));
405 + //Add operation attribute methods.
406 + if (isLeavesPresent) {
407 + methods.add(getOperationAttributesGetters() + NEW_LINE);
408 + methods.add(getSetterForSelectLeaf(className, isRootNode));
409 + }
348 } catch (IOException e) { 410 } catch (IOException e) {
349 throw new IOException("No data found in temporary java code fragment files for " + className 411 throw new IOException("No data found in temporary java code fragment files for " + className
350 + " while builder class file generation"); 412 + " while builder class file generation");
...@@ -355,191 +417,22 @@ public final class JavaFileGenerator { ...@@ -355,191 +417,22 @@ public final class JavaFileGenerator {
355 417
356 // Add default constructor and build method impl. 418 // Add default constructor and build method impl.
357 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 419 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
358 - .addBuildMethodImpl()); 420 + .addBuildMethodImpl(curNode));
359 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 421 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
360 - .addDefaultConstructor(PUBLIC, BUILDER, pluginConfig)); 422 + .addDefaultConstructor(PUBLIC, BUILDER, pluginConfig, curNode));
361 423
362 424
363 //Add methods in builder class. 425 //Add methods in builder class.
364 for (String method : methods) { 426 for (String method : methods) {
365 insertDataIntoJavaFile(file, method); 427 insertDataIntoJavaFile(file, method);
366 } 428 }
367 - insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET);
368 - return validateLineLength(file);
369 - }
370 -
371 - /**
372 - * Returns generated op param builder class file for current node.
373 - *
374 - * @param file file handle
375 - * @param curNode current YANG node
376 - * @param isAttrPresent if any attribute is present or not
377 - * @return builder class file
378 - * @throws IOException when fails to write in file
379 - */
380 - public static File generateOpParamBuilderClassFile(File file, YangNode curNode,
381 - boolean isAttrPresent) throws IOException {
382 -
383 - JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
384 - YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig();
385 -
386 - String className = getCapitalCase(javaFileInfo.getJavaName());
387 -
388 - initiateJavaFileGeneration(file, OPERATION_BUILDER_CLASS_MASK, null, curNode, className);
389 - List<String> methods = new ArrayList<>();
390 -
391 - if (isAttrPresent) {
392 - //Add attribute strings.
393 - try {
394 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
395 - OPERATION_ENUM + SPACE + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE);
396 -
397 - } catch (IOException e) {
398 - throw new IOException("No data found in temporary java code fragment files for " + className
399 - + " while impl class file generation");
400 - }
401 -
402 - try {
403 - if (curNode instanceof YangLeavesHolder) {
404 - YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
405 - List<YangLeaf> leaves = leavesHolder.getListOfLeaf();
406 - List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList();
407 -
408 - if (leaves != null && !leaves.isEmpty()) {
409 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
410 - BITSET + SPACE + FILTER_LEAF + SPACE + EQUAL + SPACE +
411 - NEW + SPACE + BITSET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN
412 - + NEW_LINE);
413 -
414 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
415 - BITSET + SPACE + SELECT_LEAF + SPACE + EQUAL + SPACE +
416 - NEW + SPACE + BITSET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
417 - + SEMI_COLAN + NEW_LINE);
418 - }
419 -
420 - if (listOfLeafList != null && !listOfLeafList.isEmpty()) {
421 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
422 - BITSET + SPACE + FILTER_LEAF_LIST + SPACE + EQUAL + SPACE +
423 - NEW + SPACE + BITSET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
424 - + SEMI_COLAN + NEW_LINE);
425 -
426 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
427 - BITSET + SPACE + SELECT_LEAF_LIST + SPACE + EQUAL + SPACE +
428 - NEW + SPACE + BITSET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
429 - + SEMI_COLAN + NEW_LINE);
430 - }
431 - }
432 -
433 - } catch (IOException e) {
434 - throw new IOException("No data found in temporary java code fragment files for " + className
435 - + " while impl class file generation");
436 - }
437 -
438 - try {
439 - // Setter methods.
440 - methods.add(getSetterForLeaf(className, curNode, pluginConfig));
441 - methods.add(getSetterForLeafList(className, curNode, pluginConfig));
442 -
443 - if (curNode instanceof YangLeavesHolder) {
444 - YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
445 - List<YangLeaf> leaves = leavesHolder.getListOfLeaf();
446 - List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList();
447 -
448 - if (leaves != null && !leaves.isEmpty()) {
449 - methods.add(getToStringLeafgetter());
450 - methods.add(getToStringSelectLeafgetter());
451 - }
452 -
453 - if (listOfLeafList != null && !listOfLeafList.isEmpty()) {
454 - methods.add(getToStringLeafListgetter());
455 - methods.add(getToStringSelectLeafListgetter());
456 - }
457 - }
458 -
459 - methods.add(getOperationTypegetter());
460 - methods.add(getOperationTypeSetter());
461 - insertDataIntoJavaFile(file, NEW_LINE);
462 - } catch (IOException e) {
463 - throw new IOException("No data found in temporary java code fragment files for " + className
464 - + " while builder class file generation");
465 - }
466 - } else {
467 - insertDataIntoJavaFile(file, NEW_LINE);
468 - }
469 429
470 - // Add methods in builder class.
471 - for (String method : methods) {
472 - insertDataIntoJavaFile(file, method);
473 - }
474 insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET); 430 insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET);
475 return validateLineLength(file); 431 return validateLineLength(file);
476 } 432 }
477 433
478 -
479 - /**
480 - * Returns generated manager class file for current node.
481 - *
482 - * @param file file
483 - * @param imports imports for the file
484 - * @param curNode current YANG node
485 - * @return builder class file
486 - * @throws IOException when fails to write in file
487 - */
488 - public static File generateManagerClassFile(File file, List<String> imports, YangNode curNode)
489 - throws IOException {
490 -
491 - JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
492 -
493 - String className = getCapitalCase(javaFileInfo.getJavaName()) + MANAGER;
494 - String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
495 -
496 - initiateJavaFileGeneration(file, GENERATE_SERVICE_AND_MANAGER, imports, curNode, className);
497 -
498 - List<String> methods = new ArrayList<>();
499 -
500 - insertDataIntoJavaFile(file, LOGGER_STATEMENT);
501 - methods.add(addActivateMethod());
502 - methods.add(addDeActivateMethod());
503 -
504 - TempJavaServiceFragmentFiles tempJavaServiceFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
505 - .getTempJavaCodeFragmentFiles().getServiceTempFiles();
506 -
507 - JavaAttributeInfo rootAttribute = getCurNodeAsAttributeInTarget(curNode, curNode, false,
508 - tempJavaServiceFragmentFiles);
509 - try {
510 - //Getter methods.
511 - methods.add(getOverRideString() +
512 - getGetterForClass(rootAttribute, GENERATE_SERVICE_AND_MANAGER) + NEW_LINE);
513 - // Setter methods.
514 - methods.add(getOverRideString() +
515 - getSetterForClass(rootAttribute, className, GENERATE_SERVICE_AND_MANAGER)
516 - + NEW_LINE);
517 -
518 - methods.add(getAugmentsDataMethodForManager(curNode) + NEW_LINE);
519 -
520 - if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) {
521 - JavaCodeGeneratorInfo javaGenInfo = (JavaCodeGeneratorInfo) curNode;
522 -
523 - //Rpc methods
524 - methods.add(getDataFromTempFileHandle(RPC_IMPL_MASK,
525 - javaGenInfo.getTempJavaCodeFragmentFiles().getServiceTempFiles(), path));
526 - }
527 - insertDataIntoJavaFile(file, NEW_LINE);
528 -
529 - } catch (IOException e) {
530 - throw new IOException("No data found in temporary java code fragment files for " + className
531 - + " while manager class file generation");
532 - }
533 -
534 - // Add methods in builder class.
535 - for (String method : methods) {
536 - insertDataIntoJavaFile(file, method);
537 - }
538 - return validateLineLength(file);
539 - }
540 -
541 /** 434 /**
542 - * Returns generated impl class file for current node. 435 + * Returns generated default class file for current node.
543 * 436 *
544 * @param file file 437 * @param file file
545 * @param curNode current YANG node 438 * @param curNode current YANG node
...@@ -548,25 +441,41 @@ public final class JavaFileGenerator { ...@@ -548,25 +441,41 @@ public final class JavaFileGenerator {
548 * @return impl class file 441 * @return impl class file
549 * @throws IOException when fails to write in file 442 * @throws IOException when fails to write in file
550 */ 443 */
551 - public static File generateImplClassFile(File file, YangNode curNode, boolean isAttrPresent, List<String> imports) 444 + public static File generateDefaultClassFile(File file, YangNode curNode, boolean isAttrPresent,
445 + List<String> imports)
552 throws IOException { 446 throws IOException {
553 447
554 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); 448 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
555 YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); 449 YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig();
556 450
451 + boolean isLeavesPresent;
452 + YangLeavesHolder leavesHolder;
453 + if (curNode instanceof YangLeavesHolder) {
454 + leavesHolder = (YangLeavesHolder) curNode;
455 + isLeavesPresent = leavesHolder.getListOfLeaf() != null && !leavesHolder.getListOfLeaf().isEmpty()
456 + || leavesHolder.getListOfLeafList() != null && !leavesHolder.getListOfLeafList().isEmpty();
457 + } else {
458 + isLeavesPresent = false;
459 + }
460 +
461 + boolean isRootNode = false;
462 +
557 String className = getCapitalCase(javaFileInfo.getJavaName()); 463 String className = getCapitalCase(javaFileInfo.getJavaName());
464 + String opParamClassName = className;
558 String path; 465 String path;
559 if (curNode instanceof YangModule || curNode instanceof YangSubModule) { 466 if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
467 + opParamClassName = className + OP_PARAM;
468 + isRootNode = true;
560 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); 469 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath();
561 } else { 470 } else {
562 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 471 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
563 } 472 }
564 473
565 - initiateJavaFileGeneration(file, IMPL_CLASS_MASK, imports, curNode, className); 474 + initiateJavaFileGeneration(file, DEFAULT_CLASS_MASK, imports, curNode, className);
566 475
567 List<String> methods = new ArrayList<>(); 476 List<String> methods = new ArrayList<>();
568 if (curNode instanceof YangAugmentableNode) { 477 if (curNode instanceof YangAugmentableNode) {
569 - insertDataIntoJavaFile(file, addAugmentationAttribute()); 478 + insertDataIntoJavaFile(file, JavaCodeSnippetGen.addAugmentationAttribute());
570 } 479 }
571 if (isAttrPresent) { 480 if (isAttrPresent) {
572 481
...@@ -581,12 +490,23 @@ public final class JavaFileGenerator { ...@@ -581,12 +490,23 @@ public final class JavaFileGenerator {
581 + " while impl class file generation"); 490 + " while impl class file generation");
582 } 491 }
583 492
493 + //Add operation attributes
494 + insertDataIntoJavaFile(file, getOperationTypeEnum());
495 + insertDataIntoJavaFile(file, getOperationTypeAttr());
496 + if (isLeavesPresent) {
497 + insertDataIntoJavaFile(file, getOperationAttributes());
498 + }
499 +
584 try { 500 try {
585 //Getter methods. 501 //Getter methods.
586 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, 502 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK,
587 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 503 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
588 .getBeanTempFiles(), path)); 504 .getBeanTempFiles(), path));
589 505
506 + //Add to list impl method.
507 + methods.add(getDataFromTempFileHandle(ADD_TO_LIST_IMPL_MASK,
508 + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
509 + .getBeanTempFiles(), path));
590 510
591 // Hash code method. 511 // Hash code method.
592 methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + 512 methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() +
...@@ -595,11 +515,17 @@ public final class JavaFileGenerator { ...@@ -595,11 +515,17 @@ public final class JavaFileGenerator {
595 .getBeanTempFiles(), path).replace(NEW_LINE, EMPTY_STRING))); 515 .getBeanTempFiles(), path).replace(NEW_LINE, EMPTY_STRING)));
596 516
597 //Equals method. 517 //Equals method.
598 - methods.add(getEqualsMethodClose(getEqualsMethodOpen(getCapitalCase(DEFAULT) + className) 518 + if (isRootNode) {
599 - + getDataFromTempFileHandle(EQUALS_IMPL_MASK, 519 + methods.add(getEqualsMethodClose(getEqualsMethodOpen(opParamClassName)
600 - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 520 + + getDataFromTempFileHandle(EQUALS_IMPL_MASK,
601 - .getBeanTempFiles(), path))); 521 + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
602 - 522 + .getBeanTempFiles(), path)));
523 + } else {
524 + methods.add(getEqualsMethodClose(getEqualsMethodOpen(getCapitalCase(DEFAULT) + className)
525 + + getDataFromTempFileHandle(EQUALS_IMPL_MASK,
526 + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
527 + .getBeanTempFiles(), path)));
528 + }
603 // To string method. 529 // To string method.
604 methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, 530 methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK,
605 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 531 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
...@@ -613,186 +539,45 @@ public final class JavaFileGenerator { ...@@ -613,186 +539,45 @@ public final class JavaFileGenerator {
613 } else { 539 } else {
614 insertDataIntoJavaFile(file, NEW_LINE); 540 insertDataIntoJavaFile(file, NEW_LINE);
615 } 541 }
616 - try {
617 542
543 + if (curNode instanceof YangAugmentableNode) {
544 + methods.add(getAddAugmentInfoMethodImpl());
545 + methods.add(getYangAugmentInfoImpl());
546 + methods.add(getYangAugmentInfoMapImpl());
547 + }
548 + try {
618 //Constructor. 549 //Constructor.
619 - String constructor = getConstructorStart(className, pluginConfig); 550 + String constructor = getConstructorStart(className, pluginConfig, isRootNode);
620 constructor = constructor + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK, 551 constructor = constructor + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK,
621 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 552 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
622 .getBeanTempFiles(), path); 553 .getBeanTempFiles(), path);
623 554
624 - methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET); 555 + if (isAttrPresent) {
556 + constructor = constructor + getOperationTypeForConstructor();
557 + }
558 + if (isLeavesPresent) {
559 + constructor = constructor + getOperationAttributeForConstructor();
560 + }
561 + methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE);
625 } catch (IOException e) { 562 } catch (IOException e) {
626 throw new IOException("No data found in temporary java code fragment files for " + className 563 throw new IOException("No data found in temporary java code fragment files for " + className
627 + " while impl class file generation"); 564 + " while impl class file generation");
628 } 565 }
629 566
630 - if (curNode instanceof YangAugmentableNode) { 567 + methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
631 - methods.add(getAddAugmentInfoMethodImpl()); 568 + .addDefaultConstructor(PUBLIC, DEFAULT, pluginConfig, curNode));
632 - methods.add(getAugmentInfoImpl());
633 - methods.add(getAugmentInfoMapImpl(javaFileInfo.getPluginConfig()));
634 - }
635 -
636 - // Add methods in impl class.
637 - for (String method : methods) {
638 - insertDataIntoJavaFile(file, method);
639 - }
640 -
641 - return validateLineLength(file);
642 - }
643 -
644 - /**
645 - * Returns generated op param class file for current node.
646 - *
647 - * @param file file handle
648 - * @param curNode current YANG node
649 - * @param isAttrPresent if any attribute is present or not
650 - * @param imports import list
651 - * @return returns generated op param class file for current node
652 - * @throws IOException when fails to write in file
653 - */
654 - public static File generateOpParamImplClassFile(File file, YangNode curNode,
655 - boolean isAttrPresent, List<String> imports)
656 - throws IOException {
657 -
658 - JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
659 - YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig();
660 -
661 - String className = getCapitalCase(javaFileInfo.getJavaName());
662 -
663 - initiateJavaFileGeneration(file, OPERATION_CLASS_MASK, imports, curNode, className);
664 -
665 - List<String> methods = new ArrayList<>();
666 -
667 - if (isAttrPresent) {
668 -
669 - // Add attribute strings.
670 - try {
671 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC +
672 - SPACE + ENUM + SPACE + OPERATION_ENUM + SPACE + OPEN_CURLY_BRACKET +
673 - NEW_LINE + EIGHT_SPACE_INDENTATION + MERGE +
674 - NEW_LINE + EIGHT_SPACE_INDENTATION + REPLACE +
675 - NEW_LINE + EIGHT_SPACE_INDENTATION + CREATE +
676 - NEW_LINE + EIGHT_SPACE_INDENTATION + DELETE +
677 - NEW_LINE + EIGHT_SPACE_INDENTATION + REMOVE +
678 - NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE);
679 -
680 - } catch (IOException e) {
681 - throw new IOException("No data found in temporary java code fragment files for " + className
682 - + " while impl class file generation");
683 - }
684 -
685 -
686 - // Add attribute strings.
687 - try {
688 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
689 - OPERATION_ENUM + SPACE + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE);
690 -
691 - } catch (IOException e) {
692 - throw new IOException("No data found in temporary java code fragment files for " + className
693 - + " while impl class file generation");
694 - }
695 -
696 - try {
697 - if (curNode instanceof YangLeavesHolder) {
698 - YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
699 - List<YangLeaf> leaves = leavesHolder.getListOfLeaf();
700 - List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList();
701 -
702 - if (leaves != null && !leaves.isEmpty()) {
703 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
704 - BITSET + SPACE + FILTER_LEAF + SPACE + EQUAL + SPACE +
705 - NEW + SPACE + BITSET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
706 - + SEMI_COLAN + NEW_LINE);
707 -
708 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
709 - BITSET + SPACE + SELECT_LEAF + SPACE + EQUAL + SPACE +
710 - NEW + SPACE + BITSET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
711 - + SEMI_COLAN + NEW_LINE);
712 - }
713 -
714 - if (listOfLeafList != null && !listOfLeafList.isEmpty()) {
715 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
716 - BITSET + SPACE + FILTER_LEAF_LIST + SPACE + EQUAL + SPACE +
717 - NEW + SPACE + BITSET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
718 - + SEMI_COLAN + NEW_LINE);
719 -
720 - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
721 - BITSET + SPACE + SELECT_LEAF_LIST + SPACE + EQUAL + SPACE +
722 - NEW + SPACE + BITSET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
723 - + SEMI_COLAN + NEW_LINE);
724 - }
725 - }
726 -
727 - } catch (IOException e) {
728 - throw new IOException("No data found in temporary java code fragment files for " + className
729 - + " while impl class file generation");
730 - }
731 -
732 - if (curNode instanceof YangLeavesHolder) {
733 - YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
734 - List<YangLeaf> leaves = leavesHolder.getListOfLeaf();
735 - List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList();
736 -
737 - if (leaves != null && !leaves.isEmpty()) {
738 - methods.add(getToStringLeafgetter());
739 - methods.add(getToStringSelectLeafgetter());
740 - }
741 -
742 - if (listOfLeafList != null && !listOfLeafList.isEmpty()) {
743 - methods.add(getToStringLeafListgetter());
744 - methods.add(getToStringSelectLeafListgetter());
745 - }
746 - }
747 -
748 - methods.add(getOperationTypegetter());
749 - methods.add(getIsFilterContentMatch(className, curNode, pluginConfig));
750 -
751 - } else {
752 - insertDataIntoJavaFile(file, NEW_LINE);
753 - }
754 - String constructor = getOpParamConstructorStart(className, pluginConfig);
755 -
756 - constructor = constructor + EIGHT_SPACE_INDENTATION + SUPER + OPEN_PARENTHESIS
757 - + BUILDER.toLowerCase() + OBJECT
758 - + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
759 -
760 - if (curNode instanceof YangLeavesHolder) {
761 - YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
762 - List<YangLeaf> leaves = leavesHolder.getListOfLeaf();
763 - List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList();
764 - String filterLeaf = "";
765 - String filterLeafList = "";
766 -
767 - if (leaves != null && !leaves.isEmpty()) {
768 - filterLeaf = EIGHT_SPACE_INDENTATION + FILTER_LEAF + SPACE + EQUAL + SPACE
769 - + BUILDER.toLowerCase() + OBJECT + PERIOD + GET_FILTER_LEAF + OPEN_PARENTHESIS
770 - + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
771 - }
772 -
773 - if (listOfLeafList != null && !listOfLeafList.isEmpty()) {
774 - filterLeafList = EIGHT_SPACE_INDENTATION + FILTER_LEAF_LIST + SPACE + EQUAL + SPACE
775 - + BUILDER.toLowerCase() + OBJECT + PERIOD + GET_FILTER_LEAF_LIST + OPEN_PARENTHESIS
776 - + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
777 - }
778 -
779 - constructor = constructor + filterLeaf + filterLeafList;
780 - }
781 -
782 - methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET);
783 569
784 - if (curNode instanceof YangAugment) { 570 + methods.add(builderMethod(className));
785 - String clsName = getCapitalCase(DEFAULT) + 571 + methods.add(getIsFilterContentMatch(curNode, pluginConfig));
786 - getCapitalCase(YangJavaModelUtils.getAugmentClassName((YangAugment) curNode, pluginConfig)); 572 + if (isLeavesPresent) {
787 - methods.add(getBaseClassMethodImpl(clsName)); 573 + methods.add(getOperationAttributesGetters());
574 + methods.add(getGettersForValueAndSelectLeaf());
788 } 575 }
789 -
790 // Add methods in impl class. 576 // Add methods in impl class.
791 for (String method : methods) { 577 for (String method : methods) {
792 insertDataIntoJavaFile(file, method); 578 insertDataIntoJavaFile(file, method);
793 } 579 }
794 580
795 -
796 return validateLineLength(file); 581 return validateLineLength(file);
797 } 582 }
798 583
...@@ -818,7 +603,7 @@ public final class JavaFileGenerator { ...@@ -818,7 +603,7 @@ public final class JavaFileGenerator {
818 List<YangType<?>> types = typeDef.getTypeList(); 603 List<YangType<?>> types = typeDef.getTypeList();
819 YangType type = types.get(0); 604 YangType type = types.get(0);
820 YangDataTypes yangDataTypes = type.getDataType(); 605 YangDataTypes yangDataTypes = type.getDataType();
821 - if (type.getDataType().equals(YangDataTypes.BINARY)) { 606 + if (type.getDataType().equals(BINARY)) {
822 imports.add(IMPORT + JAVA_UTIL_OBJECTS_IMPORT_PKG + PERIOD + JAVA_UTIL_IMPORT_BASE64_CLASS); 607 imports.add(IMPORT + JAVA_UTIL_OBJECTS_IMPORT_PKG + PERIOD + JAVA_UTIL_IMPORT_BASE64_CLASS);
823 } 608 }
824 609
...@@ -841,11 +626,10 @@ public final class JavaFileGenerator { ...@@ -841,11 +626,10 @@ public final class JavaFileGenerator {
841 626
842 //Default constructor. 627 //Default constructor.
843 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 628 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
844 - .addDefaultConstructor(PRIVATE, EMPTY_STRING, pluginConfig)); 629 + .addDefaultConstructor(PRIVATE, EMPTY_STRING, pluginConfig, curNode));
845 630
846 try { 631 try {
847 632
848 -
849 //Type constructor. 633 //Type constructor.
850 methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK, 634 methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK,
851 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), 635 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
...@@ -879,27 +663,27 @@ public final class JavaFileGenerator { ...@@ -879,27 +663,27 @@ public final class JavaFileGenerator {
879 663
880 664
881 //To string method. 665 //To string method.
882 - if (type.getDataType().equals(YangDataTypes.BINARY)) { 666 + if (type.getDataType().equals(BINARY)) {
883 JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, 667 JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
884 getCapitalCase("binary")); 668 getCapitalCase("binary"));
885 669
886 JavaAttributeInfo attr = getAttributeInfoForTheData(qualifiedTypeInfo, "binary", null, false, 670 JavaAttributeInfo attr = getAttributeInfoForTheData(qualifiedTypeInfo, "binary", null, false,
887 false); 671 false);
888 String attributeName = attr.getAttributeName(); 672 String attributeName = attr.getAttributeName();
889 - String bitsToStringMethod = MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC 673 + String bitsToStringMethod = getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC
890 + SPACE + STRING_DATA_TYPE + SPACE + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS 674 + SPACE + STRING_DATA_TYPE + SPACE + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS
891 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION 675 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
892 + RETURN + SPACE + BASE64 + PERIOD + GET_ENCODER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS 676 + RETURN + SPACE + BASE64 + PERIOD + GET_ENCODER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
893 + PERIOD + ENCODE_TO_STRING + OPEN_PARENTHESIS + attributeName + CLOSE_PARENTHESIS 677 + PERIOD + ENCODE_TO_STRING + OPEN_PARENTHESIS + attributeName + CLOSE_PARENTHESIS
894 + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 678 + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
895 methods.add(bitsToStringMethod); 679 methods.add(bitsToStringMethod);
896 - } else if (type.getDataType().equals(YangDataTypes.BITS)) { 680 + } else if (type.getDataType().equals(BITS)) {
897 JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, 681 JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
898 getCapitalCase("bits")); 682 getCapitalCase("bits"));
899 683
900 JavaAttributeInfo attr = getAttributeInfoForTheData(qualifiedTypeInfo, "bits", null, false, false); 684 JavaAttributeInfo attr = getAttributeInfoForTheData(qualifiedTypeInfo, "bits", null, false, false);
901 String attributeName = attr.getAttributeName(); 685 String attributeName = attr.getAttributeName();
902 - String bitsToStringMethod = MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC 686 + String bitsToStringMethod = getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC
903 + SPACE + STRING_DATA_TYPE + SPACE + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS 687 + SPACE + STRING_DATA_TYPE + SPACE + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS
904 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION 688 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
905 + RETURN + SPACE + attributeName + PERIOD + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS 689 + RETURN + SPACE + attributeName + PERIOD + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS
...@@ -914,6 +698,7 @@ public final class JavaFileGenerator { ...@@ -914,6 +698,7 @@ public final class JavaFileGenerator {
914 698
915 JavaCodeGeneratorInfo javaGenInfo = (JavaCodeGeneratorInfo) curNode; 699 JavaCodeGeneratorInfo javaGenInfo = (JavaCodeGeneratorInfo) curNode;
916 700
701 + //From string method.
917 if ((type.getDataType().equals(YangDataTypes.DERIVED)) 702 if ((type.getDataType().equals(YangDataTypes.DERIVED))
918 && (((YangDerivedInfo) type.getDataTypeExtendedInfo()).getEffectiveBuiltInType() 703 && (((YangDerivedInfo) type.getDataTypeExtendedInfo()).getEffectiveBuiltInType()
919 .equals(YangDataTypes.IDENTITYREF))) { 704 .equals(YangDataTypes.IDENTITYREF))) {
...@@ -925,14 +710,10 @@ public final class JavaFileGenerator { ...@@ -925,14 +710,10 @@ public final class JavaFileGenerator {
925 } 710 }
926 711
927 if (!yangDataTypes.equals(YangDataTypes.IDENTITYREF)) { 712 if (!yangDataTypes.equals(YangDataTypes.IDENTITYREF)) {
928 -
929 -
930 - //From string method.
931 methods.add(getFromStringMethodSignature(className, pluginConfig) 713 methods.add(getFromStringMethodSignature(className, pluginConfig)
932 - + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, javaGenInfo 714 + + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, javaGenInfo.getTempJavaCodeFragmentFiles()
933 - .getTempJavaCodeFragmentFiles()
934 .getTypeTempFiles(), path) 715 .getTypeTempFiles(), path)
935 - + getFromStringMethodClose()); 716 + + getFromStringMethodClose());
936 } 717 }
937 718
938 } catch (IOException e) { 719 } catch (IOException e) {
...@@ -1022,7 +803,7 @@ public final class JavaFileGenerator { ...@@ -1022,7 +803,7 @@ public final class JavaFileGenerator {
1022 803
1023 //Default constructor. 804 //Default constructor.
1024 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 805 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
1025 - .addDefaultConstructor(PRIVATE, EMPTY_STRING, pluginConfig)); 806 + .addDefaultConstructor(PRIVATE, EMPTY_STRING, pluginConfig, curNode));
1026 807
1027 try { 808 try {
1028 809
...@@ -1074,10 +855,10 @@ public final class JavaFileGenerator { ...@@ -1074,10 +855,10 @@ public final class JavaFileGenerator {
1074 + getFromStringMethodClose()); 855 + getFromStringMethodClose());
1075 856
1076 if (isIntConflict) { 857 if (isIntConflict) {
1077 - methods.add(MethodsGenerator.getRangeValidatorMethodForUnion(INT)); 858 + methods.add(getRangeValidatorMethodForUnion(INT));
1078 } 859 }
1079 if (isLongConflict) { 860 if (isLongConflict) {
1080 - methods.add(MethodsGenerator.getRangeValidatorMethodForUnion(BIG_INTEGER)); 861 + methods.add(getRangeValidatorMethodForUnion(BIG_INTEGER));
1081 } 862 }
1082 863
1083 } catch (IOException e) { 864 } catch (IOException e) {
......
...@@ -20,11 +20,14 @@ import java.io.File; ...@@ -20,11 +20,14 @@ import java.io.File;
20 import java.io.IOException; 20 import java.io.IOException;
21 import java.util.ArrayList; 21 import java.util.ArrayList;
22 import java.util.List; 22 import java.util.List;
23 +
23 import org.onosproject.yangutils.datamodel.YangAtomicPath; 24 import org.onosproject.yangutils.datamodel.YangAtomicPath;
24 import org.onosproject.yangutils.datamodel.YangAugment; 25 import org.onosproject.yangutils.datamodel.YangAugment;
25 import org.onosproject.yangutils.datamodel.YangLeafRef; 26 import org.onosproject.yangutils.datamodel.YangLeafRef;
27 +import org.onosproject.yangutils.datamodel.YangModule;
26 import org.onosproject.yangutils.datamodel.YangNode; 28 import org.onosproject.yangutils.datamodel.YangNode;
27 import org.onosproject.yangutils.datamodel.YangNodeIdentifier; 29 import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
30 +import org.onosproject.yangutils.datamodel.YangSubModule;
28 import org.onosproject.yangutils.datamodel.YangType; 31 import org.onosproject.yangutils.datamodel.YangType;
29 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 32 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
30 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 33 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
...@@ -46,6 +49,7 @@ import org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType; ...@@ -46,6 +49,7 @@ import org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType;
46 49
47 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; 50 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
48 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; 51 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
52 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
49 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; 53 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
50 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; 54 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
51 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; 55 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
...@@ -54,10 +58,9 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -54,10 +58,9 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
54 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 58 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
55 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; 59 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
56 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; 60 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
57 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
58 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; 61 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
59 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK; 62 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK;
60 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_CLASS_MASK; 63 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK;
61 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; 64 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
62 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; 65 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK;
63 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; 66 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
...@@ -72,6 +75,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. ...@@ -72,6 +75,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.
72 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; 75 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
73 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK; 76 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
74 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK; 77 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK;
78 +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK;
75 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK; 79 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK;
76 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK; 80 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK;
77 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK; 81 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK;
...@@ -79,14 +83,14 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. ...@@ -79,14 +83,14 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.
79 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; 83 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
80 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; 84 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
81 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode; 85 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
82 -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getAugmentedNodesPackage; 86 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getNodesPackage;
83 import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; 87 import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition;
84 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 88 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
85 import static org.onosproject.yangutils.utils.UtilConstants.LEAFREF; 89 import static org.onosproject.yangutils.utils.UtilConstants.LEAFREF;
86 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 90 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
91 +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
87 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE; 92 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE;
88 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 93 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
89 -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE;
90 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 94 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
91 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 95 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
92 import static org.onosproject.yangutils.utils.UtilConstants.SPACE; 96 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
...@@ -98,9 +102,7 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVE ...@@ -98,9 +102,7 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVE
98 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVENT_SUBJECT_CLASS; 102 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVENT_SUBJECT_CLASS;
99 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.IMPL_CLASS; 103 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.IMPL_CLASS;
100 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INTERFACE; 104 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INTERFACE;
101 -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OPERATION_CLASS;
102 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_INTERFACE; 105 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_INTERFACE;
103 -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_MANAGER;
104 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; 106 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
105 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 107 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
106 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 108 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
...@@ -122,15 +124,14 @@ public final class JavaFileGeneratorUtils { ...@@ -122,15 +124,14 @@ public final class JavaFileGeneratorUtils {
122 /** 124 /**
123 * Returns a file object for generated file. 125 * Returns a file object for generated file.
124 * 126 *
125 - * @param filePath file package path 127 + * @param filePath file package path
126 - * @param fileName file name 128 + * @param fileName file name
127 - * @param extension file extension 129 + * @param extension file extension
128 - * @param baseCodePath cached file handle 130 + * @param handler cached file handle
129 * @return file object 131 * @return file object
130 */ 132 */
131 - public static File getFileObject(String filePath, String fileName, String extension, String baseCodePath) { 133 + public static File getFileObject(String filePath, String fileName, String extension, JavaFileInfo handler) {
132 - 134 + return new File(handler.getBaseCodeGenPath() + filePath + SLASH + fileName + extension);
133 - return new File(baseCodePath + filePath + SLASH + fileName + extension);
134 } 135 }
135 136
136 /** 137 /**
...@@ -188,6 +189,18 @@ public final class JavaFileGeneratorUtils { ...@@ -188,6 +189,18 @@ public final class JavaFileGeneratorUtils {
188 return tempJavaFragmentFiles 189 return tempJavaFragmentFiles
189 .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSetterImplTempFileHandle(), 190 .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSetterImplTempFileHandle(),
190 absolutePath); 191 absolutePath);
192 + } else if ((generatedTempFiles & ADD_TO_LIST_INTERFACE_MASK) != 0) {
193 + return tempJavaFragmentFiles
194 + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAddToListInterfaceTempFileHandle(),
195 + absolutePath);
196 + } else if ((generatedTempFiles & ADD_TO_LIST_IMPL_MASK) != 0) {
197 + return tempJavaFragmentFiles
198 + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAddToListImplTempFileHandle(),
199 + absolutePath);
200 + } else if ((generatedTempFiles & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) {
201 + return tempJavaFragmentFiles
202 + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getLeafIdAttributeTempFileHandle(),
203 + absolutePath);
191 } else if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) { 204 } else if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) {
192 if (beanFragmentFiles == null) { 205 if (beanFragmentFiles == null) {
193 throw new TranslatorException("Required constructor info is missing."); 206 throw new TranslatorException("Required constructor info is missing.");
...@@ -370,20 +383,13 @@ public final class JavaFileGeneratorUtils { ...@@ -370,20 +383,13 @@ public final class JavaFileGeneratorUtils {
370 appendHeaderContents(file, pkgString, importsList); 383 appendHeaderContents(file, pkgString, importsList);
371 write(file, genType, INTERFACE, curNode, className); 384 write(file, genType, INTERFACE, curNode, className);
372 break; 385 break;
373 - case IMPL_CLASS_MASK: 386 + case DEFAULT_CLASS_MASK:
374 appendHeaderContents(file, pkgString, importsList); 387 appendHeaderContents(file, pkgString, importsList);
375 write(file, genType, IMPL_CLASS, curNode, className); 388 write(file, genType, IMPL_CLASS, curNode, className);
376 break; 389 break;
377 - case OPERATION_CLASS_MASK:
378 - appendHeaderContents(file, pkgString, importsList);
379 - write(file, genType, OPERATION_CLASS, curNode, className);
380 - break;
381 case BUILDER_CLASS_MASK: 390 case BUILDER_CLASS_MASK:
382 write(file, genType, BUILDER_CLASS, curNode, className); 391 write(file, genType, BUILDER_CLASS, curNode, className);
383 break; 392 break;
384 - case OPERATION_BUILDER_CLASS_MASK:
385 - write(file, genType, BUILDER_CLASS, curNode, className);
386 - break;
387 case BUILDER_INTERFACE_MASK: 393 case BUILDER_INTERFACE_MASK:
388 write(file, genType, BUILDER_INTERFACE, curNode, className); 394 write(file, genType, BUILDER_INTERFACE, curNode, className);
389 break; 395 break;
...@@ -511,16 +517,7 @@ public final class JavaFileGeneratorUtils { ...@@ -511,16 +517,7 @@ public final class JavaFileGeneratorUtils {
511 throws IOException { 517 throws IOException {
512 518
513 YangPluginConfig pluginConfig = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPluginConfig(); 519 YangPluginConfig pluginConfig = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPluginConfig();
514 - if ((genType & GENERATE_SERVICE_AND_MANAGER) != 0) { 520 + insertDataIntoJavaFile(file, getJavaDoc(javaDocType, fileName, false, pluginConfig));
515 - if (!fileName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) {
516 - insertDataIntoJavaFile(file, getJavaDoc(RPC_MANAGER, fileName, false, pluginConfig));
517 - insertDataIntoJavaFile(file, JavaCodeSnippetGen.addComponentString());
518 - } else {
519 - insertDataIntoJavaFile(file, getJavaDoc(javaDocType, fileName, false, pluginConfig));
520 - }
521 - } else {
522 - insertDataIntoJavaFile(file, getJavaDoc(javaDocType, fileName, false, pluginConfig));
523 - }
524 insertDataIntoJavaFile(file, generateClassDefinition(genType, fileName, curNode)); 521 insertDataIntoJavaFile(file, generateClassDefinition(genType, fileName, curNode));
525 } 522 }
526 523
...@@ -616,6 +613,13 @@ public final class JavaFileGeneratorUtils { ...@@ -616,6 +613,13 @@ public final class JavaFileGeneratorUtils {
616 parentInfo.getPluginConfig()); 613 parentInfo.getPluginConfig());
617 tempJavaCodeFragmentFiles.getServiceTempFiles().getJavaImportData().addImportInfo(javaQualifiedTypeInfo, 614 tempJavaCodeFragmentFiles.getServiceTempFiles().getJavaImportData().addImportInfo(javaQualifiedTypeInfo,
618 parentInfo.getJavaName(), parentInfo.getPackage()); 615 parentInfo.getJavaName(), parentInfo.getPackage());
616 + if (augmentedNode instanceof YangModule || augmentedNode instanceof YangSubModule) {
617 + javaQualifiedTypeInfo = getQualifiedTypeInfoOfAugmentedNode(augmentedNode,
618 + getCapitalCase(curNodeName) + OP_PARAM,
619 + parentInfo.getPluginConfig());
620 + tempJavaCodeFragmentFiles.getServiceTempFiles().getJavaImportData().addImportInfo(javaQualifiedTypeInfo,
621 + parentInfo.getJavaName(), parentInfo.getPackage());
622 + }
619 623
620 } 624 }
621 } 625 }
...@@ -634,7 +638,7 @@ public final class JavaFileGeneratorUtils { ...@@ -634,7 +638,7 @@ public final class JavaFileGeneratorUtils {
634 JavaQualifiedTypeInfoTranslator javaQualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(augmentedNode, 638 JavaQualifiedTypeInfoTranslator javaQualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(augmentedNode,
635 getCapitalCase(curNodeName)); 639 getCapitalCase(curNodeName));
636 if (javaQualifiedTypeInfo.getPkgInfo() == null) { 640 if (javaQualifiedTypeInfo.getPkgInfo() == null) {
637 - javaQualifiedTypeInfo.setPkgInfo(getAugmentedNodesPackage(augmentedNode, 641 + javaQualifiedTypeInfo.setPkgInfo(getNodesPackage(augmentedNode,
638 pluginConfig)); 642 pluginConfig));
639 } 643 }
640 return javaQualifiedTypeInfo; 644 return javaQualifiedTypeInfo;
...@@ -735,4 +739,5 @@ public final class JavaFileGeneratorUtils { ...@@ -735,4 +739,5 @@ public final class JavaFileGeneratorUtils {
735 } 739 }
736 return attributeType; 740 return attributeType;
737 } 741 }
742 +
738 } 743 }
......
...@@ -20,14 +20,16 @@ import java.io.File; ...@@ -20,14 +20,16 @@ import java.io.File;
20 import java.io.IOException; 20 import java.io.IOException;
21 import java.text.SimpleDateFormat; 21 import java.text.SimpleDateFormat;
22 import java.util.ArrayList; 22 import java.util.ArrayList;
23 +import java.util.Arrays;
24 +import java.util.Collections;
23 import java.util.Date; 25 import java.util.Date;
24 import java.util.List; 26 import java.util.List;
27 +
25 import org.onosproject.yangutils.datamodel.YangNode; 28 import org.onosproject.yangutils.datamodel.YangNode;
26 -import org.onosproject.yangutils.translator.exception.TranslatorException;
27 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo; 29 import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
28 -import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
29 -import org.onosproject.yangutils.utils.io.impl.YangIoUtils;
30 import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflictUtil; 30 import org.onosproject.yangutils.datamodel.javadatamodel.YangToJavaNamingConflictUtil;
31 +import org.onosproject.yangutils.translator.exception.TranslatorException;
32 +import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
31 33
32 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; 34 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
33 import static org.onosproject.yangutils.utils.UtilConstants.COLAN; 35 import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
...@@ -48,6 +50,7 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirector ...@@ -48,6 +50,7 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirector
48 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; 50 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
49 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; 51 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath;
50 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; 52 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
53 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPrefixForIdentifier;
51 54
52 /** 55 /**
53 * Represents an utility Class for translating the name from YANG to java convention. 56 * Represents an utility Class for translating the name from YANG to java convention.
...@@ -109,14 +112,12 @@ public final class JavaIdentifierSyntax { ...@@ -109,14 +112,12 @@ public final class JavaIdentifierSyntax {
109 */ 112 */
110 private static String getPkgFromNameSpace(String nameSpace, YangToJavaNamingConflictUtil conflictResolver) { 113 private static String getPkgFromNameSpace(String nameSpace, YangToJavaNamingConflictUtil conflictResolver) {
111 114
112 - ArrayList<String> pkgArr = new ArrayList<String>(); 115 + ArrayList<String> pkgArr = new ArrayList<>();
113 nameSpace = nameSpace.replace(QUOTES, EMPTY_STRING); 116 nameSpace = nameSpace.replace(QUOTES, EMPTY_STRING);
114 String properNameSpace = nameSpace.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLAN); 117 String properNameSpace = nameSpace.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLAN);
115 String[] nameSpaceArr = properNameSpace.split(COLAN); 118 String[] nameSpaceArr = properNameSpace.split(COLAN);
116 119
117 - for (String nameSpaceString : nameSpaceArr) { 120 + Collections.addAll(pkgArr, nameSpaceArr);
118 - pkgArr.add(nameSpaceString);
119 - }
120 return getPkgFrmArr(pkgArr, conflictResolver); 121 return getPkgFrmArr(pkgArr, conflictResolver);
121 } 122 }
122 123
...@@ -159,7 +160,7 @@ public final class JavaIdentifierSyntax { ...@@ -159,7 +160,7 @@ public final class JavaIdentifierSyntax {
159 for (String member : pkgArr) { 160 for (String member : pkgArr) {
160 boolean presenceOfKeyword = JAVA_KEY_WORDS.contains(member.toLowerCase()); 161 boolean presenceOfKeyword = JAVA_KEY_WORDS.contains(member.toLowerCase());
161 if (presenceOfKeyword || member.matches(REGEX_FOR_FIRST_DIGIT)) { 162 if (presenceOfKeyword || member.matches(REGEX_FOR_FIRST_DIGIT)) {
162 - String prefix = YangIoUtils.getPrefixForIdentifier(conflictResolver); 163 + String prefix = getPrefixForIdentifier(conflictResolver);
163 member = prefix + member; 164 member = prefix + member;
164 } 165 }
165 pkg = pkg + member; 166 pkg = pkg + member;
...@@ -183,10 +184,8 @@ public final class JavaIdentifierSyntax { ...@@ -183,10 +184,8 @@ public final class JavaIdentifierSyntax {
183 String[] strArray = name.split(COLAN); 184 String[] strArray = name.split(COLAN);
184 String output = EMPTY_STRING; 185 String output = EMPTY_STRING;
185 if (strArray[0].isEmpty()) { 186 if (strArray[0].isEmpty()) {
186 - List<String> stringArrangement = new ArrayList<String>(); 187 + List<String> stringArrangement = new ArrayList<>();
187 - for (int i = 1; i < strArray.length; i++) { 188 + stringArrangement.addAll(Arrays.asList(strArray).subList(1, strArray.length));
188 - stringArrangement.add(strArray[i]);
189 - }
190 strArray = stringArrangement.toArray(new String[stringArrangement.size()]); 189 strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
191 } 190 }
192 for (int i = 0; i < strArray.length; i++) { 191 for (int i = 0; i < strArray.length; i++) {
...@@ -236,7 +235,7 @@ public final class JavaIdentifierSyntax { ...@@ -236,7 +235,7 @@ public final class JavaIdentifierSyntax {
236 * @param pkg Package to check if it is created 235 * @param pkg Package to check if it is created
237 * @return existence status of package 236 * @return existence status of package
238 */ 237 */
239 - public static boolean doesPackageExist(String pkg) { 238 + static boolean doesPackageExist(String pkg) {
240 File pkgDir = new File(getPackageDirPathFromJavaJPackage(pkg)); 239 File pkgDir = new File(getPackageDirPathFromJavaJPackage(pkg));
241 File pkgWithFile = new File(pkgDir + SLASH + "package-info.java"); 240 File pkgWithFile = new File(pkgDir + SLASH + "package-info.java");
242 return pkgDir.exists() && pkgWithFile.isFile(); 241 return pkgDir.exists() && pkgWithFile.isFile();
......
...@@ -21,12 +21,16 @@ import java.util.Map; ...@@ -21,12 +21,16 @@ import java.util.Map;
21 21
22 import org.onosproject.yangutils.datamodel.YangAtomicPath; 22 import org.onosproject.yangutils.datamodel.YangAtomicPath;
23 import org.onosproject.yangutils.datamodel.YangAugmentableNode; 23 import org.onosproject.yangutils.datamodel.YangAugmentableNode;
24 +import org.onosproject.yangutils.datamodel.YangIsFilterContentNodes;
24 import org.onosproject.yangutils.datamodel.YangLeaf; 25 import org.onosproject.yangutils.datamodel.YangLeaf;
25 import org.onosproject.yangutils.datamodel.YangLeafList; 26 import org.onosproject.yangutils.datamodel.YangLeafList;
26 import org.onosproject.yangutils.datamodel.YangLeafRef; 27 import org.onosproject.yangutils.datamodel.YangLeafRef;
27 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 28 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
29 +import org.onosproject.yangutils.datamodel.YangList;
28 import org.onosproject.yangutils.datamodel.YangNode; 30 import org.onosproject.yangutils.datamodel.YangNode;
29 import org.onosproject.yangutils.datamodel.YangType; 31 import org.onosproject.yangutils.datamodel.YangType;
32 +import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
33 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
30 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; 34 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
31 import org.onosproject.yangutils.translator.exception.TranslatorException; 35 import org.onosproject.yangutils.translator.exception.TranslatorException;
32 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; 36 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
...@@ -34,7 +38,6 @@ import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; ...@@ -34,7 +38,6 @@ import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
34 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 38 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
35 import org.onosproject.yangutils.translator.tojava.TempJavaBeanFragmentFiles; 39 import org.onosproject.yangutils.translator.tojava.TempJavaBeanFragmentFiles;
36 import org.onosproject.yangutils.utils.io.impl.JavaDocGen; 40 import org.onosproject.yangutils.utils.io.impl.JavaDocGen;
37 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
38 41
39 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BINARY; 42 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BINARY;
40 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BITS; 43 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BITS;
...@@ -58,21 +61,17 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato ...@@ -58,21 +61,17 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato
58 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods; 61 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods;
59 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers; 62 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers;
60 import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.INT_TYPE_CONFLICT; 63 import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.INT_TYPE_CONFLICT;
61 -import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE;
62 -import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION;
63 import static org.onosproject.yangutils.utils.UtilConstants.ADD; 64 import static org.onosproject.yangutils.utils.UtilConstants.ADD;
64 import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; 65 import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
65 import static org.onosproject.yangutils.utils.UtilConstants.AND; 66 import static org.onosproject.yangutils.utils.UtilConstants.AND;
66 import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE; 67 import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE;
67 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED; 68 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
68 -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO;
69 import static org.onosproject.yangutils.utils.UtilConstants.BASE64; 69 import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
70 -import static org.onosproject.yangutils.utils.UtilConstants.BASE_CLASS;
71 import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL; 70 import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL;
72 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; 71 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
73 -import static org.onosproject.yangutils.utils.UtilConstants.BITSET;
74 import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; 72 import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
75 import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER; 73 import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER;
74 +import static org.onosproject.yangutils.utils.UtilConstants.BREAK;
76 import static org.onosproject.yangutils.utils.UtilConstants.BUILD; 75 import static org.onosproject.yangutils.utils.UtilConstants.BUILD;
77 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 76 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
78 import static org.onosproject.yangutils.utils.UtilConstants.BYTE; 77 import static org.onosproject.yangutils.utils.UtilConstants.BYTE;
...@@ -87,8 +86,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; ...@@ -87,8 +86,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
87 import static org.onosproject.yangutils.utils.UtilConstants.COLAN; 86 import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
88 import static org.onosproject.yangutils.utils.UtilConstants.COLON; 87 import static org.onosproject.yangutils.utils.UtilConstants.COLON;
89 import static org.onosproject.yangutils.utils.UtilConstants.COMMA; 88 import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
90 -import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE;
91 -import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE_ANNOTATION;
92 import static org.onosproject.yangutils.utils.UtilConstants.DECODE; 89 import static org.onosproject.yangutils.utils.UtilConstants.DECODE;
93 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; 90 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
94 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; 91 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET;
...@@ -97,37 +94,40 @@ import static org.onosproject.yangutils.utils.UtilConstants.DOUBLE; ...@@ -97,37 +94,40 @@ import static org.onosproject.yangutils.utils.UtilConstants.DOUBLE;
97 import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; 94 import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
98 import static org.onosproject.yangutils.utils.UtilConstants.ELSE; 95 import static org.onosproject.yangutils.utils.UtilConstants.ELSE;
99 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 96 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
97 +import static org.onosproject.yangutils.utils.UtilConstants.ENUM;
100 import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; 98 import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
101 import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING; 99 import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING;
102 import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION; 100 import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION;
103 import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION_VAR; 101 import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION_VAR;
104 import static org.onosproject.yangutils.utils.UtilConstants.FALSE; 102 import static org.onosproject.yangutils.utils.UtilConstants.FALSE;
105 import static org.onosproject.yangutils.utils.UtilConstants.FILTER_CONTENT_MATCH; 103 import static org.onosproject.yangutils.utils.UtilConstants.FILTER_CONTENT_MATCH;
106 -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF; 104 +import static org.onosproject.yangutils.utils.UtilConstants.FLAG;
107 -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF_LIST;
108 import static org.onosproject.yangutils.utils.UtilConstants.FOR; 105 import static org.onosproject.yangutils.utils.UtilConstants.FOR;
109 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; 106 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
110 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME; 107 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME;
111 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME; 108 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME;
112 import static org.onosproject.yangutils.utils.UtilConstants.GET; 109 import static org.onosproject.yangutils.utils.UtilConstants.GET;
110 +import static org.onosproject.yangutils.utils.UtilConstants.GET_CLASS;
113 import static org.onosproject.yangutils.utils.UtilConstants.GET_DECODER; 111 import static org.onosproject.yangutils.utils.UtilConstants.GET_DECODER;
114 import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF; 112 import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF;
115 -import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF_LIST; 113 +import static org.onosproject.yangutils.utils.UtilConstants.GET_LEAF_INDEX;
114 +import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD;
116 import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX; 115 import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX;
117 -import static org.onosproject.yangutils.utils.UtilConstants.GET_OPERATION_TYPE;
118 -import static org.onosproject.yangutils.utils.UtilConstants.GET_SELECT_LEAF;
119 -import static org.onosproject.yangutils.utils.UtilConstants.GET_SELECT_LEAF_LIST;
120 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING; 116 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING;
121 import static org.onosproject.yangutils.utils.UtilConstants.HASH; 117 import static org.onosproject.yangutils.utils.UtilConstants.HASH;
122 import static org.onosproject.yangutils.utils.UtilConstants.HASH_CODE_STRING; 118 import static org.onosproject.yangutils.utils.UtilConstants.HASH_CODE_STRING;
123 import static org.onosproject.yangutils.utils.UtilConstants.IF; 119 import static org.onosproject.yangutils.utils.UtilConstants.IF;
124 -import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ARGUMENT_EXCEPTION; 120 +import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ACCESS_EXCEPTION;
125 -import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ARGUMENT_EXCEPTION_MSG;
126 import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; 121 import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF;
127 import static org.onosproject.yangutils.utils.UtilConstants.INT; 122 import static org.onosproject.yangutils.utils.UtilConstants.INT;
128 import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; 123 import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER;
129 import static org.onosproject.yangutils.utils.UtilConstants.INT_MAX_RANGE; 124 import static org.onosproject.yangutils.utils.UtilConstants.INT_MAX_RANGE;
130 import static org.onosproject.yangutils.utils.UtilConstants.INT_MIN_RANGE; 125 import static org.onosproject.yangutils.utils.UtilConstants.INT_MIN_RANGE;
126 +import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION;
127 +import static org.onosproject.yangutils.utils.UtilConstants.INVOKE;
128 +import static org.onosproject.yangutils.utils.UtilConstants.IS_EMPTY;
129 +import static org.onosproject.yangutils.utils.UtilConstants.IS_SELECT_LEAF;
130 +import static org.onosproject.yangutils.utils.UtilConstants.LEAF_IDENTIFIER;
131 import static org.onosproject.yangutils.utils.UtilConstants.LIST; 131 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
132 import static org.onosproject.yangutils.utils.UtilConstants.LONG; 132 import static org.onosproject.yangutils.utils.UtilConstants.LONG;
133 import static org.onosproject.yangutils.utils.UtilConstants.LONG_MAX_RANGE; 133 import static org.onosproject.yangutils.utils.UtilConstants.LONG_MAX_RANGE;
...@@ -139,6 +139,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.MIN_RANGE; ...@@ -139,6 +139,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.MIN_RANGE;
139 import static org.onosproject.yangutils.utils.UtilConstants.NEW; 139 import static org.onosproject.yangutils.utils.UtilConstants.NEW;
140 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 140 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
141 import static org.onosproject.yangutils.utils.UtilConstants.NOT; 141 import static org.onosproject.yangutils.utils.UtilConstants.NOT;
142 +import static org.onosproject.yangutils.utils.UtilConstants.NO_SUCH_METHOD_EXCEPTION;
142 import static org.onosproject.yangutils.utils.UtilConstants.NULL; 143 import static org.onosproject.yangutils.utils.UtilConstants.NULL;
143 import static org.onosproject.yangutils.utils.UtilConstants.OBJ; 144 import static org.onosproject.yangutils.utils.UtilConstants.OBJ;
144 import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; 145 import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
...@@ -147,9 +148,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.OF; ...@@ -147,9 +148,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.OF;
147 import static org.onosproject.yangutils.utils.UtilConstants.OMIT_NULL_VALUE_STRING; 148 import static org.onosproject.yangutils.utils.UtilConstants.OMIT_NULL_VALUE_STRING;
148 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; 149 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
149 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; 150 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
150 -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; 151 +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
151 -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION_ENUM;
152 -import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_TYPE;
153 import static org.onosproject.yangutils.utils.UtilConstants.OR_OPERATION; 152 import static org.onosproject.yangutils.utils.UtilConstants.OR_OPERATION;
154 import static org.onosproject.yangutils.utils.UtilConstants.OTHER; 153 import static org.onosproject.yangutils.utils.UtilConstants.OTHER;
155 import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE; 154 import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE;
...@@ -164,15 +163,12 @@ import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; ...@@ -164,15 +163,12 @@ import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
164 import static org.onosproject.yangutils.utils.UtilConstants.PUT; 163 import static org.onosproject.yangutils.utils.UtilConstants.PUT;
165 import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK; 164 import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK;
166 import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; 165 import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
167 -import static org.onosproject.yangutils.utils.UtilConstants.RECEIVED_OBJECT;
168 import static org.onosproject.yangutils.utils.UtilConstants.REPLACE_STRING; 166 import static org.onosproject.yangutils.utils.UtilConstants.REPLACE_STRING;
169 import static org.onosproject.yangutils.utils.UtilConstants.RETURN; 167 import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
170 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; 168 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
171 -import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF;
172 -import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF_LIST;
173 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 169 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
174 import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX; 170 import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX;
175 -import static org.onosproject.yangutils.utils.UtilConstants.SET_OPERATION_TYPE; 171 +import static org.onosproject.yangutils.utils.UtilConstants.SET_SELECT_LEAF;
176 import static org.onosproject.yangutils.utils.UtilConstants.SHORT; 172 import static org.onosproject.yangutils.utils.UtilConstants.SHORT;
177 import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER; 173 import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER;
178 import static org.onosproject.yangutils.utils.UtilConstants.SINGLE_QUOTE; 174 import static org.onosproject.yangutils.utils.UtilConstants.SINGLE_QUOTE;
...@@ -180,26 +176,27 @@ import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENT ...@@ -180,26 +176,27 @@ import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENT
180 import static org.onosproject.yangutils.utils.UtilConstants.SPACE; 176 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
181 import static org.onosproject.yangutils.utils.UtilConstants.SPLIT_STRING; 177 import static org.onosproject.yangutils.utils.UtilConstants.SPLIT_STRING;
182 import static org.onosproject.yangutils.utils.UtilConstants.SQUARE_BRACKETS; 178 import static org.onosproject.yangutils.utils.UtilConstants.SQUARE_BRACKETS;
183 -import static org.onosproject.yangutils.utils.UtilConstants.STARTED_LOG_INFO;
184 import static org.onosproject.yangutils.utils.UtilConstants.STATIC; 179 import static org.onosproject.yangutils.utils.UtilConstants.STATIC;
185 -import static org.onosproject.yangutils.utils.UtilConstants.STOPPED_LOG_INFO;
186 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; 180 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
187 import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S; 181 import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S;
188 import static org.onosproject.yangutils.utils.UtilConstants.SWITCH; 182 import static org.onosproject.yangutils.utils.UtilConstants.SWITCH;
189 import static org.onosproject.yangutils.utils.UtilConstants.THIS; 183 import static org.onosproject.yangutils.utils.UtilConstants.THIS;
190 -import static org.onosproject.yangutils.utils.UtilConstants.THROW;
191 import static org.onosproject.yangutils.utils.UtilConstants.TMP_VAL; 184 import static org.onosproject.yangutils.utils.UtilConstants.TMP_VAL;
192 import static org.onosproject.yangutils.utils.UtilConstants.TO; 185 import static org.onosproject.yangutils.utils.UtilConstants.TO;
193 import static org.onosproject.yangutils.utils.UtilConstants.TRIM_STRING; 186 import static org.onosproject.yangutils.utils.UtilConstants.TRIM_STRING;
194 import static org.onosproject.yangutils.utils.UtilConstants.TRUE; 187 import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
195 import static org.onosproject.yangutils.utils.UtilConstants.TRY; 188 import static org.onosproject.yangutils.utils.UtilConstants.TRY;
196 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; 189 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
190 +import static org.onosproject.yangutils.utils.UtilConstants.TWENTY_FOUR_SPACE_INDENTATION;
191 +import static org.onosproject.yangutils.utils.UtilConstants.TWENTY_SPACE_INDENTATION;
197 import static org.onosproject.yangutils.utils.UtilConstants.UINT_MAX_RANGE; 192 import static org.onosproject.yangutils.utils.UtilConstants.UINT_MAX_RANGE;
198 import static org.onosproject.yangutils.utils.UtilConstants.UINT_MIN_RANGE; 193 import static org.onosproject.yangutils.utils.UtilConstants.UINT_MIN_RANGE;
199 import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MAX_RANGE; 194 import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MAX_RANGE;
200 import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MIN_RANGE; 195 import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MIN_RANGE;
196 +import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE;
201 import static org.onosproject.yangutils.utils.UtilConstants.VALIDATE_RANGE; 197 import static org.onosproject.yangutils.utils.UtilConstants.VALIDATE_RANGE;
202 import static org.onosproject.yangutils.utils.UtilConstants.VALUE; 198 import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
199 +import static org.onosproject.yangutils.utils.UtilConstants.VALUE_LEAF_SET;
203 import static org.onosproject.yangutils.utils.UtilConstants.VOID; 200 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
204 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; 201 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
205 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO; 202 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO;
...@@ -215,7 +212,9 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_ ...@@ -215,7 +212,9 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_
215 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD; 212 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
216 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; 213 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR;
217 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForAddAugmentation; 214 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForAddAugmentation;
215 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForBuilderMethod;
218 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForGetAugmentation; 216 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForGetAugmentation;
217 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForGetMethodWithAttribute;
219 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForValidatorMethod; 218 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForValidatorMethod;
220 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; 219 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
221 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 220 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
...@@ -260,6 +259,10 @@ public final class MethodsGenerator { ...@@ -260,6 +259,10 @@ public final class MethodsGenerator {
260 259
261 String returnType = getReturnType(attr); 260 String returnType = getReturnType(attr);
262 String attributeName = attr.getAttributeName(); 261 String attributeName = attr.getAttributeName();
262 + if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
263 + return generateForGetMethodWithAttribute(returnType)
264 + + getGetterForInterface(attributeName, returnType, attr.isListAttr(), generatedJavaFiles);
265 + }
263 266
264 return getJavaDoc(GETTER_METHOD, attributeName, attr.isListAttr(), pluginConfig) 267 return getJavaDoc(GETTER_METHOD, attributeName, attr.isListAttr(), pluginConfig)
265 + getGetterForInterface(attributeName, returnType, attr.isListAttr(), generatedJavaFiles); 268 + getGetterForInterface(attributeName, returnType, attr.isListAttr(), generatedJavaFiles);
...@@ -297,7 +300,7 @@ public final class MethodsGenerator { ...@@ -297,7 +300,7 @@ public final class MethodsGenerator {
297 * @param pluginConfig plugin configurations 300 * @param pluginConfig plugin configurations
298 * @return constructor string 301 * @return constructor string
299 */ 302 */
300 - public static String getConstructorString(String name, YangPluginConfig pluginConfig) { 303 + private static String getConstructorString(String name, YangPluginConfig pluginConfig) {
301 return getJavaDoc(CONSTRUCTOR, name, false, pluginConfig); 304 return getJavaDoc(CONSTRUCTOR, name, false, pluginConfig);
302 } 305 }
303 306
...@@ -322,7 +325,7 @@ public final class MethodsGenerator { ...@@ -322,7 +325,7 @@ public final class MethodsGenerator {
322 * @param name attribute name 325 * @param name attribute name
323 * @return check not null string 326 * @return check not null string
324 */ 327 */
325 - public static String getCheckNotNull(String name) { 328 + static String getCheckNotNull(String name) {
326 return EIGHT_SPACE_INDENTATION + CHECK_NOT_NULL_STRING + OPEN_PARENTHESIS + name + COMMA + SPACE + name 329 return EIGHT_SPACE_INDENTATION + CHECK_NOT_NULL_STRING + OPEN_PARENTHESIS + name + COMMA + SPACE + name
327 + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; 330 + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
328 } 331 }
...@@ -330,11 +333,15 @@ public final class MethodsGenerator { ...@@ -330,11 +333,15 @@ public final class MethodsGenerator {
330 /** 333 /**
331 * Returns build method string. 334 * Returns build method string.
332 * 335 *
333 - * @param name class name 336 + * @param name class name
337 + * @param isRootNode if root node
334 * @return build string 338 * @return build string
335 */ 339 */
336 - public static String getBuildString(String name) { 340 + public static String getBuildString(String name, boolean isRootNode) {
337 - return FOUR_SPACE_INDENTATION + OVERRIDE + NEW_LINE + getBuild(name); 341 + if (isRootNode) {
342 + return NEW_LINE + getBuild(name, true);
343 + }
344 + return FOUR_SPACE_INDENTATION + OVERRIDE + NEW_LINE + getBuild(name, false);
338 } 345 }
339 346
340 /** 347 /**
...@@ -346,13 +353,13 @@ public final class MethodsGenerator { ...@@ -346,13 +353,13 @@ public final class MethodsGenerator {
346 */ 353 */
347 public static String getGetterForClass(JavaAttributeInfo attr, int generatedJavaFiles) { 354 public static String getGetterForClass(JavaAttributeInfo attr, int generatedJavaFiles) {
348 355
349 - String attrQuaifiedType = getReturnType(attr); 356 + String attrQualifiedType = getReturnType(attr);
350 String attributeName = attr.getAttributeName(); 357 String attributeName = attr.getAttributeName();
351 358
352 if (!attr.isListAttr()) { 359 if (!attr.isListAttr()) {
353 - return getGetter(attrQuaifiedType, attributeName, generatedJavaFiles); 360 + return getGetter(attrQualifiedType, attributeName, generatedJavaFiles);
354 } 361 }
355 - String listAttr = getListString() + attrQuaifiedType + DIAMOND_CLOSE_BRACKET; 362 + String listAttr = getListString() + attrQualifiedType + DIAMOND_CLOSE_BRACKET;
356 return getGetter(listAttr, attributeName, generatedJavaFiles); 363 return getGetter(listAttr, attributeName, generatedJavaFiles);
357 } 364 }
358 365
...@@ -364,7 +371,7 @@ public final class MethodsGenerator { ...@@ -364,7 +371,7 @@ public final class MethodsGenerator {
364 * @param generatedJavaFiles generated java files 371 * @param generatedJavaFiles generated java files
365 * @return getter for attribute 372 * @return getter for attribute
366 */ 373 */
367 - public static String getGetter(String type, String name, int generatedJavaFiles) { 374 + static String getGetter(String type, String name, int generatedJavaFiles) {
368 String ret = parseTypeForReturnValue(type); 375 String ret = parseTypeForReturnValue(type);
369 if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) { 376 if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
370 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + type + SPACE + GET_METHOD_PREFIX + getCapitalCase(name) 377 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + type + SPACE + GET_METHOD_PREFIX + getCapitalCase(name)
...@@ -406,24 +413,31 @@ public final class MethodsGenerator { ...@@ -406,24 +413,31 @@ public final class MethodsGenerator {
406 */ 413 */
407 public static String getSetterForClass(JavaAttributeInfo attr, String className, int generatedJavaFiles) { 414 public static String getSetterForClass(JavaAttributeInfo attr, String className, int generatedJavaFiles) {
408 415
409 - String attrQuaifiedType = getReturnType(attr); 416 + String attrQualifiedType = getReturnType(attr);
410 String attributeName = attr.getAttributeName(); 417 String attributeName = attr.getAttributeName();
418 + boolean isTypeNull = false;
419 + if (attr.getAttributeType() == null) {
420 + isTypeNull = true;
421 + }
411 if (!attr.isListAttr()) { 422 if (!attr.isListAttr()) {
412 - return getSetter(className, attributeName, attrQuaifiedType, generatedJavaFiles); 423 + return getSetter(className, attributeName, attrQualifiedType, generatedJavaFiles, isTypeNull, false);
413 } 424 }
414 - String listAttr = getListString() + attrQuaifiedType + DIAMOND_CLOSE_BRACKET; 425 + String listAttr = getListString() + attrQualifiedType + DIAMOND_CLOSE_BRACKET;
415 - return getSetter(className, attributeName, listAttr, generatedJavaFiles); 426 + return getSetter(className, attributeName, listAttr, generatedJavaFiles, isTypeNull, true);
416 } 427 }
417 428
418 /** 429 /**
419 * Returns setter for attribute. 430 * Returns setter for attribute.
420 * 431 *
421 - * @param className class name 432 + * @param className class name
422 - * @param name attribute name 433 + * @param name attribute name
423 - * @param type return type 434 + * @param type return type
435 + * @param isTypeNull if attribute type is null
436 + * @param isList true if leaf-list
424 * @return setter for attribute 437 * @return setter for attribute
425 */ 438 */
426 - private static String getSetter(String className, String name, String type, int generatedJavaFiles) { 439 + private static String getSetter(String className, String name, String type, int generatedJavaFiles,
440 + boolean isTypeNull, boolean isList) {
427 if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) { 441 if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
428 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX 442 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX
429 + getCapitalCase(name) + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE + 443 + getCapitalCase(name) + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE +
...@@ -435,12 +449,25 @@ public final class MethodsGenerator { ...@@ -435,12 +449,25 @@ public final class MethodsGenerator {
435 + THIS + PERIOD + name + SPACE + EQUAL + SPACE + name + SEMI_COLAN + NEW_LINE 449 + THIS + PERIOD + name + SPACE + EQUAL + SPACE + name + SEMI_COLAN + NEW_LINE
436 + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; 450 + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
437 } else { 451 } else {
438 - return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + className + BUILDER + SPACE + 452 + String method = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + className + BUILDER + SPACE +
439 name + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE 453 name + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE
440 - + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + THIS + PERIOD + name + SPACE 454 + + OPEN_CURLY_BRACKET;
455 + if (!isTypeNull && !isList) {
456 + method = method + getValueLeafSetString(name);
457 + } else {
458 + method = method + EMPTY_STRING;
459 + }
460 + return method + NEW_LINE + EIGHT_SPACE_INDENTATION + THIS +
461 + PERIOD + name + SPACE
441 + EQUAL + SPACE + name + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE 462 + EQUAL + SPACE + name + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE
442 + THIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; 463 + THIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
443 } 464 }
465 +
466 + }
467 +
468 + //Returns value leaf flag setter.
469 + private static String getValueLeafSetString(String name) {
470 + return "\n get_valueLeafFlags().set(LeafIdentifier." + name.toUpperCase() + ".getLeafIndex());";
444 } 471 }
445 472
446 /** 473 /**
...@@ -449,11 +476,11 @@ public final class MethodsGenerator { ...@@ -449,11 +476,11 @@ public final class MethodsGenerator {
449 * @param attr attribute info 476 * @param attr attribute info
450 * @return setter method for class 477 * @return setter method for class
451 */ 478 */
452 - public static String getSetterForTypeDefClass(JavaAttributeInfo attr) { 479 + static String getSetterForTypeDefClass(JavaAttributeInfo attr) {
453 480
454 - String attrQuaifiedType = getReturnType(attr); 481 + String attrQualifiedType = getReturnType(attr);
455 String attributeName = attr.getAttributeName(); 482 String attributeName = attr.getAttributeName();
456 - return getTypeDefSetter(attrQuaifiedType, attributeName); 483 + return getTypeDefSetter(attrQualifiedType, attributeName);
457 } 484 }
458 485
459 /** 486 /**
...@@ -466,8 +493,8 @@ public final class MethodsGenerator { ...@@ -466,8 +493,8 @@ public final class MethodsGenerator {
466 private static String getTypeDefSetter(String type, String name) { 493 private static String getTypeDefSetter(String type, String name) {
467 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(name) 494 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(name)
468 + OPEN_PARENTHESIS + type + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE 495 + OPEN_PARENTHESIS + type + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
469 - + EIGHT_SPACE_INDENTATION + THIS + PERIOD + name + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN + NEW_LINE 496 + + EIGHT_SPACE_INDENTATION + THIS + PERIOD + name + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN +
470 - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; 497 + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
471 } 498 }
472 499
473 /** 500 /**
...@@ -488,8 +515,8 @@ public final class MethodsGenerator { ...@@ -488,8 +515,8 @@ public final class MethodsGenerator {
488 * @param generatedJavaFiles generated java files 515 * @param generatedJavaFiles generated java files
489 * @return getter method for interface 516 * @return getter method for interface
490 */ 517 */
491 - public static String getGetterForInterface(String yangName, String returnType, boolean isList, 518 + static String getGetterForInterface(String yangName, String returnType, boolean isList,
492 - int generatedJavaFiles) { 519 + int generatedJavaFiles) {
493 520
494 if (!isList) { 521 if (!isList) {
495 return getGetterInterfaceString(returnType, yangName, generatedJavaFiles); 522 return getGetterInterfaceString(returnType, yangName, generatedJavaFiles);
...@@ -508,8 +535,7 @@ public final class MethodsGenerator { ...@@ -508,8 +535,7 @@ public final class MethodsGenerator {
508 private static String getGetterInterfaceString(String returnType, String yangName, 535 private static String getGetterInterfaceString(String returnType, String yangName,
509 int generatedJavaFiles) { 536 int generatedJavaFiles) {
510 if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) { 537 if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
511 - return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCapitalCase(yangName) 538 + return getGetMethodWithArgument(returnType, yangName);
512 - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN;
513 } else { 539 } else {
514 return FOUR_SPACE_INDENTATION + returnType + SPACE + yangName 540 return FOUR_SPACE_INDENTATION + returnType + SPACE + yangName
515 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN; 541 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN;
...@@ -526,8 +552,8 @@ public final class MethodsGenerator { ...@@ -526,8 +552,8 @@ public final class MethodsGenerator {
526 * @param generatedJavaFiles generated java files 552 * @param generatedJavaFiles generated java files
527 * @return setter method for interface 553 * @return setter method for interface
528 */ 554 */
529 - public static String getSetterForInterface(String attrName, String attrType, String className, 555 + static String getSetterForInterface(String attrName, String attrType, String className,
530 - boolean isList, int generatedJavaFiles) { 556 + boolean isList, int generatedJavaFiles) {
531 557
532 if (!isList) { 558 if (!isList) {
533 return getSetterInterfaceString(className, attrName, attrType, generatedJavaFiles); 559 return getSetterInterfaceString(className, attrName, attrType, generatedJavaFiles);
...@@ -547,7 +573,6 @@ public final class MethodsGenerator { ...@@ -547,7 +573,6 @@ public final class MethodsGenerator {
547 private static String getSetterInterfaceString(String className, String attrName, String attrType, 573 private static String getSetterInterfaceString(String className, String attrName, String attrType,
548 int generatedJavaFiles) { 574 int generatedJavaFiles) {
549 if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) { 575 if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
550 -
551 return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName) 576 return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName)
552 + OPEN_PARENTHESIS + attrType + SPACE + attrName + CLOSE_PARENTHESIS + SEMI_COLAN; 577 + OPEN_PARENTHESIS + attrType + SPACE + attrName + CLOSE_PARENTHESIS + SEMI_COLAN;
553 } else { 578 } else {
...@@ -587,7 +612,7 @@ public final class MethodsGenerator { ...@@ -587,7 +612,7 @@ public final class MethodsGenerator {
587 * @param yangName name of the interface 612 * @param yangName name of the interface
588 * @return build method for interface 613 * @return build method for interface
589 */ 614 */
590 - public static String getBuildForInterface(String yangName) { 615 + static String getBuildForInterface(String yangName) {
591 return FOUR_SPACE_INDENTATION + yangName + SPACE + BUILD + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN 616 return FOUR_SPACE_INDENTATION + yangName + SPACE + BUILD + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN
592 + NEW_LINE; 617 + NEW_LINE;
593 } 618 }
...@@ -597,29 +622,19 @@ public final class MethodsGenerator { ...@@ -597,29 +622,19 @@ public final class MethodsGenerator {
597 * 622 *
598 * @param yangName class name 623 * @param yangName class name
599 * @param pluginConfig plugin configurations 624 * @param pluginConfig plugin configurations
625 + * @param isRootNode if root node
600 * @return constructor string 626 * @return constructor string
601 */ 627 */
602 - public static String getConstructorStart(String yangName, YangPluginConfig pluginConfig) { 628 + static String getConstructorStart(String yangName, YangPluginConfig pluginConfig, boolean isRootNode) {
603 629
604 String javadoc = getConstructorString(yangName, pluginConfig); 630 String javadoc = getConstructorString(yangName, pluginConfig);
605 - String constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + getCapitalCase(DEFAULT) + yangName +
606 - OPEN_PARENTHESIS + yangName + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT
607 - + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
608 - return javadoc + constructor;
609 - }
610 -
611 - /**
612 - * Returns constructor string for op param class.
613 - *
614 - * @param yangName class name
615 - * @param pluginConfig plugin configurations
616 - * @return constructor string
617 - */
618 - public static String getOpParamConstructorStart(String yangName, YangPluginConfig pluginConfig) {
619 631
620 - String javadoc = getConstructorString(yangName, pluginConfig); 632 + String returnType = getCapitalCase(DEFAULT) + yangName;
621 - String constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + OPERATION + 633 + if (isRootNode) {
622 - OPEN_PARENTHESIS + yangName + OPERATION + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT 634 + returnType = yangName + OP_PARAM;
635 + }
636 + String constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + returnType +
637 + OPEN_PARENTHESIS + yangName + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT
623 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 638 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
624 return javadoc + constructor; 639 return javadoc + constructor;
625 } 640 }
...@@ -706,13 +721,19 @@ public final class MethodsGenerator { ...@@ -706,13 +721,19 @@ public final class MethodsGenerator {
706 /** 721 /**
707 * Returns the build method strings for class file. 722 * Returns the build method strings for class file.
708 * 723 *
709 - * @param yangName class name 724 + * @param yangName class name
725 + * @param isRootNode if root node
710 * @return build method string for class 726 * @return build method string for class
711 */ 727 */
712 - public static String getBuild(String yangName) { 728 + static String getBuild(String yangName, boolean isRootNode) {
713 - return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + SPACE + BUILD + OPEN_PARENTHESIS + CLOSE_PARENTHESIS 729 + String type = getCapitalCase(DEFAULT) + yangName;
730 + if (isRootNode) {
731 + type = yangName + OP_PARAM;
732 + }
733 + return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + SPACE + BUILD + OPEN_PARENTHESIS +
734 + CLOSE_PARENTHESIS
714 + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE + NEW + SPACE + 735 + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE + NEW + SPACE +
715 - getCapitalCase(DEFAULT) + yangName + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS + SEMI_COLAN 736 + type + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS + SEMI_COLAN
716 + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; 737 + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
717 } 738 }
718 739
...@@ -733,170 +754,13 @@ public final class MethodsGenerator { ...@@ -733,170 +754,13 @@ public final class MethodsGenerator {
733 * 754 *
734 * @return string method's open string 755 * @return string method's open string
735 */ 756 */
736 - public static String getToStringMethodOpen() { 757 + static String getToStringMethodOpen() {
737 return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STRING_DATA_TYPE + SPACE + TO 758 return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STRING_DATA_TYPE + SPACE + TO
738 + STRING_DATA_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE 759 + STRING_DATA_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
739 + EIGHT_SPACE_INDENTATION + RETURN + GOOGLE_MORE_OBJECT_METHOD_STRING + NEW_LINE; 760 + EIGHT_SPACE_INDENTATION + RETURN + GOOGLE_MORE_OBJECT_METHOD_STRING + NEW_LINE;
740 } 761 }
741 762
742 /** 763 /**
743 - * Returns to string leaf for get method.
744 - *
745 - * @return string leaf for get method
746 - */
747 - public static String getToStringLeafgetter() {
748 - return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_FILTER_LEAF
749 - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
750 - + EIGHT_SPACE_INDENTATION + RETURN + SPACE + FILTER_LEAF + SEMI_COLAN + NEW_LINE
751 - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
752 - }
753 -
754 - /**
755 - * Returns to string select leaf for get method.
756 - *
757 - * @return select leaf string for get method
758 - */
759 - public static String getToStringSelectLeafgetter() {
760 - return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_SELECT_LEAF
761 - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
762 - + EIGHT_SPACE_INDENTATION + RETURN + SPACE + SELECT_LEAF + SEMI_COLAN + NEW_LINE
763 - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
764 - }
765 -
766 - /**
767 - * Returns to string leaf list for get method.
768 - *
769 - * @return string leaf list for get method
770 - */
771 - public static String getToStringLeafListgetter() {
772 - return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_FILTER_LEAF_LIST
773 - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
774 - + EIGHT_SPACE_INDENTATION + RETURN + SPACE + FILTER_LEAF_LIST + SEMI_COLAN + NEW_LINE
775 - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
776 - }
777 -
778 - /**
779 - * Returns to string select leaf list for get.
780 - *
781 - * @return select leaf list list for get
782 - */
783 - public static String getToStringSelectLeafListgetter() {
784 - return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_SELECT_LEAF_LIST
785 - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
786 - + EIGHT_SPACE_INDENTATION + RETURN + SPACE + SELECT_LEAF_LIST + SEMI_COLAN + NEW_LINE
787 - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
788 - }
789 -
790 - /**
791 - * Returns to string operation type for get method.
792 - *
793 - * @return operation type for get method
794 - */
795 - public static String getOperationTypegetter() {
796 - return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + OPERATION_ENUM
797 - + SPACE + GET_OPERATION_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE
798 - + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE
799 - + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
800 - }
801 -
802 - /**
803 - * Returns to string operation type for set.
804 - *
805 - * @return operation type set method
806 - */
807 - public static String getOperationTypeSetter() {
808 - return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_OPERATION_TYPE
809 - + OPEN_PARENTHESIS + OPERATION_ENUM + SPACE + getSmallCase(OPERATION_ENUM) + CLOSE_PARENTHESIS
810 - + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + THIS + PERIOD
811 - + OP_PARAM_TYPE + SPACE + EQUAL + SPACE + getSmallCase(OPERATION_ENUM) + SEMI_COLAN + NEW_LINE
812 - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
813 - }
814 -
815 - /**
816 - * Returns string for leaf set method.
817 - *
818 - * @param className class name
819 - * @param curnode current YANG node
820 - * @param pluginConfig plugin configurations
821 - * @return string for leaf set method
822 - */
823 - public static String getSetterForLeaf(String className, YangNode curnode, YangPluginConfig pluginConfig) {
824 -
825 - int numleaf = 1;
826 - String filterMethod = "";
827 - TempJavaBeanFragmentFiles tempFragmentFiles = ((JavaCodeGeneratorInfo) curnode)
828 - .getTempJavaCodeFragmentFiles().getBeanTempFiles();
829 - if (curnode instanceof YangLeavesHolder) {
830 - YangLeavesHolder leavesHolder = (YangLeavesHolder) curnode;
831 - List<YangLeaf> leaves = leavesHolder.getListOfLeaf();
832 - if (leaves != null && !leaves.isEmpty()) {
833 - for (YangLeaf leaf : leaves) {
834 - JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeaf(tempFragmentFiles, leaf, pluginConfig);
835 - String attrQuaifiedType = getReturnType(javaAttributeInfo);
836 - String attributeName = javaAttributeInfo.getAttributeName();
837 -
838 - filterMethod = filterMethod + NEW_LINE + FOUR_SPACE_INDENTATION + OVERRIDE + NEW_LINE
839 - + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + className + BUILDER + SPACE
840 - + attributeName + OPEN_PARENTHESIS + attrQuaifiedType
841 - + SPACE + RECEIVED_OBJECT + attributeName + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
842 - + NEW_LINE + EIGHT_SPACE_INDENTATION + attributeName + SPACE + EQUAL + SPACE
843 - + RECEIVED_OBJECT + attributeName + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION
844 - + GET_FILTER_LEAF + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + SET_METHOD_PREFIX
845 - + OPEN_PARENTHESIS + String.valueOf(numleaf) + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
846 - + EIGHT_SPACE_INDENTATION + RETURN + SPACE + THIS + SEMI_COLAN + NEW_LINE
847 - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
848 - numleaf++;
849 - }
850 - }
851 - }
852 - return filterMethod;
853 - }
854 -
855 - /**
856 - * Returns string for leaf list set method.
857 - *
858 - * @param className class name
859 - * @param curnode current YANG node
860 - * @param pluginConfig plugin configurations
861 - * @return string for leaf list set method
862 - */
863 - public static String getSetterForLeafList(String className, YangNode curnode, YangPluginConfig pluginConfig) {
864 -
865 - int numleaf = 1;
866 - String filterMethod = "";
867 - TempJavaBeanFragmentFiles tempFragmentFiles = ((JavaCodeGeneratorInfo) curnode)
868 - .getTempJavaCodeFragmentFiles().getBeanTempFiles();
869 - if (curnode instanceof YangLeavesHolder) {
870 - YangLeavesHolder leavesHolder = (YangLeavesHolder) curnode;
871 - List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList();
872 -
873 - if (listOfLeafList != null && !listOfLeafList.isEmpty()) {
874 - for (YangLeafList leafList : listOfLeafList) {
875 - JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList,
876 - pluginConfig);
877 - String attributeName = javaAttributeInfo.getAttributeName();
878 - String attrQuaifiedType = getReturnType(javaAttributeInfo);
879 - if (javaAttributeInfo.isListAttr()) {
880 - attrQuaifiedType = getListString() + attrQuaifiedType + DIAMOND_CLOSE_BRACKET;
881 - }
882 - filterMethod = filterMethod + NEW_LINE + FOUR_SPACE_INDENTATION + OVERRIDE + NEW_LINE
883 - + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + className + BUILDER + SPACE
884 - + attributeName + OPEN_PARENTHESIS + attrQuaifiedType
885 - + SPACE + RECEIVED_OBJECT + attributeName + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
886 - + NEW_LINE + EIGHT_SPACE_INDENTATION + attributeName + SPACE + EQUAL + SPACE
887 - + RECEIVED_OBJECT + attributeName + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION
888 - + GET_FILTER_LEAF_LIST + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + SET_METHOD_PREFIX
889 - + OPEN_PARENTHESIS + String.valueOf(numleaf) + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
890 - + EIGHT_SPACE_INDENTATION + RETURN + SPACE + THIS + SEMI_COLAN + NEW_LINE
891 - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
892 - numleaf++;
893 - }
894 - }
895 - }
896 - return filterMethod;
897 - }
898 -
899 - /**
900 * Returns whether the data type is of primitive data type. 764 * Returns whether the data type is of primitive data type.
901 * 765 *
902 * @param dataType data type to be checked 766 * @param dataType data type to be checked
...@@ -923,7 +787,7 @@ public final class MethodsGenerator { ...@@ -923,7 +787,7 @@ public final class MethodsGenerator {
923 + CLOSE_PARENTHESIS; 787 + CLOSE_PARENTHESIS;
924 } 788 }
925 789
926 - private static String getAttrTypeForFilterContentMatchWhenNonPremitiveDatatype(String attributeName) { 790 + private static String getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(String attributeName) {
927 return APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS 791 return APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
928 + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION + SPACE 792 + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION + SPACE
929 + NOT + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS 793 + NOT + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
...@@ -933,7 +797,7 @@ public final class MethodsGenerator { ...@@ -933,7 +797,7 @@ public final class MethodsGenerator {
933 } 797 }
934 798
935 private static String getIfFilterContentMatchMethodImpl(String attributeName, 799 private static String getIfFilterContentMatchMethodImpl(String attributeName,
936 - String filterMethod, int numleaf, YangType dataType) { 800 + YangType dataType) {
937 String attrQualifiedType; 801 String attrQualifiedType;
938 802
939 if (isPrimitiveDataType(dataType.getDataType())) { 803 if (isPrimitiveDataType(dataType.getDataType())) {
...@@ -943,10 +807,10 @@ public final class MethodsGenerator { ...@@ -943,10 +807,10 @@ public final class MethodsGenerator {
943 if (isPrimitiveDataType(type.getDataType())) { 807 if (isPrimitiveDataType(type.getDataType())) {
944 attrQualifiedType = getAttrTypeForFilterContentMatchWhenPrimitiveDataType(attributeName); 808 attrQualifiedType = getAttrTypeForFilterContentMatchWhenPrimitiveDataType(attributeName);
945 } else { 809 } else {
946 - attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPremitiveDatatype(attributeName); 810 + attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(attributeName);
947 } 811 }
948 } else { 812 } else {
949 - attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPremitiveDatatype(attributeName); 813 + attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPrimitiveDataTypes(attributeName);
950 } 814 }
951 815
952 return attrQualifiedType; 816 return attrQualifiedType;
...@@ -955,27 +819,21 @@ public final class MethodsGenerator { ...@@ -955,27 +819,21 @@ public final class MethodsGenerator {
955 /** 819 /**
956 * Returns string for is filter content match method. 820 * Returns string for is filter content match method.
957 * 821 *
958 - * @param className class name
959 * @param curNode current YANG node 822 * @param curNode current YANG node
960 * @param pluginConfig plugin configurations 823 * @param pluginConfig plugin configurations
961 * @return string for is filter content match method 824 * @return string for is filter content match method
962 */ 825 */
963 - public static String getIsFilterContentMatch(String className, YangNode curNode, YangPluginConfig pluginConfig) { 826 + static String getIsFilterContentMatch(YangNode curNode, YangPluginConfig pluginConfig) {
964 827
965 - int numLeaf = 1; 828 + String filterMethod = getOverRideString();
966 - String filterMethod = "";
967 TempJavaBeanFragmentFiles tempFragmentFiles = ((JavaCodeGeneratorInfo) curNode) 829 TempJavaBeanFragmentFiles tempFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
968 .getTempJavaCodeFragmentFiles().getBeanTempFiles(); 830 .getTempJavaCodeFragmentFiles().getBeanTempFiles();
831 + JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
969 if (curNode instanceof YangLeavesHolder) { 832 if (curNode instanceof YangLeavesHolder) {
970 - filterMethod = NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE 833 + filterMethod = filterMethod + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE
971 - + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + getCapitalCase(OBJECT) 834 + + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + getCapitalCase(javaFileInfo.getJavaName())
972 - + SPACE + OBJ + 835 + + SPACE + APP_INSTANCE + CLOSE_PARENTHESIS + SPACE
973 - CLOSE_PARENTHESIS + SPACE
974 + OPEN_CURLY_BRACKET + NEW_LINE; 836 + OPEN_CURLY_BRACKET + NEW_LINE;
975 - filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + getCapitalCase(DEFAULT)
976 - + getCapitalCase(className) + SPACE + APP_INSTANCE + SPACE + EQUAL + SPACE + OPEN_PARENTHESIS +
977 - getCapitalCase(DEFAULT) + getCapitalCase(className) + CLOSE_PARENTHESIS + OBJ +
978 - SEMI_COLAN + NEW_LINE;
979 if (curNode instanceof YangAugmentableNode) { 837 if (curNode instanceof YangAugmentableNode) {
980 filterMethod = filterMethod + getAugmentableOpParamSyntax(); 838 filterMethod = filterMethod + getAugmentableOpParamSyntax();
981 } 839 }
...@@ -990,39 +848,46 @@ public final class MethodsGenerator { ...@@ -990,39 +848,46 @@ public final class MethodsGenerator {
990 pluginConfig); 848 pluginConfig);
991 String attributeName = javaAttributeInfo.getAttributeName(); 849 String attributeName = javaAttributeInfo.getAttributeName();
992 attrQualifiedType = getIfFilterContentMatchMethodImpl(attributeName, 850 attrQualifiedType = getIfFilterContentMatchMethodImpl(attributeName,
993 - filterMethod, numLeaf, leaf.getDataType()); 851 + leaf.getDataType());
994 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS 852 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS
995 + GET_FILTER_LEAF + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX 853 + GET_FILTER_LEAF + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX
996 - + OPEN_PARENTHESIS + String.valueOf(numLeaf) + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS 854 + + OPEN_PARENTHESIS + LEAF_IDENTIFIER + PERIOD + attributeName.toUpperCase() + PERIOD +
855 + GET_LEAF_INDEX
856 + + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
997 + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE 857 + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE
998 + OPEN_PARENTHESIS + attrQualifiedType + CLOSE_PARENTHESIS + SPACE 858 + OPEN_PARENTHESIS + attrQualifiedType + CLOSE_PARENTHESIS + SPACE
999 + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE 859 + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE
1000 + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE 860 + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE
1001 - + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 861 + + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + NEW_LINE;
1002 -
1003 - numLeaf++;
1004 } 862 }
1005 } 863 }
1006 864
1007 if (listOfLeafList != null) { 865 if (listOfLeafList != null) {
1008 - numLeaf = 1;
1009 for (YangLeafList leafList : listOfLeafList) { 866 for (YangLeafList leafList : listOfLeafList) {
1010 JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList, 867 JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList,
1011 pluginConfig); 868 pluginConfig);
1012 String attributeName = javaAttributeInfo.getAttributeName(); 869 String attributeName = javaAttributeInfo.getAttributeName();
1013 - attrQualifiedType = getIfFilterContentMatchMethodImpl( 870 + filterMethod = filterMethod + getIsFileContentMatchForLists(getCapitalCase(attributeName), true,
1014 - attributeName, filterMethod, numLeaf, leafList.getDataType()); 871 + javaAttributeInfo.getImportInfo().getClassInfo());
1015 - filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS
1016 - + GET_FILTER_LEAF_LIST + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX
1017 - + OPEN_PARENTHESIS + String.valueOf(numLeaf) + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
1018 - + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE
1019 - + OPEN_PARENTHESIS + attrQualifiedType + CLOSE_PARENTHESIS + SPACE
1020 - + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE
1021 - + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE
1022 - + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
1023 - numLeaf++;
1024 } 872 }
1025 } 873 }
874 + YangNode tempNode = curNode.getChild();
875 + JavaFileInfo fileInfo;
876 + String name;
877 + while (tempNode != null) {
878 + if (tempNode instanceof YangIsFilterContentNodes) {
879 + fileInfo = ((JavaFileInfoContainer) tempNode).getJavaFileInfo();
880 + name = getCapitalCase(fileInfo.getJavaName());
881 + if (tempNode instanceof YangList) {
882 + filterMethod = filterMethod +
883 + getIsFileContentMatchForLists(name, false, null);
884 + } else {
885 +
886 + filterMethod = filterMethod + getIsFilerContentMatchForChildNode(name);
887 + }
888 + }
889 + tempNode = tempNode.getNextSibling();
890 + }
1026 891
1027 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + RETURN + SPACE + TRUE + SEMI_COLAN + 892 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + RETURN + SPACE + TRUE + SEMI_COLAN +
1028 NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 893 NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
...@@ -1031,57 +896,138 @@ public final class MethodsGenerator { ...@@ -1031,57 +896,138 @@ public final class MethodsGenerator {
1031 return filterMethod; 896 return filterMethod;
1032 } 897 }
1033 898
1034 - /*Returns method string for op parms augmented syntax*/ 899 + /**
900 + * Returns filter content match for child nodes.
901 + *
902 + * @param name name of node
903 + * @return filter content match for child nodes
904 + */
905 + private static String getIsFilerContentMatchForChildNode(String name) {
906 + name = getSmallCase(name);
907 + String method = EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + name + OPEN_PARENTHESIS +
908 + CLOSE_PARENTHESIS + SPACE + NOT + EQUAL + SPACE + NULL + CLOSE_PARENTHESIS + SPACE +
909 + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + APP_INSTANCE
910 + + PERIOD + name + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + EQUAL
911 + + EQUAL + SPACE + NULL + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
912 + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + NEW_LINE + TWELVE_SPACE_INDENTATION +
913 + CLOSE_CURLY_BRACKET + NEW_LINE;
914 + return method + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + name + OPEN_PARENTHESIS +
915 + CLOSE_PARENTHESIS + PERIOD + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD + name +
916 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE +
917 + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN +
918 + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
919 + + CLOSE_CURLY_BRACKET + NEW_LINE;
920 + }
921 +
922 + /**
923 + * Returns filter content match for list types.
924 + *
925 + * @param name name of node
926 + * @param isLeafList if for leaf list
927 + * @param type type of the attribute
928 + * @return filter content match for list types
929 + */
930 + private static String getIsFileContentMatchForLists(String name, boolean isLeafList, String type) {
931 + String method = EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + getSmallCase(name) + OPEN_PARENTHESIS
932 + + CLOSE_PARENTHESIS + SPACE + NOT + EQUAL + SPACE + NULL + SPACE + AND + AND + SPACE + NOT +
933 + getSmallCase(name) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + IS_EMPTY +
934 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
935 + + NEW_LINE;
936 + method = method + TWELVE_SPACE_INDENTATION + IF + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD + getSmallCase(name)
937 + + OPEN_PARENTHESIS
938 + + CLOSE_PARENTHESIS + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + "||" + SPACE +
939 + getSmallCase(name) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + IS_EMPTY + CLOSE_PARENTHESIS +
940 + SPACE + OPEN_CURLY_BRACKET
941 + + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE +
942 + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
943 + if (isLeafList) {
944 + if (type.equals(getSmallCase(STRING_DATA_TYPE))) {
945 + type = STRING_DATA_TYPE;
946 + }
947 + method = method + TWELVE_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + type + SPACE +
948 + getSmallCase(name)
949 + + SPACE + COLAN + SPACE + getSmallCase(name) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS +
950 + CLOSE_PARENTHESIS
951 + + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE +
952 + FLAG + SPACE + EQUAL + SPACE + FALSE + SEMI_COLAN + NEW_LINE;
953 + method = method + SIXTEEN_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + type + SPACE +
954 + UNDER_SCORE + getSmallCase(name)
955 + + SPACE + COLAN + SPACE + APP_INSTANCE + PERIOD + getSmallCase(name) + OPEN_PARENTHESIS
956 + + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
957 + method = method + TWENTY_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + getSmallCase(name) + PERIOD;
958 + } else {
959 + method = method + TWELVE_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + name + SPACE +
960 + getSmallCase(name)
961 + + SPACE + COLAN + SPACE + getSmallCase(name) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS +
962 + CLOSE_PARENTHESIS
963 + + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE +
964 + FLAG + SPACE + EQUAL + SPACE + FALSE + SEMI_COLAN + NEW_LINE;
965 + method = method + SIXTEEN_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + name + SPACE +
966 + UNDER_SCORE + getSmallCase(name)
967 + + SPACE + COLAN + SPACE + APP_INSTANCE + PERIOD + getSmallCase(name) + OPEN_PARENTHESIS
968 + + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
969 + method = method + TWENTY_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + getSmallCase(name) + PERIOD;
970 + }
971 + if (!isLeafList) {
972 + method = method + FILTER_CONTENT_MATCH;
973 + } else {
974 + method = method + EQUALS_STRING;
975 + }
976 + method = method + OPEN_PARENTHESIS + UNDER_SCORE + getSmallCase(name) + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
977 + + SPACE +
978 + OPEN_CURLY_BRACKET + NEW_LINE + TWENTY_FOUR_SPACE_INDENTATION + FLAG + SPACE + EQUAL + SPACE + TRUE +
979 + SEMI_COLAN
980 + + NEW_LINE + TWENTY_FOUR_SPACE_INDENTATION + BREAK + SEMI_COLAN + NEW_LINE + TWENTY_SPACE_INDENTATION
981 + + CLOSE_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
982 +
983 + method = method + SIXTEEN_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + FLAG + SPACE + EQUAL + EQUAL
984 + + SPACE + FALSE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWENTY_SPACE_INDENTATION
985 + + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE + SIXTEEN_SPACE_INDENTATION + CLOSE_CURLY_BRACKET +
986 + NEW_LINE;
987 + return method + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION +
988 + CLOSE_CURLY_BRACKET + NEW_LINE + NEW_LINE;
989 +
990 + }
991 +
992 + //Returns method string for op params augmented syntax
1035 private static String getAugmentableOpParamSyntax() { 993 private static String getAugmentableOpParamSyntax() {
1036 - return EIGHT_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + YANG_AUGMENTED_INFO + SPACE + 994 + return EIGHT_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + OBJECT_STRING + SPACE +
1037 getSmallCase(YANG_AUGMENTED_INFO) + SPACE + COLAN + SPACE + THIS + 995 getSmallCase(YANG_AUGMENTED_INFO) + SPACE + COLAN + SPACE + THIS +
1038 - PERIOD + GET_METHOD_PREFIX + YANG_AUGMENTED_INFO + MAP + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD 996 + PERIOD + getSmallCase(YANG_AUGMENTED_INFO) + MAP + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD
1039 + VALUE + "s" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + 997 + VALUE + "s" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET +
1040 - NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + NOT + OPEN_PARENTHESIS + 998 + NEW_LINE + TWELVE_SPACE_INDENTATION + OBJECT_STRING + SPACE +
1041 - getSmallCase(YANG_AUGMENTED_INFO) + SPACE + INSTANCE_OF + SPACE + YANG_AUGMENTED_OP_PARAM_INFO +
1042 - CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
1043 - SIXTEEN_SPACE_INDENTATION + THROW + SPACE + NEW + SPACE + ILLEGAL_ARGUMENT_EXCEPTION +
1044 - OPEN_PARENTHESIS +
1045 - ILLEGAL_ARGUMENT_EXCEPTION_MSG + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION +
1046 - CLOSE_CURLY_BRACKET + NEW_LINE + NEW_LINE + TWELVE_SPACE_INDENTATION + YANG_AUGMENTED_INFO + SPACE +
1047 getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO) + SPACE + EQUAL + SPACE + APP_INSTANCE + PERIOD + 999 getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO) + SPACE + EQUAL + SPACE + APP_INSTANCE + PERIOD +
1048 - GET_METHOD_PREFIX + AUGMENTED_INFO + OPEN_PARENTHESIS + OPEN_PARENTHESIS + OPEN_PARENTHESIS + 1000 + getSmallCase(YANG_AUGMENTED_INFO) + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD + GET_CLASS +
1049 - YANG_AUGMENTED_OP_PARAM_INFO + CLOSE_PARENTHESIS + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + 1001 + CLOSE_PARENTHESIS + SEMI_COLAN +
1050 - CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX + BASE_CLASS + CLOSE_PARENTHESIS + SEMI_COLAN + 1002 + NEW_LINE + TWELVE_SPACE_INDENTATION
1051 - NEW_LINE + TWELVE_SPACE_INDENTATION + IF + OPEN_PARENTHESIS + NOT + 1003 + + BOOLEAN_DATA_TYPE + SPACE + FILTER_CONTENT_MATCH + SPACE + EQUAL + SPACE + FALSE + SEMI_COLAN
1052 - OPEN_PARENTHESIS + OPEN_PARENTHESIS + YANG_AUGMENTED_OP_PARAM_INFO + CLOSE_PARENTHESIS + SPACE + 1004 + + NEW_LINE + TWELVE_SPACE_INDENTATION + TRY + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
1053 - getSmallCase(YANG_AUGMENTED_INFO) + CLOSE_PARENTHESIS 1005 + SIXTEEN_SPACE_INDENTATION +
1054 - + PERIOD + "isFilterContentMatch" + OPEN_PARENTHESIS + 1006 + FILTER_CONTENT_MATCH + SPACE + EQUAL + SPACE + OPEN_PARENTHESIS
1055 - getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO) + CLOSE_PARENTHESIS + 1007 + + BOOLEAN_DATA_TYPE + CLOSE_PARENTHESIS + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD +
1056 - CLOSE_PARENTHESIS + 1008 + GET_CLASS + NEW_LINE + TWENTY_SPACE_INDENTATION + PERIOD + GET_METHOD
1009 + + OPEN_PARENTHESIS + QUOTES + FILTER_CONTENT_MATCH + QUOTES + COMMA + SPACE + OBJECT_STRING + PERIOD
1010 + + CLASS + CLOSE_PARENTHESIS + PERIOD + INVOKE + OPEN_PARENTHESIS + getSmallCase(YANG_AUGMENTED_INFO) +
1011 + NEW_LINE + TWENTY_FOUR_SPACE_INDENTATION + PERIOD + GET_CLASS + COMMA + SPACE +
1012 + getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO)
1013 + + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE
1014 + + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + SPACE + CATCH + OPEN_PARENTHESIS
1015 + + NO_SUCH_METHOD_EXCEPTION + " | " + INVOCATION_TARGET_EXCEPTION + " | " + ILLEGAL_ACCESS_EXCEPTION +
1016 + SPACE + EXCEPTION_VAR + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
1017 + + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
1018 + + CLOSE_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION
1019 + + IF + OPEN_PARENTHESIS + NOT + FILTER_CONTENT_MATCH + CLOSE_PARENTHESIS +
1057 SPACE + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + 1020 SPACE + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE +
1058 SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION 1021 SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
1059 + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 1022 + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
1060 } 1023 }
1061 1024
1062 - /**
1063 - * Returns implementation of get base class method for op param files.
1064 - *
1065 - * @param baseClassName base class name
1066 - * @return implementation of get base class method for op param files
1067 - */
1068 - public static String getBaseClassMethodImpl(String baseClassName) {
1069 - return NEW_LINE + getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_STRING +
1070 - DIAMOND_OPEN_BRACKET +
1071 - QUESTION_MARK +
1072 - DIAMOND_CLOSE_BRACKET + SPACE + GET_METHOD_PREFIX + BASE_CLASS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
1073 - EIGHT_SPACE_INDENTATION + RETURN + SPACE + baseClassName + PERIOD + CLASS + SEMI_COLAN + NEW_LINE +
1074 - FOUR_SPACE_INDENTATION +
1075 - CLOSE_CURLY_BRACKET;
1076 -
1077 - }
1078 -
1079 /* 1025 /*
1080 - * Retruns omit null value string. 1026 + * Returns omit null value string.
1081 * 1027 *
1082 * @return omit null value string 1028 * @return omit null value string
1083 */ 1029 */
1084 - public static String getOmitNullValueString() { 1030 + static String getOmitNullValueString() {
1085 return TWELVE_SPACE_INDENTATION + PERIOD + OMIT_NULL_VALUE_STRING + NEW_LINE; 1031 return TWELVE_SPACE_INDENTATION + PERIOD + OMIT_NULL_VALUE_STRING + NEW_LINE;
1086 } 1032 }
1087 1033
...@@ -1090,7 +1036,7 @@ public final class MethodsGenerator { ...@@ -1090,7 +1036,7 @@ public final class MethodsGenerator {
1090 * 1036 *
1091 * @return to string method close string 1037 * @return to string method close string
1092 */ 1038 */
1093 - public static String getToStringMethodClose() { 1039 + static String getToStringMethodClose() {
1094 return TWELVE_SPACE_INDENTATION + PERIOD + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS 1040 return TWELVE_SPACE_INDENTATION + PERIOD + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
1095 + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 1041 + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
1096 } 1042 }
...@@ -1115,7 +1061,7 @@ public final class MethodsGenerator { ...@@ -1115,7 +1061,7 @@ public final class MethodsGenerator {
1115 * @param pluginConfig plugin configurations 1061 * @param pluginConfig plugin configurations
1116 * @return from string method's open string 1062 * @return from string method's open string
1117 */ 1063 */
1118 - public static String getFromStringMethodSignature(String className, YangPluginConfig pluginConfig) { 1064 + static String getFromStringMethodSignature(String className, YangPluginConfig pluginConfig) {
1119 return getJavaDoc(FROM_METHOD, className, false, pluginConfig) + FOUR_SPACE_INDENTATION + PUBLIC + SPACE 1065 return getJavaDoc(FROM_METHOD, className, false, pluginConfig) + FOUR_SPACE_INDENTATION + PUBLIC + SPACE
1120 + STATIC + SPACE + className + SPACE + FROM_STRING_METHOD_NAME + OPEN_PARENTHESIS 1066 + STATIC + SPACE + className + SPACE + FROM_STRING_METHOD_NAME + OPEN_PARENTHESIS
1121 + STRING_DATA_TYPE + SPACE + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SPACE 1067 + STRING_DATA_TYPE + SPACE + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SPACE
...@@ -1127,7 +1073,7 @@ public final class MethodsGenerator { ...@@ -1127,7 +1073,7 @@ public final class MethodsGenerator {
1127 * 1073 *
1128 * @return from string method's close string 1074 * @return from string method's close string
1129 */ 1075 */
1130 - public static String getFromStringMethodClose() { 1076 + static String getFromStringMethodClose() {
1131 return EIGHT_SPACE_INDENTATION + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + 1077 return EIGHT_SPACE_INDENTATION + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION +
1132 CLOSE_CURLY_BRACKET + NEW_LINE; 1078 CLOSE_CURLY_BRACKET + NEW_LINE;
1133 } 1079 }
...@@ -1153,7 +1099,7 @@ public final class MethodsGenerator { ...@@ -1153,7 +1099,7 @@ public final class MethodsGenerator {
1153 * 1099 *
1154 * @return sub string with try statement for union's from string method 1100 * @return sub string with try statement for union's from string method
1155 */ 1101 */
1156 - public static String getTrySubString() { 1102 + private static String getTrySubString() {
1157 return TRY + SPACE + OPEN_CURLY_BRACKET; 1103 return TRY + SPACE + OPEN_CURLY_BRACKET;
1158 } 1104 }
1159 1105
...@@ -1162,7 +1108,7 @@ public final class MethodsGenerator { ...@@ -1162,7 +1108,7 @@ public final class MethodsGenerator {
1162 * 1108 *
1163 * @return sub string with return statement for union's from string method 1109 * @return sub string with return statement for union's from string method
1164 */ 1110 */
1165 - public static String getReturnOfSubString() { 1111 + private static String getReturnOfSubString() {
1166 return RETURN + SPACE + OF + OPEN_PARENTHESIS + TMP_VAL + CLOSE_PARENTHESIS + SEMI_COLAN; 1112 return RETURN + SPACE + OF + OPEN_PARENTHESIS + TMP_VAL + CLOSE_PARENTHESIS + SEMI_COLAN;
1167 } 1113 }
1168 1114
...@@ -1171,7 +1117,7 @@ public final class MethodsGenerator { ...@@ -1171,7 +1117,7 @@ public final class MethodsGenerator {
1171 * 1117 *
1172 * @return sub string with catch statement for union's from string method 1118 * @return sub string with catch statement for union's from string method
1173 */ 1119 */
1174 - public static String getCatchSubString() { 1120 + private static String getCatchSubString() {
1175 return CLOSE_CURLY_BRACKET + SPACE + CATCH + SPACE + OPEN_PARENTHESIS + EXCEPTION + SPACE + EXCEPTION_VAR 1121 return CLOSE_CURLY_BRACKET + SPACE + CATCH + SPACE + OPEN_PARENTHESIS + EXCEPTION + SPACE + EXCEPTION_VAR
1176 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET; 1122 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET;
1177 } 1123 }
...@@ -1227,10 +1173,11 @@ public final class MethodsGenerator { ...@@ -1227,10 +1173,11 @@ public final class MethodsGenerator {
1227 * 1173 *
1228 * @return hash code method open string 1174 * @return hash code method open string
1229 */ 1175 */
1230 - public static String getHashCodeMethodOpen() { 1176 + static String getHashCodeMethodOpen() {
1231 return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + INT + SPACE + HASH_CODE_STRING 1177 return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + INT + SPACE + HASH_CODE_STRING
1232 - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION 1178 + + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
1233 - + RETURN + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD + HASH + OPEN_PARENTHESIS; 1179 + EIGHT_SPACE_INDENTATION
1180 + + RETURN + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD + HASH + OPEN_PARENTHESIS + SPACE;
1234 } 1181 }
1235 1182
1236 /** 1183 /**
...@@ -1239,10 +1186,11 @@ public final class MethodsGenerator { ...@@ -1239,10 +1186,11 @@ public final class MethodsGenerator {
1239 * @param hashcodeString hash code string 1186 * @param hashcodeString hash code string
1240 * @return to hash code method close string 1187 * @return to hash code method close string
1241 */ 1188 */
1242 - public static String getHashCodeMethodClose(String hashcodeString) { 1189 + static String getHashCodeMethodClose(String hashcodeString) {
1243 hashcodeString = trimAtLast(hashcodeString, COMMA); 1190 hashcodeString = trimAtLast(hashcodeString, COMMA);
1244 hashcodeString = trimAtLast(hashcodeString, SPACE); 1191 hashcodeString = trimAtLast(hashcodeString, SPACE);
1245 - return hashcodeString + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET 1192 + return hashcodeString + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION +
1193 + CLOSE_CURLY_BRACKET
1246 + NEW_LINE; 1194 + NEW_LINE;
1247 } 1195 }
1248 1196
...@@ -1262,8 +1210,9 @@ public final class MethodsGenerator { ...@@ -1262,8 +1210,9 @@ public final class MethodsGenerator {
1262 * @param className class name 1210 * @param className class name
1263 * @return equals method open string 1211 * @return equals method open string
1264 */ 1212 */
1265 - public static String getEqualsMethodOpen(String className) { 1213 + static String getEqualsMethodOpen(String className) {
1266 - return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE + SPACE + EQUALS_STRING 1214 + return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE + SPACE +
1215 + EQUALS_STRING
1267 + OPEN_PARENTHESIS + OBJECT_STRING + SPACE + OBJ + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET 1216 + OPEN_PARENTHESIS + OBJECT_STRING + SPACE + OBJ + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
1268 + NEW_LINE + getEqualsMethodsCommonIfCondition() + getEqualsMethodsSpecificIfCondition(className); 1217 + NEW_LINE + getEqualsMethodsCommonIfCondition() + getEqualsMethodsSpecificIfCondition(className);
1269 } 1218 }
...@@ -1298,7 +1247,7 @@ public final class MethodsGenerator { ...@@ -1298,7 +1247,7 @@ public final class MethodsGenerator {
1298 * @param equalMethodString equal method string 1247 * @param equalMethodString equal method string
1299 * @return equals method close string 1248 * @return equals method close string
1300 */ 1249 */
1301 - public static String getEqualsMethodClose(String equalMethodString) { 1250 + static String getEqualsMethodClose(String equalMethodString) {
1302 equalMethodString = trimAtLast(equalMethodString, AND); 1251 equalMethodString = trimAtLast(equalMethodString, AND);
1303 equalMethodString = trimAtLast(equalMethodString, AND); 1252 equalMethodString = trimAtLast(equalMethodString, AND);
1304 equalMethodString = trimAtLast(equalMethodString, SPACE); 1253 equalMethodString = trimAtLast(equalMethodString, SPACE);
...@@ -1329,7 +1278,7 @@ public final class MethodsGenerator { ...@@ -1329,7 +1278,7 @@ public final class MethodsGenerator {
1329 * @param attr attribute info 1278 * @param attr attribute info
1330 * @return of method string 1279 * @return of method string
1331 */ 1280 */
1332 - public static String getOfMethod(String name, JavaAttributeInfo attr) { 1281 + static String getOfMethod(String name, JavaAttributeInfo attr) {
1333 1282
1334 String attrQualifiedType = getReturnType(attr); 1283 String attrQualifiedType = getReturnType(attr);
1335 1284
...@@ -1399,7 +1348,7 @@ public final class MethodsGenerator { ...@@ -1399,7 +1348,7 @@ public final class MethodsGenerator {
1399 * @param generatedJavaClassName class name 1348 * @param generatedJavaClassName class name
1400 * @param pluginConfig plugin config 1349 * @param pluginConfig plugin config
1401 * @param type conflict validate type 1350 * @param type conflict validate type
1402 - * @param addFirst whether int came first or uint came first 1351 + * @param addFirst whether int came first or uInt came first
1403 * @return string and java doc for constructor of type class 1352 * @return string and java doc for constructor of type class
1404 */ 1353 */
1405 public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr1, JavaAttributeInfo 1354 public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr1, JavaAttributeInfo
...@@ -1460,7 +1409,7 @@ public final class MethodsGenerator { ...@@ -1460,7 +1409,7 @@ public final class MethodsGenerator {
1460 name1 = attr2; 1409 name1 = attr2;
1461 name2 = attr1; 1410 name2 = attr1;
1462 } 1411 }
1463 - constructor = constructor + ifConditionForIntInTypeDefConstrcutor(validatorType, addInt) + 1412 + constructor = constructor + ifConditionForIntInTypeDefConstructor(validatorType, addInt) +
1464 TWELVE_SPACE_INDENTATION + THIS + PERIOD 1413 TWELVE_SPACE_INDENTATION + THIS + PERIOD
1465 + name1 + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION 1414 + name1 + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION
1466 + CLOSE_CURLY_BRACKET + SPACE + ELSE + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION 1415 + CLOSE_CURLY_BRACKET + SPACE + ELSE + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION
...@@ -1473,13 +1422,24 @@ public final class MethodsGenerator { ...@@ -1473,13 +1422,24 @@ public final class MethodsGenerator {
1473 } 1422 }
1474 1423
1475 /** 1424 /**
1425 + * Returns interface of add augmentation.
1426 + *
1427 + * @return interface of add augmentation
1428 + */
1429 + static String getAddAugmentInfoMethodInterface() {
1430 + return generateForAddAugmentation() + FOUR_SPACE_INDENTATION + VOID + SPACE +
1431 + ADD_STRING + YANG_AUGMENTED_INFO + OPEN_PARENTHESIS + OBJECT_STRING + SPACE + VALUE + COMMA +
1432 + SPACE + CLASS_STRING + SPACE + CLASS + OBJECT_STRING + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1433 + }
1434 +
1435 + /**
1476 * Returns implementation of add augmentation. 1436 * Returns implementation of add augmentation.
1477 * 1437 *
1478 * @return implementation of add augmentation 1438 * @return implementation of add augmentation
1479 */ 1439 */
1480 static String getAddAugmentInfoMethodImpl() { 1440 static String getAddAugmentInfoMethodImpl() {
1481 - return NEW_LINE + generateForAddAugmentation() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + 1441 + return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE +
1482 - ADD_STRING + AUGMENTED_INFO + OPEN_PARENTHESIS + YANG_AUGMENTED_INFO + SPACE + VALUE + COMMA + 1442 + ADD_STRING + YANG_AUGMENTED_INFO + OPEN_PARENTHESIS + OBJECT_STRING + SPACE + VALUE + COMMA +
1483 SPACE + CLASS_STRING + SPACE + CLASS + OBJECT_STRING + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + 1443 SPACE + CLASS_STRING + SPACE + CLASS + OBJECT_STRING + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET +
1484 NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + PUT + 1444 NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + PUT +
1485 OPEN_PARENTHESIS + CLASS + OBJECT_STRING + COMMA + SPACE + VALUE + 1445 OPEN_PARENTHESIS + CLASS + OBJECT_STRING + COMMA + SPACE + VALUE +
...@@ -1488,15 +1448,25 @@ public final class MethodsGenerator { ...@@ -1488,15 +1448,25 @@ public final class MethodsGenerator {
1488 } 1448 }
1489 1449
1490 /** 1450 /**
1491 - * Returns implementation of get augment info. 1451 + * Returns interface of get YANG augment info.
1492 * 1452 *
1493 - * @return implementation of get augment info 1453 + * @return interface of get YANG augment info
1494 */ 1454 */
1495 - static String getAugmentInfoImpl() { 1455 + static String getYangAugmentInfoInterface() {
1456 + return generateForGetAugmentation() + FOUR_SPACE_INDENTATION + OBJECT_STRING + SPACE +
1457 + getSmallCase(YANG_AUGMENTED_INFO) + OPEN_PARENTHESIS + CLASS_STRING + SPACE + CLASS + OBJECT_STRING +
1458 + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1459 + }
1496 1460
1497 - return generateForGetAugmentation() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + 1461 + /**
1498 - YANG_AUGMENTED_INFO + SPACE + GET_METHOD_PREFIX + 1462 + * Returns implementation of get YANG augment info.
1499 - AUGMENTED_INFO + OPEN_PARENTHESIS + CLASS_STRING + SPACE + CLASS + OBJECT_STRING + 1463 + *
1464 + * @return implementation of get YANG augment info
1465 + */
1466 + static String getYangAugmentInfoImpl() {
1467 + return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE +
1468 + OBJECT_STRING + SPACE +
1469 + getSmallCase(YANG_AUGMENTED_INFO) + OPEN_PARENTHESIS + CLASS_STRING + SPACE + CLASS + OBJECT_STRING +
1500 CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + 1470 CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION +
1501 RETURN + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + GET + OPEN_PARENTHESIS + CLASS + 1471 RETURN + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + GET + OPEN_PARENTHESIS + CLASS +
1502 OBJECT_STRING + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + 1472 OBJECT_STRING + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION +
...@@ -1504,17 +1474,29 @@ public final class MethodsGenerator { ...@@ -1504,17 +1474,29 @@ public final class MethodsGenerator {
1504 } 1474 }
1505 1475
1506 /** 1476 /**
1507 - * Returns implementation of get augment info. 1477 + * Returns implementation of get YANG augment info.
1508 * 1478 *
1509 - * @return implementation of get augment info 1479 + * @return implementation of get YANG augment info
1510 */ 1480 */
1511 - static String getAugmentInfoMapImpl(YangPluginConfig pluginConfig) { 1481 + static String getYangAugmentInfoMapInterface(YangPluginConfig pluginConfig) {
1512 -
1513 return getJavaDoc(GETTER_METHOD, getSmallCase(YANG_AUGMENTED_INFO) + MAP, false, pluginConfig) 1482 return getJavaDoc(GETTER_METHOD, getSmallCase(YANG_AUGMENTED_INFO) + MAP, false, pluginConfig)
1483 + + FOUR_SPACE_INDENTATION + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING + DIAMOND_OPEN_BRACKET +
1484 + QUESTION_MARK + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + OBJECT_STRING + DIAMOND_CLOSE_BRACKET +
1485 + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + OPEN_PARENTHESIS +
1486 + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1487 + }
1488 +
1489 + /**
1490 + * Returns implementation of get YANG augment info.
1491 + *
1492 + * @return implementation of get YANG augment info
1493 + */
1494 + static String getYangAugmentInfoMapImpl() {
1495 + return getOverRideString()
1514 + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + 1496 + FOUR_SPACE_INDENTATION + PUBLIC + SPACE +
1515 MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING + DIAMOND_OPEN_BRACKET + QUESTION_MARK + 1497 MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING + DIAMOND_OPEN_BRACKET + QUESTION_MARK +
1516 - DIAMOND_CLOSE_BRACKET + COMMA + SPACE + YANG_AUGMENTED_INFO + DIAMOND_CLOSE_BRACKET + SPACE + 1498 + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + OBJECT_STRING + DIAMOND_CLOSE_BRACKET + SPACE +
1517 - GET_METHOD_PREFIX + YANG_AUGMENTED_INFO + MAP + OPEN_PARENTHESIS + 1499 + getSmallCase(YANG_AUGMENTED_INFO) + MAP + OPEN_PARENTHESIS +
1518 CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + 1500 CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION +
1519 RETURN + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SEMI_COLAN + NEW_LINE 1501 RETURN + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SEMI_COLAN + NEW_LINE
1520 + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 1502 + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
...@@ -1526,7 +1508,7 @@ public final class MethodsGenerator { ...@@ -1526,7 +1508,7 @@ public final class MethodsGenerator {
1526 * @param className enum's class name 1508 * @param className enum's class name
1527 * @return enum's constructor 1509 * @return enum's constructor
1528 */ 1510 */
1529 - public static String getEnumsConstructor(String className) { 1511 + static String getEnumsConstructor(String className) {
1530 return FOUR_SPACE_INDENTATION + className + OPEN_PARENTHESIS + INT + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE 1512 return FOUR_SPACE_INDENTATION + className + OPEN_PARENTHESIS + INT + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE
1531 + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(className) + SPACE + EQUAL 1513 + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(className) + SPACE + EQUAL
1532 + SPACE + VALUE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; 1514 + SPACE + VALUE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
...@@ -1542,9 +1524,9 @@ public final class MethodsGenerator { ...@@ -1542,9 +1524,9 @@ public final class MethodsGenerator {
1542 * @param pluginConfig plugin configurations 1524 * @param pluginConfig plugin configurations
1543 * @return of method 1525 * @return of method
1544 */ 1526 */
1545 - public static String getEnumsOfMethod(String className, JavaAttributeInfo attr, 1527 + static String getEnumsOfMethod(String className, JavaAttributeInfo attr,
1546 - Map<String, Integer> enumMap, List<String> enumList, 1528 + Map<String, Integer> enumMap, List<String> enumList,
1547 - YangPluginConfig pluginConfig) { 1529 + YangPluginConfig pluginConfig) {
1548 String attrType = getReturnType(attr); 1530 String attrType = getReturnType(attr);
1549 String attrName = attr.getAttributeName(); 1531 String attrName = attr.getAttributeName();
1550 1532
...@@ -1553,7 +1535,7 @@ public final class MethodsGenerator { ...@@ -1553,7 +1535,7 @@ public final class MethodsGenerator {
1553 + attrType + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE 1535 + attrType + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
1554 + EIGHT_SPACE_INDENTATION + SWITCH + SPACE + OPEN_PARENTHESIS + VALUE 1536 + EIGHT_SPACE_INDENTATION + SWITCH + SPACE + OPEN_PARENTHESIS + VALUE
1555 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 1537 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
1556 - int value = 0; 1538 + int value;
1557 for (String str : enumList) { 1539 for (String str : enumList) {
1558 1540
1559 value = enumMap.get(str); 1541 value = enumMap.get(str);
...@@ -1570,42 +1552,13 @@ public final class MethodsGenerator { ...@@ -1570,42 +1552,13 @@ public final class MethodsGenerator {
1570 } 1552 }
1571 1553
1572 /** 1554 /**
1573 - * Returns activate method string.
1574 - *
1575 - * @return activate method string
1576 - */
1577 - public static String addActivateMethod() {
1578 - return FOUR_SPACE_INDENTATION + ACTIVATE_ANNOTATION + FOUR_SPACE_INDENTATION
1579 - + PUBLIC + SPACE + VOID + SPACE + ACTIVATE + OPEN_PARENTHESIS
1580 - + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
1581 - + NEW_LINE + EIGHT_SPACE_INDENTATION
1582 - + YANG_UTILS_TODO
1583 - + NEW_LINE + EIGHT_SPACE_INDENTATION
1584 - + STARTED_LOG_INFO + FOUR_SPACE_INDENTATION
1585 - + CLOSE_CURLY_BRACKET + NEW_LINE;
1586 - }
1587 -
1588 - /**
1589 - * Returns deactivate method string.
1590 - *
1591 - * @return deactivate method string
1592 - */
1593 - public static String addDeActivateMethod() {
1594 - return NEW_LINE + FOUR_SPACE_INDENTATION + DEACTIVATE_ANNOTATION + FOUR_SPACE_INDENTATION
1595 - + PUBLIC + SPACE + VOID + SPACE + DEACTIVATE + OPEN_PARENTHESIS
1596 - + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
1597 - + YANG_UTILS_TODO + NEW_LINE + EIGHT_SPACE_INDENTATION
1598 - + STOPPED_LOG_INFO + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
1599 - }
1600 -
1601 - /**
1602 * Returns from string method parsed string. 1555 * Returns from string method parsed string.
1603 * 1556 *
1604 * @param targetDataType target data type 1557 * @param targetDataType target data type
1605 * @param yangType YANG type 1558 * @param yangType YANG type
1606 * @return parsed string 1559 * @return parsed string
1607 */ 1560 */
1608 - public static String getParseFromStringMethod(String targetDataType, YangType<?> yangType) { 1561 + private static String getParseFromStringMethod(String targetDataType, YangType<?> yangType) {
1609 1562
1610 YangDataTypes type = yangType.getDataType(); 1563 YangDataTypes type = yangType.getDataType();
1611 1564
...@@ -1629,7 +1582,6 @@ public final class MethodsGenerator { ...@@ -1629,7 +1582,6 @@ public final class MethodsGenerator {
1629 case DECIMAL64: 1582 case DECIMAL64:
1630 return NEW + SPACE + BIG_DECIMAL; 1583 return NEW + SPACE + BIG_DECIMAL;
1631 case STRING: 1584 case STRING:
1632 - return EMPTY_STRING;
1633 case IDENTITYREF: 1585 case IDENTITYREF:
1634 return EMPTY_STRING; 1586 return EMPTY_STRING;
1635 case EMPTY: 1587 case EMPTY:
...@@ -1646,22 +1598,6 @@ public final class MethodsGenerator { ...@@ -1646,22 +1598,6 @@ public final class MethodsGenerator {
1646 } 1598 }
1647 1599
1648 /** 1600 /**
1649 - * Returns the constructor strings for class file.
1650 - *
1651 - * @param attr attribute info
1652 - * @param pluginConfig plugin configurations
1653 - * @return constructor for class
1654 - */
1655 - public static String getAugmentedConstructor(JavaAttributeInfo attr, YangPluginConfig pluginConfig) {
1656 -
1657 - String attributeName = getCamelCase(attr.getAttributeName(), pluginConfig.getConflictResolver());
1658 -
1659 - return EIGHT_SPACE_INDENTATION + THIS + PERIOD + attributeName + OPEN_PARENTHESIS
1660 - + VALUE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
1661 - + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1662 - }
1663 -
1664 - /**
1665 * Returns augmented data getter and setter methods for service class. 1601 * Returns augmented data getter and setter methods for service class.
1666 * 1602 *
1667 * @param parent parent node 1603 * @param parent parent node
...@@ -1688,11 +1624,9 @@ public final class MethodsGenerator { ...@@ -1688,11 +1624,9 @@ public final class MethodsGenerator {
1688 } 1624 }
1689 returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent); 1625 returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent);
1690 parentName = getParentNodeNameForDataMethods(augmentedNode, pluginConfig); 1626 parentName = getParentNodeNameForDataMethods(augmentedNode, pluginConfig);
1691 - method = getJavaDoc(GETTER_METHOD, getSmallCase(AUGMENTED + parentName + curNodeName), false, 1627 + method = generateForGetMethodWithAttribute(returnType)
1692 - pluginConfig) + getGetterForInterface(AUGMENTED + parentName 1628 + + getGetMethodWithArgument(returnType, AUGMENTED + parentName
1693 - + getCapitalCase(curNodeName), 1629 + + getCapitalCase(curNodeName)) + NEW_LINE;
1694 - returnType, false, GENERATE_SERVICE_AND_MANAGER)
1695 - + NEW_LINE;
1696 methods.append(method); 1630 methods.append(method);
1697 1631
1698 method = getJavaDoc(MANAGER_SETTER_METHOD, AUGMENTED + 1632 method = getJavaDoc(MANAGER_SETTER_METHOD, AUGMENTED +
...@@ -1707,54 +1641,12 @@ public final class MethodsGenerator { ...@@ -1707,54 +1641,12 @@ public final class MethodsGenerator {
1707 } 1641 }
1708 1642
1709 /** 1643 /**
1710 - * Returns augmented data getter and setter methods for manager class.
1711 - *
1712 - * @param parent parent node
1713 - * @return augmented data getter and setter methods for manager class
1714 - */
1715 - static String getAugmentsDataMethodForManager(YangNode parent) {
1716 - List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent);
1717 - YangNode augmentedNode;
1718 - String curNodeName;
1719 - String returnType;
1720 - String method;
1721 - StringBuilder methods = new StringBuilder();
1722 - String parentName;
1723 - YangNode methodNode;
1724 - YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig();
1725 - for (YangAtomicPath nodeId : targets) {
1726 - augmentedNode = nodeId.getResolvedNode().getParent();
1727 - methodNode = nodeId.getResolvedNode();
1728 - if (((JavaFileInfoContainer) methodNode).getJavaFileInfo().getJavaName() != null) {
1729 - curNodeName = ((JavaFileInfoContainer) methodNode).getJavaFileInfo().getJavaName();
1730 - } else {
1731 - curNodeName = getCapitalCase(getCamelCase(methodNode.getName(), pluginConfig
1732 - .getConflictResolver()));
1733 - }
1734 - returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent);
1735 - parentName = getParentNodeNameForDataMethods(augmentedNode, pluginConfig);
1736 - method = getOverRideString() + getGetter(returnType, AUGMENTED
1737 - + parentName + getCapitalCase(curNodeName),
1738 - GENERATE_SERVICE_AND_MANAGER) + NEW_LINE;
1739 - methods.append(method);
1740 -
1741 - method = getOverRideString() + getSetter(parentName, getSmallCase(AUGMENTED) +
1742 - getCapitalCase(parentName) + getCapitalCase(curNodeName),
1743 - returnType,
1744 - GENERATE_SERVICE_AND_MANAGER)
1745 - + NEW_LINE;
1746 - methods.append(method);
1747 - }
1748 - return methods.toString();
1749 - }
1750 -
1751 - /**
1752 * Returns validator method for range in union class. 1644 * Returns validator method for range in union class.
1753 * 1645 *
1754 * @param type type 1646 * @param type type
1755 * @return validator method for range in union class 1647 * @return validator method for range in union class
1756 */ 1648 */
1757 - public static String getRangeValidatorMethodForUnion(String type) { 1649 + static String getRangeValidatorMethodForUnion(String type) {
1758 String newType; 1650 String newType;
1759 if (type.contentEquals(BIG_INTEGER)) { 1651 if (type.contentEquals(BIG_INTEGER)) {
1760 newType = LONG; 1652 newType = LONG;
...@@ -1790,7 +1682,7 @@ public final class MethodsGenerator { ...@@ -1790,7 +1682,7 @@ public final class MethodsGenerator {
1790 * @param addFirst true int/long need to be added first 1682 * @param addFirst true int/long need to be added first
1791 * @return if condition string for typedef constructor 1683 * @return if condition string for typedef constructor
1792 */ 1684 */
1793 - private static String ifConditionForIntInTypeDefConstrcutor(ValidatorTypeForUnionTypes type, boolean addFirst) { 1685 + private static String ifConditionForIntInTypeDefConstructor(ValidatorTypeForUnionTypes type, boolean addFirst) {
1794 String condition = EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + VALIDATE_RANGE + OPEN_PARENTHESIS; 1686 String condition = EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + VALIDATE_RANGE + OPEN_PARENTHESIS;
1795 1687
1796 if (type == INT_TYPE_CONFLICT) { 1688 if (type == INT_TYPE_CONFLICT) {
...@@ -1809,5 +1701,249 @@ public final class MethodsGenerator { ...@@ -1809,5 +1701,249 @@ public final class MethodsGenerator {
1809 return condition + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; 1701 return condition + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
1810 } 1702 }
1811 1703
1704 + //Get method with arguments.
1705 + private static String getGetMethodWithArgument(String returnType, String yangName) {
1706 + return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCapitalCase(yangName)
1707 + + OPEN_PARENTHESIS + returnType + OP_PARAM + SPACE + getSmallCase(returnType) + CLOSE_PARENTHESIS +
1708 + SEMI_COLAN;
1709 + }
1812 1710
1711 + /**
1712 + * Returns add to list method interface.
1713 + *
1714 + * @param attr java attribute
1715 + * @return add to list method interface
1716 + */
1717 + public static String getAddToListMethodInterface(JavaAttributeInfo attr) {
1718 + return FOUR_SPACE_INDENTATION + VOID + SPACE + ADD_STRING + getCapitalCase(TO) +
1719 + getCapitalCase(attr.getAttributeName()) + OPEN_PARENTHESIS + getReturnType(attr) + SPACE +
1720 + VALUE + CLOSE_PARENTHESIS + SEMI_COLAN;
1721 + }
1722 +
1723 + /**
1724 + * Returns add to list method impl.
1725 + *
1726 + * @param attr java attribute
1727 + * @return add to list method impl
1728 + */
1729 + public static String getAddToListMethodImpl(JavaAttributeInfo attr) {
1730 + return getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + ADD_STRING +
1731 + getCapitalCase(TO) + getCapitalCase(attr.getAttributeName()) + OPEN_PARENTHESIS +
1732 + getReturnType(attr) + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET
1733 + + NEW_LINE + EIGHT_SPACE_INDENTATION + attr.getAttributeName() + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
1734 + + PERIOD + ADD_STRING + OPEN_PARENTHESIS + VALUE + CLOSE_PARENTHESIS + SEMI_COLAN +
1735 + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
1736 + }
1737 +
1738 + /**
1739 + * Returns builder method for class.
1740 + *
1741 + * @param name name of class
1742 + * @return builder method for class
1743 + */
1744 + static String builderMethod(String name) {
1745 + return NEW_LINE + generateForBuilderMethod(name) + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC + SPACE
1746 + + name + BUILDER + SPACE + getSmallCase(BUILDER) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE +
1747 + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE + NEW + SPACE + name +
1748 + BUILDER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION +
1749 + CLOSE_CURLY_BRACKET;
1750 + }
1751 +
1752 + /**
1753 + * Returns is filter content match interface.
1754 + *
1755 + * @param name name of node
1756 + * @return is filter content match interface
1757 + */
1758 + static String isFilterContentMatchInterface(String name) {
1759 + String method = " /**\n" +
1760 + " * Checks if the passed " + name + " maps the content match query condition.\n" +
1761 + " *\n" +
1762 + " * @param " + getSmallCase(name) + SPACE + getSmallCase(name) + SPACE + "being passed to check" +
1763 + " for" +
1764 + " content match\n" +
1765 + " * @return match result\n" +
1766 + " */\n";
1767 + return method + FOUR_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS
1768 + + name + SPACE + getSmallCase(name) + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1769 + }
1770 +
1771 + /**
1772 + * Returns is value set interface.
1773 + *
1774 + * @return is value set interface
1775 + */
1776 + static String isLeafValueSetInterface() {
1777 + String method = " /**\n" +
1778 + " * Checks if the leaf value is set.\n" +
1779 + " *\n" +
1780 + " * @param leaf leaf whose value status needs to checked\n" +
1781 + " * @return result of leaf value set in object\n" +
1782 + " */\n";
1783 + return method + FOUR_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE + VALUE_LEAF_SET + OPEN_PARENTHESIS
1784 + + LEAF_IDENTIFIER + SPACE + "leaf" + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1785 + }
1786 +
1787 + /**
1788 + * Returns is select leaf set interface.
1789 + *
1790 + * @return is select leaf set interface
1791 + */
1792 + static String isSelectLeafSetInterface() {
1793 + String method = " /**\n" +
1794 + " * Checks if the leaf is set to be a selected leaf.\n" +
1795 + " *\n" +
1796 + " * @param leaf if leaf needs to be selected\n" +
1797 + " * @return result of leaf value set in object\n" +
1798 + " */\n";
1799 + return method + FOUR_SPACE_INDENTATION + BOOLEAN_DATA_TYPE + SPACE + IS_SELECT_LEAF + OPEN_PARENTHESIS
1800 + + LEAF_IDENTIFIER + SPACE + "leaf" + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1801 + }
1802 +
1803 + /**
1804 + * Returns set select leaf set interface.
1805 + *
1806 + * @param name node name
1807 + * @return set select leaf set interface
1808 + */
1809 + static String setSelectLeafSetInterface(String name) {
1810 + String method = " /**\n" +
1811 + " * Set a leaf to be selected.\n" +
1812 + " *\n" +
1813 + " * @param leaf leaf needs to be selected\n" +
1814 + " */\n";
1815 + return method + FOUR_SPACE_INDENTATION + name + BUILDER + SPACE + SET_SELECT_LEAF + OPEN_PARENTHESIS
1816 + + LEAF_IDENTIFIER + SPACE + "leaf" + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1817 + }
1818 +
1819 + /**
1820 + * Returns leaf identifier interface enum signature.
1821 + *
1822 + * @param name name of node
1823 + * @return leaf identifier interface enum signature
1824 + */
1825 + static String getInterfaceLeafIdEnumSignature(String name) {
1826 + String start = " /**\n" +
1827 + " * Identify the leaf of " + name + PERIOD + NEW_LINE +
1828 + " */\n";
1829 + return start + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + ENUM + SPACE + LEAF_IDENTIFIER + SPACE +
1830 + OPEN_CURLY_BRACKET + NEW_LINE;
1831 + }
1832 +
1833 + /**
1834 + * Returns interface leaf identifier enum method.
1835 + *
1836 + * @return interface leaf identifier enum method
1837 + */
1838 + static String getInterfaceLeafIdEnumMethods() {
1839 + return " private int leafIndex;\n" +
1840 + "\n" +
1841 + " public int getLeafIndex() {\n" +
1842 + " return leafIndex;\n" +
1843 + " }\n" +
1844 + "\n" +
1845 + " LeafIdentifier(int value) {\n" +
1846 + " this.leafIndex = value;\n" +
1847 + " }\n" +
1848 + " }\n";
1849 + }
1850 +
1851 + /**
1852 + * Returns getter methods for operation attributes.
1853 + *
1854 + * @return getter methods for operation attributes
1855 + */
1856 + static String getOperationAttributesGetters() {
1857 + return "\n" +
1858 + " /**\n" +
1859 + " * Returns the _valueLeafFlags.\n" +
1860 + " *\n" +
1861 + " * @return value of _valueLeafFlags\n" +
1862 + " */\n" +
1863 + " public BitSet get_valueLeafFlags() {\n" +
1864 + " return _valueLeafFlags;\n" +
1865 + " }\n" +
1866 + "\n" +
1867 + " /**\n" +
1868 + " * Returns the _selectLeafFlags.\n" +
1869 + " *\n" +
1870 + " * @return value of _selectLeafFlags\n" +
1871 + " */\n" +
1872 + " public BitSet get_selectLeafFlags() {\n" +
1873 + " return _selectLeafFlags;\n" +
1874 + " }\n" +
1875 + "\n";
1876 + }
1877 +
1878 + /**
1879 + * Returns getter for operation type.
1880 + *
1881 + * @return getter for operation type
1882 + */
1883 + static String getGetterForOperationType() {
1884 + return " /**\n" +
1885 + " * Returns the _operationType.\n" +
1886 + " *\n" +
1887 + " * @return value of _operationType\n" +
1888 + " */\n" +
1889 + " public OperationType get_operationType() {\n" +
1890 + " return _operationType;\n" +
1891 + " }\n";
1892 + }
1893 +
1894 + /**
1895 + * Returns getters for value and select leaf.
1896 + *
1897 + * @return getters for value and select leaf
1898 + */
1899 + static String getGettersForValueAndSelectLeaf() {
1900 + return "\n" +
1901 + " @Override\n" +
1902 + " public boolean isLeafValueSet(LeafIdentifier leaf) {\n" +
1903 + " return get_valueLeafFlags().get(leaf.getLeafIndex());\n" +
1904 + " }\n" +
1905 + "\n" +
1906 + " @Override\n" +
1907 + " public boolean isSelectLeaf(LeafIdentifier leaf) {\n" +
1908 + " return get_selectLeafFlags().get(leaf.getLeafIndex());\n" +
1909 + " }\n";
1910 + }
1911 +
1912 + /**
1913 + * Returns setter for operation type.
1914 + *
1915 + * @param name name of node
1916 + * @return setter for operation type
1917 + */
1918 + static String getSetterForOperationType(String name) {
1919 + return " /**\n" +
1920 + " * Set operation type.\n" +
1921 + " *\n" +
1922 + " * @param _operationType operation type\n" +
1923 + " */\n" +
1924 + " public " + name + BUILDER + " set_operationType(OperationType _operationType) {\n" +
1925 + " this._operationType = _operationType;\n" +
1926 + " return this;\n" +
1927 + " }\n";
1928 + }
1929 +
1930 + /**
1931 + * Returns setter for select leaf.
1932 + *
1933 + * @param name name of node
1934 + * @param isRootNode if root node
1935 + * @return setter for select leaf
1936 + */
1937 + static String getSetterForSelectLeaf(String name, boolean isRootNode) {
1938 + String append = OVERRIDE;
1939 + if (isRootNode) {
1940 + append = EMPTY_STRING;
1941 + }
1942 + return "\n" +
1943 + " " + append + "\n" +
1944 + " public " + name + BUILDER + " selectLeaf(LeafIdentifier leaf) {\n" +
1945 + " get_selectLeafFlags().set(leaf.getLeafIndex());\n" +
1946 + " return this;\n" +
1947 + " }\n";
1948 + }
1813 } 1949 }
......
...@@ -22,12 +22,12 @@ package org.onosproject.yangutils.translator.tojava.utils; ...@@ -22,12 +22,12 @@ package org.onosproject.yangutils.translator.tojava.utils;
22 public enum ValidatorTypeForUnionTypes { 22 public enum ValidatorTypeForUnionTypes {
23 23
24 /** 24 /**
25 - * When conflict is there for int32 and uint16. 25 + * When conflict is there for int32 and uInt16.
26 */ 26 */
27 INT_TYPE_CONFLICT, 27 INT_TYPE_CONFLICT,
28 28
29 /** 29 /**
30 - * When conflict is there for int64 and uint32. 30 + * When conflict is there for int64 and uInt32.
31 */ 31 */
32 LONG_TYPE_CONFLICT 32 LONG_TYPE_CONFLICT
33 } 33 }
......
...@@ -107,6 +107,11 @@ public final class UtilConstants { ...@@ -107,6 +107,11 @@ public final class UtilConstants {
107 public static final String JAVA_DOC_SETTERS = " * Returns the builder object of "; 107 public static final String JAVA_DOC_SETTERS = " * Returns the builder object of ";
108 108
109 /** 109 /**
110 + * JavaDocs's description for add to list method.
111 + */
112 + public static final String JAVA_DOC_ADD_TO_LIST = " * Adds to the list of ";
113 +
114 + /**
110 * JavaDocs's description for setter method. 115 * JavaDocs's description for setter method.
111 */ 116 */
112 public static final String JAVA_DOC_MANAGER_SETTERS = " * Sets the value to attribute "; 117 public static final String JAVA_DOC_MANAGER_SETTERS = " * Sets the value to attribute ";
...@@ -187,11 +192,6 @@ public final class UtilConstants { ...@@ -187,11 +192,6 @@ public final class UtilConstants {
187 public static final String OPERATION = "OpParam"; 192 public static final String OPERATION = "OpParam";
188 193
189 /** 194 /**
190 - * Static attribute for operation type.
191 - */
192 - public static final String OPERATION_ENUM = "OperationType";
193 -
194 - /**
195 * Static attribute for java code generation for sbi. 195 * Static attribute for java code generation for sbi.
196 */ 196 */
197 public static final String SBI = "sbi"; 197 public static final String SBI = "sbi";
...@@ -217,14 +217,14 @@ public final class UtilConstants { ...@@ -217,14 +217,14 @@ public final class UtilConstants {
217 public static final String PERIOD = "."; 217 public static final String PERIOD = ".";
218 218
219 /** 219 /**
220 - * Static attribute for parse byte. 220 + * Static attribute for period.
221 */ 221 */
222 - public static final String PARSE_BYTE = "parseByte"; 222 + public static final String INVOKE = "invoke";
223 223
224 /** 224 /**
225 - * Static attribute for get bytes. 225 + * Static attribute for parse byte.
226 */ 226 */
227 - public static final String GET_BYTES = "getBytes"; 227 + public static final String PARSE_BYTE = "parseByte";
228 228
229 /** 229 /**
230 * Static attribute for parse boolean. 230 * Static attribute for parse boolean.
...@@ -694,11 +694,6 @@ public final class UtilConstants { ...@@ -694,11 +694,6 @@ public final class UtilConstants {
694 public static final String OPEN_PARENTHESIS = "("; 694 public static final String OPEN_PARENTHESIS = "(";
695 695
696 /** 696 /**
697 - * Static attribute for received syntax.
698 - */
699 - public static final String RECEIVED_OBJECT = "recv";
700 -
701 - /**
702 * Static attribute for switch syntax. 697 * Static attribute for switch syntax.
703 */ 698 */
704 public static final String SWITCH = "switch"; 699 public static final String SWITCH = "switch";
...@@ -749,6 +744,16 @@ public final class UtilConstants { ...@@ -749,6 +744,16 @@ public final class UtilConstants {
749 public static final String GET_METHOD_PREFIX = "get"; 744 public static final String GET_METHOD_PREFIX = "get";
750 745
751 /** 746 /**
747 + * Static attribute for getter method prefix.
748 + */
749 + public static final String GET_METHOD = "getMethod";
750 +
751 + /**
752 + * Static attribute for getter method prefix.
753 + */
754 + public static final String GET_CLASS = "getClass()";
755 +
756 + /**
752 * Static attribute for setter method prefix. 757 * Static attribute for setter method prefix.
753 */ 758 */
754 public static final String SET_METHOD_PREFIX = "set"; 759 public static final String SET_METHOD_PREFIX = "set";
...@@ -756,62 +761,58 @@ public final class UtilConstants { ...@@ -756,62 +761,58 @@ public final class UtilConstants {
756 /** 761 /**
757 * Static attribute for get filter leaf flags. 762 * Static attribute for get filter leaf flags.
758 */ 763 */
759 - public static final String GET_FILTER_LEAF = "getFilterLeafFlags"; 764 + public static final String GET_FILTER_LEAF = "get_valueLeafFlags";
760 765
761 /** 766 /**
762 - * Static attribute for get filter leaf list flags. 767 + * Static attribute for getLeafIndex.
763 */ 768 */
764 - public static final String GET_FILTER_LEAF_LIST = "getFilterLeafListFlags"; 769 + public static final String GET_LEAF_INDEX = "getLeafIndex()";
765 770
766 /** 771 /**
767 - * Static attribute for filter leaf flags. 772 + * Static attribute for op param.
768 */ 773 */
769 - public static final String FILTER_LEAF = "filterLeafFlags"; 774 + public static final String OP_PARAM = "OpParam";
770 775
771 - /**
772 - * Static attribute for filter leaf list flags.
773 - */
774 - public static final String FILTER_LEAF_LIST = "filterLeafListFlags";
775 776
776 /** 777 /**
777 - * Static attribute for get select leaf flags. 778 + * Static attribute for is filter content match method prefix.
778 */ 779 */
779 - public static final String GET_SELECT_LEAF = "getSelectLeafFlags"; 780 + public static final String FILTER_CONTENT_MATCH = "isFilterContentMatch";
780 781
781 /** 782 /**
782 - * Static attribute for get select leaf list flags. 783 + * Static attribute for flag prefix.
783 */ 784 */
784 - public static final String GET_SELECT_LEAF_LIST = "getSelectLeafListFlags"; 785 + public static final String FLAG = "flag";
785 786
786 /** 787 /**
787 - * Static attribute for get operation type. 788 + * Static attribute for break prefix.
788 */ 789 */
789 - public static final String GET_OPERATION_TYPE = "getOpertionType"; 790 + public static final String BREAK = "break";
790 791
791 /** 792 /**
792 - * Static attribute for set operation type. 793 + * Static attribute for break prefix.
793 */ 794 */
794 - public static final String SET_OPERATION_TYPE = "setOpertionType"; 795 + public static final String IS_EMPTY = "isEmpty()";
795 796
796 /** 797 /**
797 - * Static attribute for select leaf flags. 798 + * Static attribute for is isLeafValueSet method prefix.
798 */ 799 */
799 - public static final String SELECT_LEAF = "selectLeafFlags"; 800 + public static final String VALUE_LEAF_SET = "isLeafValueSet";
800 801
801 /** 802 /**
802 - * Static attribute for select leaf list flags. 803 + * Static attribute for is isSelectLeaf method prefix.
803 */ 804 */
804 - public static final String SELECT_LEAF_LIST = "selectLeafListFlags"; 805 + public static final String IS_SELECT_LEAF = "isSelectLeaf";
805 806
806 /** 807 /**
807 - * Static attribute for op param type. 808 + * Static attribute for is selectLeaf method prefix.
808 */ 809 */
809 - public static final String OP_PARAM_TYPE = "opParamType"; 810 + public static final String SET_SELECT_LEAF = "selectLeaf";
810 811
811 /** 812 /**
812 - * Static attribute for is filter content match method prefix. 813 + * Static attribute for is LeafIdentifier enum prefix.
813 */ 814 */
814 - public static final String FILTER_CONTENT_MATCH = "isFilterContentMatch"; 815 + public static final String LEAF_IDENTIFIER = "LeafIdentifier";
815 816
816 /** 817 /**
817 * Static attribute for four space indentation. 818 * Static attribute for four space indentation.
...@@ -834,36 +835,6 @@ public final class UtilConstants { ...@@ -834,36 +835,6 @@ public final class UtilConstants {
834 public static final String CATCH = "catch"; 835 public static final String CATCH = "catch";
835 836
836 /** 837 /**
837 - * Static attribute for super syntax.
838 - */
839 - public static final String SUPER = "super";
840 -
841 - /**
842 - * Static attribute for merge syntax.
843 - */
844 - public static final String MERGE = "MERGE,";
845 -
846 - /**
847 - * Static attribute for replace syntax.
848 - */
849 - public static final String REPLACE = "REPLACE,";
850 -
851 - /**
852 - * Static attribute for create syntax.
853 - */
854 - public static final String CREATE = "CREATE,";
855 -
856 - /**
857 - * Static attribute for delete syntax.
858 - */
859 - public static final String DELETE = "DELETE,";
860 -
861 - /**
862 - * Static attribute for remove syntax.
863 - */
864 - public static final String REMOVE = "REMOVE";
865 -
866 - /**
867 * Static attribute for eight space indentation. 838 * Static attribute for eight space indentation.
868 */ 839 */
869 public static final String EIGHT_SPACE_INDENTATION = FOUR_SPACE_INDENTATION + FOUR_SPACE_INDENTATION; 840 public static final String EIGHT_SPACE_INDENTATION = FOUR_SPACE_INDENTATION + FOUR_SPACE_INDENTATION;
...@@ -879,6 +850,16 @@ public final class UtilConstants { ...@@ -879,6 +850,16 @@ public final class UtilConstants {
879 public static final String SIXTEEN_SPACE_INDENTATION = EIGHT_SPACE_INDENTATION + EIGHT_SPACE_INDENTATION; 850 public static final String SIXTEEN_SPACE_INDENTATION = EIGHT_SPACE_INDENTATION + EIGHT_SPACE_INDENTATION;
880 851
881 /** 852 /**
853 + * Static attribute for twenty space indentation.
854 + */
855 + public static final String TWENTY_SPACE_INDENTATION = FOUR_SPACE_INDENTATION + SIXTEEN_SPACE_INDENTATION;
856 +
857 + /**
858 + * Static attribute for twenty four space indentation.
859 + */
860 + public static final String TWENTY_FOUR_SPACE_INDENTATION = EIGHT_SPACE_INDENTATION + SIXTEEN_SPACE_INDENTATION;
861 +
862 + /**
882 * Static attribute for generated code path. 863 * Static attribute for generated code path.
883 */ 864 */
884 public static final String YANG_GEN_DIR = "src/main/java/"; 865 public static final String YANG_GEN_DIR = "src/main/java/";
...@@ -899,7 +880,7 @@ public final class UtilConstants { ...@@ -899,7 +880,7 @@ public final class UtilConstants {
899 public static final String YANG_AUTO_PREFIX = "yangAutoPrefix"; 880 public static final String YANG_AUTO_PREFIX = "yangAutoPrefix";
900 881
901 /** 882 /**
902 - * Static attribute for YANG version perifx. 883 + * Static attribute for YANG version prefix.
903 */ 884 */
904 public static final String VERSION_PREFIX = "v"; 885 public static final String VERSION_PREFIX = "v";
905 886
...@@ -1014,7 +995,7 @@ public final class UtilConstants { ...@@ -1014,7 +995,7 @@ public final class UtilConstants {
1014 public static final String LONG_WRAPPER = "Long"; 995 public static final String LONG_WRAPPER = "Long";
1015 996
1016 /** 997 /**
1017 - * Static varibale for question mark. 998 + * Static variable for question mark.
1018 */ 999 */
1019 public static final String QUESTION_MARK = "?"; 1000 public static final String QUESTION_MARK = "?";
1020 1001
...@@ -1022,11 +1003,11 @@ public final class UtilConstants { ...@@ -1022,11 +1003,11 @@ public final class UtilConstants {
1022 * List of keywords in java, this is used for checking if the input does not contain these keywords. 1003 * List of keywords in java, this is used for checking if the input does not contain these keywords.
1023 */ 1004 */
1024 public static final List<String> JAVA_KEY_WORDS = Arrays.asList( 1005 public static final List<String> JAVA_KEY_WORDS = Arrays.asList(
1025 - "abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized", 1006 + "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue",
1026 - "boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", 1007 + "default", "do", "double", "else", "extends", "false", "final", "finally", "float", "for", "goto", "if",
1027 - "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", 1008 + "implements", "import", "instanceof", "enum", "int", "interface", "long", "native", "new", "null",
1028 - "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", 1009 + "package", "private", "protected", "public", "return", "short", "static", "strictfp", "super", "switch",
1029 - "long", "strictfp", "volatile", "const", "float", "native", "super", "while"); 1010 + "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while");
1030 1011
1031 /** 1012 /**
1032 * Static attribute for regex for all the special characters. 1013 * Static attribute for regex for all the special characters.
...@@ -1199,11 +1180,6 @@ public final class UtilConstants { ...@@ -1199,11 +1180,6 @@ public final class UtilConstants {
1199 public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject"; 1180 public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject";
1200 1181
1201 /** 1182 /**
1202 - * Static attribute for impl syntax.
1203 - */
1204 - public static final String IMPL = "Impl";
1205 -
1206 - /**
1207 * Static attribute for build method syntax. 1183 * Static attribute for build method syntax.
1208 */ 1184 */
1209 public static final String BUILD = "build"; 1185 public static final String BUILD = "build";
...@@ -1275,21 +1251,6 @@ public final class UtilConstants { ...@@ -1275,21 +1251,6 @@ public final class UtilConstants {
1275 public static final String JAVA_UTIL_IMPORT_BASE64_CLASS = "Base64;\n"; 1251 public static final String JAVA_UTIL_IMPORT_BASE64_CLASS = "Base64;\n";
1276 1252
1277 /** 1253 /**
1278 - * Static attribute for AugmentedInfo class import package.
1279 - */
1280 - public static final String YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG = "org.onosproject.yangutils.datamodel";
1281 -
1282 - /**
1283 - * Static attribute for AugmentedInfo class import class.
1284 - */
1285 - public static final String YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS = "YangAugmentedInfo;\n";
1286 -
1287 - /**
1288 - * Static attribute for augmentation class.
1289 - */
1290 - public static final String AUGMENTED_INFO = "AugmentedInfo";
1291 -
1292 - /**
1293 * Static attribute for AugmentedInfo class. 1254 * Static attribute for AugmentedInfo class.
1294 */ 1255 */
1295 public static final String YANG_AUGMENTED_INFO = "YangAugmentedInfo"; 1256 public static final String YANG_AUGMENTED_INFO = "YangAugmentedInfo";
...@@ -1305,104 +1266,11 @@ public final class UtilConstants { ...@@ -1305,104 +1266,11 @@ public final class UtilConstants {
1305 public static final String LIST = "List"; 1266 public static final String LIST = "List";
1306 1267
1307 /** 1268 /**
1308 - * Comment to be added for autogenerated impl methods. 1269 + * Comment to be added for auto generated impl methods.
1309 */ 1270 */
1310 public static final String YANG_UTILS_TODO = "//TODO: YANG utils generated code"; 1271 public static final String YANG_UTILS_TODO = "//TODO: YANG utils generated code";
1311 1272
1312 /** 1273 /**
1313 - * Static attribute for activate annotation.
1314 - */
1315 - public static final String ACTIVATE_ANNOTATION = "@Activate\n";
1316 -
1317 - /**
1318 - * Static attribute for activate.
1319 - */
1320 - public static final String ACTIVATE = "activate";
1321 -
1322 - /**
1323 - * Static attribute for activate annotation import.
1324 - */
1325 - public static final String ACTIVATE_ANNOTATION_IMPORT = "import org.apache.felix.scr.annotations.Activate;\n";
1326 -
1327 - /**
1328 - * Static attribute for deactivate annotation.
1329 - */
1330 - public static final String DEACTIVATE_ANNOTATION = "@Deactivate\n";
1331 -
1332 - /**
1333 - * Static attribute for deactivate.
1334 - */
1335 - public static final String DEACTIVATE = "deactivate";
1336 -
1337 - /**
1338 - * Static attribute for deactivate annotation import.
1339 - */
1340 - public static final String DEACTIVATE_ANNOTATION_IMPORT =
1341 - "import org.apache.felix.scr.annotations.Deactivate;\n";
1342 -
1343 - /**
1344 - * Static attribute for component annotation.
1345 - */
1346 - public static final String COMPONENT_ANNOTATION = "@Component";
1347 -
1348 - /**
1349 - * Static attribute for component.
1350 - */
1351 - public static final String COMPONENT = "Component";
1352 -
1353 - /**
1354 - * Static attribute for immediate.
1355 - */
1356 - public static final String IMMEDIATE = "immediate";
1357 -
1358 - /**
1359 - * Static attribute for component annotation import.
1360 - */
1361 - public static final String COMPONENT_ANNOTATION_IMPORT =
1362 - "import org.apache.felix.scr.annotations.Component;\n";
1363 -
1364 - /**
1365 - * Static attribute for service annotation.
1366 - */
1367 - public static final String SERVICE_ANNOTATION = "@Service\n";
1368 -
1369 - /**
1370 - * Static attribute for service annotation import.
1371 - */
1372 - public static final String SERVICE_ANNOTATION_IMPORT =
1373 - "import org.apache.felix.scr.annotations.Service;\n";
1374 -
1375 - /**
1376 - * Static attribute for logger factory import.
1377 - */
1378 - public static final String LOGGER_FACTORY_IMPORT =
1379 - "import static org.slf4j.LoggerFactory.getLogger;\n";
1380 -
1381 - /**
1382 - * Static attribute for logger import.
1383 - */
1384 - public static final String LOGGER_IMPORT =
1385 - "import org.slf4j.Logger;\n";
1386 -
1387 - /**
1388 - * Static attribute for logger statement.
1389 - */
1390 - public static final String LOGGER_STATEMENT =
1391 - "\n private final Logger log = getLogger(getClass());\n";
1392 -
1393 - /**
1394 - * Static attribute for logger statement for started.
1395 - */
1396 - public static final String STARTED_LOG_INFO =
1397 - "log.info(\"Started\");\n";
1398 -
1399 - /**
1400 - * Static attribute for logger statement for stopped.
1401 - */
1402 - public static final String STOPPED_LOG_INFO =
1403 - "log.info(\"Stopped\");\n";
1404 -
1405 - /**
1406 * Static attribute for AbstractEvent. 1274 * Static attribute for AbstractEvent.
1407 */ 1275 */
1408 public static final String ABSTRACT_EVENT = "AbstractEvent"; 1276 public static final String ABSTRACT_EVENT = "AbstractEvent";
...@@ -1470,16 +1338,6 @@ public final class UtilConstants { ...@@ -1470,16 +1338,6 @@ public final class UtilConstants {
1470 + "identity for given base"; 1338 + "identity for given base";
1471 1339
1472 /** 1340 /**
1473 - * Static attribute for reference.
1474 - */
1475 - public static final String REFERENCE = "Reference";
1476 -
1477 - /**
1478 - * Static attribute for ReferenceCardinality.
1479 - */
1480 - public static final String REFERENCE_CARDINALITY = "ReferenceCardinality";
1481 -
1482 - /**
1483 * Static attribute for jar. 1341 * Static attribute for jar.
1484 */ 1342 */
1485 public static final String JAR = "jar"; 1343 public static final String JAR = "jar";
...@@ -1495,31 +1353,34 @@ public final class UtilConstants { ...@@ -1495,31 +1353,34 @@ public final class UtilConstants {
1495 public static final String YANG_AUGMENTED_OP_PARAM_INFO = "YangAugmentedOpParamInfo"; 1353 public static final String YANG_AUGMENTED_OP_PARAM_INFO = "YangAugmentedOpParamInfo";
1496 1354
1497 /** 1355 /**
1498 - * Static attribute for YangAugmentedOpParamInfo. 1356 + * Static attribute for NoSuchMethodException.
1499 */ 1357 */
1500 - public static final String YANG_AUGMENTED_OP_PARAM_INFO_CLASS = "YangAugmentedOpParamInfo;\n"; 1358 + public static final String NO_SUCH_METHOD_EXCEPTION = "NoSuchMethodException";
1501 1359
1502 /** 1360 /**
1503 - * Static attribute for IllegalArgumentException. 1361 + * Static attribute for InvocationTargetException.
1504 */ 1362 */
1505 - public static final String ILLEGAL_ARGUMENT_EXCEPTION = "IllegalArgumentException"; 1363 + public static final String INVOCATION_TARGET_EXCEPTION = "InvocationTargetException";
1506 1364
1507 /** 1365 /**
1508 - * Static attribute for IllegalArgumentException. 1366 + * Static attribute for InvocationTargetException.
1509 */ 1367 */
1510 - public static final String ILLEGAL_ARGUMENT_EXCEPTION_MSG = "\"provided augmented info is invalid for content " + 1368 + public static final String INVOCATION_TARGET_EXCEPTION_IMPORT = "import" +
1511 - "match.\""; 1369 + " java.lang.reflect.InvocationTargetException;\n";
1512 -
1513 /** 1370 /**
1514 - * Static attribute for throw. 1371 + * Static attribute for IllegalAccessException.
1515 */ 1372 */
1516 - public static final String THROW = "throw"; 1373 + public static final String ILLEGAL_ACCESS_EXCEPTION = "IllegalAccessException";
1517 1374
1518 /** 1375 /**
1519 - * Static attribute for baseClass(). 1376 + * Static attribute for arrayList.
1520 */ 1377 */
1521 - public static final String BASE_CLASS = "BaseClass()"; 1378 + public static final String ARRAY_LIST = "ArrayList<>()";
1522 1379
1380 + /**
1381 + * Static attribute for arrayList import.
1382 + */
1383 + public static final String ARRAY_LIST_IMPORT = IMPORT + COLLECTION_IMPORTS + ".ArrayList;\n";
1523 1384
1524 /** 1385 /**
1525 * Creates an instance of util constants. 1386 * Creates an instance of util constants.
......
...@@ -44,16 +44,13 @@ public final class FileSystemUtil { ...@@ -44,16 +44,13 @@ public final class FileSystemUtil {
44 } 44 }
45 45
46 /** 46 /**
47 - * Reads the contents from source file and append its contents to append 47 + * Reads the contents from source file and append its contents to append file.
48 - * file.
49 * 48 *
50 - * @param toAppend destination file in which the contents of source file is 49 + * @param toAppend destination file in which the contents of source file is appended
51 - * appended 50 + * @param srcFile source file from which data is read and added to to append file
52 - * @param srcFile source file from which data is read and added to to append
53 - * file
54 * @throws IOException any IO errors 51 * @throws IOException any IO errors
55 */ 52 */
56 - public static void appendFileContents(File toAppend, File srcFile) 53 + static void appendFileContents(File toAppend, File srcFile)
57 throws IOException { 54 throws IOException {
58 updateFileHandle(srcFile, NEW_LINE + readAppendFile(toAppend.toString(), FOUR_SPACE_INDENTATION), false); 55 updateFileHandle(srcFile, NEW_LINE + readAppendFile(toAppend.toString(), FOUR_SPACE_INDENTATION), false);
59 } 56 }
...@@ -76,14 +73,21 @@ public final class FileSystemUtil { ...@@ -76,14 +73,21 @@ public final class FileSystemUtil {
76 String line = bufferReader.readLine(); 73 String line = bufferReader.readLine();
77 74
78 while (line != null) { 75 while (line != null) {
79 - if (line.equals(SPACE) || line.equals(EMPTY_STRING) || line.equals(EIGHT_SPACE_INDENTATION) 76 + switch (line) {
80 - || line.equals(MULTIPLE_NEW_LINE)) { 77 + case SPACE:
81 - stringBuilder.append(NEW_LINE); 78 + case EMPTY_STRING:
82 - } else if (line.equals(FOUR_SPACE_INDENTATION)) { 79 + case EIGHT_SPACE_INDENTATION:
83 - stringBuilder.append(EMPTY_STRING); 80 + case MULTIPLE_NEW_LINE:
84 - } else { 81 + stringBuilder.append(NEW_LINE);
85 - stringBuilder.append(spaces + line); 82 + break;
86 - stringBuilder.append(NEW_LINE); 83 + case FOUR_SPACE_INDENTATION:
84 + stringBuilder.append(EMPTY_STRING);
85 + break;
86 + default:
87 + String append = spaces + line;
88 + stringBuilder.append(append);
89 + stringBuilder.append(NEW_LINE);
90 + break;
87 } 91 }
88 line = bufferReader.readLine(); 92 line = bufferReader.readLine();
89 } 93 }
...@@ -100,10 +104,10 @@ public final class FileSystemUtil { ...@@ -100,10 +104,10 @@ public final class FileSystemUtil {
100 * @param inputFile input file 104 * @param inputFile input file
101 * @param contentTobeAdded content to be appended to the file 105 * @param contentTobeAdded content to be appended to the file
102 * @param isClose when close of file is called. 106 * @param isClose when close of file is called.
103 - * @throws IOException if the named file exists but is a directory rather than a regular file, 107 + * @throws IOException if the named file exists but is a directory rather than a regular file, does not exist but
104 - * does not exist but cannot be created, or cannot be opened for any other reason 108 + * cannot be created, or cannot be opened for any other reason
105 */ 109 */
106 - public static void updateFileHandle(File inputFile, String contentTobeAdded, boolean isClose) 110 + static void updateFileHandle(File inputFile, String contentTobeAdded, boolean isClose)
107 throws IOException { 111 throws IOException {
108 112
109 List<FileWriter> fileWriterStore = new ArrayList<>(); 113 List<FileWriter> fileWriterStore = new ArrayList<>();
...@@ -119,7 +123,6 @@ public final class FileSystemUtil { ...@@ -119,7 +123,6 @@ public final class FileSystemUtil {
119 for (FileWriter curWriter : fileWriterStore) { 123 for (FileWriter curWriter : fileWriterStore) {
120 curWriter.flush(); 124 curWriter.flush();
121 curWriter.close(); 125 curWriter.close();
122 - curWriter = null;
123 } 126 }
124 } 127 }
125 } 128 }
...@@ -137,7 +140,10 @@ public final class FileSystemUtil { ...@@ -137,7 +140,10 @@ public final class FileSystemUtil {
137 if (file != null) { 140 if (file != null) {
138 updateFileHandle(file, null, true); 141 updateFileHandle(file, null, true);
139 if (toBeDeleted) { 142 if (toBeDeleted) {
140 - file.delete(); 143 + boolean deleted = file.delete();
144 + if (!deleted) {
145 + throw new IOException("Failed to delete temporary file " + file.getName());
146 + }
141 } 147 }
142 } 148 }
143 } 149 }
......
...@@ -19,17 +19,12 @@ package org.onosproject.yangutils.utils.io.impl; ...@@ -19,17 +19,12 @@ package org.onosproject.yangutils.utils.io.impl;
19 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; 19 import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
20 20
21 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED; 21 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
22 -import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR;
23 -import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR_RETURN;
24 -import static org.onosproject.yangutils.utils.UtilConstants.MAX_RANGE;
25 -import static org.onosproject.yangutils.utils.UtilConstants.MIN_RANGE;
26 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
27 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 22 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
28 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC; 23 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC;
29 -import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_JAVA_DOC;
30 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC; 24 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC;
31 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_OBJECT; 25 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_OBJECT;
32 import static org.onosproject.yangutils.utils.UtilConstants.CLASS; 26 import static org.onosproject.yangutils.utils.UtilConstants.CLASS;
27 +import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
33 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 28 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
34 import static org.onosproject.yangutils.utils.UtilConstants.ENUM_ATTRIBUTE_JAVADOC; 29 import static org.onosproject.yangutils.utils.UtilConstants.ENUM_ATTRIBUTE_JAVADOC;
35 import static org.onosproject.yangutils.utils.UtilConstants.ENUM_CLASS_JAVADOC; 30 import static org.onosproject.yangutils.utils.UtilConstants.ENUM_CLASS_JAVADOC;
...@@ -38,15 +33,17 @@ import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_JAVA_ ...@@ -38,15 +33,17 @@ import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_JAVA_
38 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; 33 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
39 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME; 34 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME;
40 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME; 35 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME;
41 -import static org.onosproject.yangutils.utils.UtilConstants.IMPL;
42 import static org.onosproject.yangutils.utils.UtilConstants.IMPL_CLASS_JAVA_DOC; 36 import static org.onosproject.yangutils.utils.UtilConstants.IMPL_CLASS_JAVA_DOC;
43 import static org.onosproject.yangutils.utils.UtilConstants.INPUT; 37 import static org.onosproject.yangutils.utils.UtilConstants.INPUT;
44 import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE_JAVA_DOC; 38 import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE_JAVA_DOC;
39 +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_ADD_TO_LIST;
45 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_BUILD; 40 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_BUILD;
46 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_BUILD_RETURN; 41 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_BUILD_RETURN;
47 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_CONSTRUCTOR; 42 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_CONSTRUCTOR;
48 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_END_LINE; 43 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_END_LINE;
49 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FIRST_LINE; 44 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FIRST_LINE;
45 +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR;
46 +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR_RETURN;
50 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_GETTERS; 47 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_GETTERS;
51 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_MANAGER_SETTERS; 48 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_MANAGER_SETTERS;
52 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_OF; 49 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_OF;
...@@ -57,11 +54,14 @@ import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS; ...@@ -57,11 +54,14 @@ import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS;
57 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS_COMMON; 54 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS_COMMON;
58 import static org.onosproject.yangutils.utils.UtilConstants.LIST; 55 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
59 import static org.onosproject.yangutils.utils.UtilConstants.MAP; 56 import static org.onosproject.yangutils.utils.UtilConstants.MAP;
57 +import static org.onosproject.yangutils.utils.UtilConstants.MAX_RANGE;
58 +import static org.onosproject.yangutils.utils.UtilConstants.MIN_RANGE;
60 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 59 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
61 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE_ASTERISK; 60 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE_ASTERISK;
62 import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; 61 import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
63 import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING; 62 import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING;
64 import static org.onosproject.yangutils.utils.UtilConstants.OF; 63 import static org.onosproject.yangutils.utils.UtilConstants.OF;
64 +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_JAVA_DOC;
65 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC; 65 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC;
66 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC_OF_CHILD; 66 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC_OF_CHILD;
67 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 67 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
...@@ -71,6 +71,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.SPACE; ...@@ -71,6 +71,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
71 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; 71 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
72 import static org.onosproject.yangutils.utils.UtilConstants.VALUE; 72 import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
73 import static org.onosproject.yangutils.utils.UtilConstants.VOID; 73 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
74 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
74 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 75 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
75 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; 76 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
76 77
...@@ -92,7 +93,7 @@ public final class JavaDocGen { ...@@ -92,7 +93,7 @@ public final class JavaDocGen {
92 * @param name name of the YangNode 93 * @param name name of the YangNode
93 * @param isList is list attribute 94 * @param isList is list attribute
94 * @param pluginConfig plugin configurations 95 * @param pluginConfig plugin configurations
95 - * @return javadocs. 96 + * @return javaDocs.
96 */ 97 */
97 public static String getJavaDoc(JavaDocType type, String name, boolean isList, YangPluginConfig pluginConfig) { 98 public static String getJavaDoc(JavaDocType type, String name, boolean isList, YangPluginConfig pluginConfig) {
98 99
...@@ -167,6 +168,9 @@ public final class JavaDocGen { ...@@ -167,6 +168,9 @@ public final class JavaDocGen {
167 case EVENT_SUBJECT_CLASS: { 168 case EVENT_SUBJECT_CLASS: {
168 return generateForClass(name); 169 return generateForClass(name);
169 } 170 }
171 + case ADD_TO_LIST: {
172 + return generateForAddToList(name);
173 + }
170 default: { 174 default: {
171 return generateForConstructors(name); 175 return generateForConstructors(name);
172 } 176 }
...@@ -180,8 +184,8 @@ public final class JavaDocGen { ...@@ -180,8 +184,8 @@ public final class JavaDocGen {
180 * @return javaDocs 184 * @return javaDocs
181 */ 185 */
182 private static String generateForEnumAttr(String name) { 186 private static String generateForEnumAttr(String name) {
183 - return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + ENUM_ATTRIBUTE_JAVADOC 187 + return EIGHT_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + EIGHT_SPACE_INDENTATION + ENUM_ATTRIBUTE_JAVADOC
184 - + name + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; 188 + + name + PERIOD + NEW_LINE + EIGHT_SPACE_INDENTATION + JAVA_DOC_END_LINE;
185 } 189 }
186 190
187 /** 191 /**
...@@ -438,11 +442,11 @@ public final class JavaDocGen { ...@@ -438,11 +442,11 @@ public final class JavaDocGen {
438 /** 442 /**
439 * Generates javaDoc for the builder interface. 443 * Generates javaDoc for the builder interface.
440 * 444 *
441 - * @param builderforName builder for name 445 + * @param builderForName builder for name
442 * @return javaDocs 446 * @return javaDocs
443 */ 447 */
444 - private static String generateForBuilderInterface(String builderforName) { 448 + private static String generateForBuilderInterface(String builderForName) {
445 - return JAVA_DOC_FIRST_LINE + BUILDER_INTERFACE_JAVA_DOC + builderforName + PERIOD + NEW_LINE 449 + return JAVA_DOC_FIRST_LINE + BUILDER_INTERFACE_JAVA_DOC + builderForName + PERIOD + NEW_LINE
446 + JAVA_DOC_END_LINE; 450 + JAVA_DOC_END_LINE;
447 } 451 }
448 452
...@@ -480,7 +484,7 @@ public final class JavaDocGen { ...@@ -480,7 +484,7 @@ public final class JavaDocGen {
480 */ 484 */
481 private static String generateForConstructors(String className) { 485 private static String generateForConstructors(String className) {
482 return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR 486 return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR
483 - + className + IMPL + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK 487 + + className + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK
484 + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + BUILDER.toLowerCase() + OBJECT + SPACE + BUILDER_OBJECT 488 + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + BUILDER.toLowerCase() + OBJECT + SPACE + BUILDER_OBJECT
485 + className + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; 489 + className + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
486 } 490 }
...@@ -504,7 +508,7 @@ public final class JavaDocGen { ...@@ -504,7 +508,7 @@ public final class JavaDocGen {
504 * @param attribute attribute string 508 * @param attribute attribute string
505 * @return javaDocs for type constructor 509 * @return javaDocs for type constructor
506 */ 510 */
507 - public static String generateForTypeConstructor(String attribute) { 511 + private static String generateForTypeConstructor(String attribute) {
508 return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR 512 return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR
509 + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION 513 + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION
510 + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE 514 + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE
...@@ -557,6 +561,52 @@ public final class JavaDocGen { ...@@ -557,6 +561,52 @@ public final class JavaDocGen {
557 } 561 }
558 562
559 /** 563 /**
564 + * Generates javaDocs for type constructor.
565 + *
566 + * @param attribute attribute string
567 + * @return javaDocs for type constructor
568 + */
569 + public static String generateForGetMethodWithAttribute(String attribute) {
570 + return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_GETTERS
571 + + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION
572 + + JAVA_DOC_PARAM + attribute + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE
573 + + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE
574 + + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
575 + }
576 +
577 + /**
578 + * Returns javaDocs for add to list method.
579 + *
580 + * @param attribute attribute
581 + * @return javaDocs
582 + */
583 + private static String generateForAddToList(String attribute) {
584 + String javadoc = NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION
585 + + JAVA_DOC_ADD_TO_LIST + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK
586 + + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + VALUE + SPACE;
587 + javadoc = javadoc + VALUE + SPACE + OF + SPACE;
588 + javadoc = javadoc + attribute + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
589 + return javadoc;
590 + }
591 +
592 + /**
593 + * Generates for builder method.
594 + *
595 + * @param attribute attribute
596 + * @return javaDocs
597 + */
598 + public static String generateForBuilderMethod(String attribute) {
599 +
600 + String javadoc = FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION
601 + + JAVA_DOC_GETTERS + attribute + BUILDER + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION
602 + + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN;
603 + javadoc = javadoc + VALUE + SPACE + OF + SPACE;
604 + javadoc = javadoc + attribute + BUILDER + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
605 + return javadoc;
606 + }
607 +
608 +
609 + /**
560 * JavaDocs types. 610 * JavaDocs types.
561 */ 611 */
562 public enum JavaDocType { 612 public enum JavaDocType {
...@@ -679,6 +729,12 @@ public final class JavaDocGen { ...@@ -679,6 +729,12 @@ public final class JavaDocGen {
679 /** 729 /**
680 * For operation builder. 730 * For operation builder.
681 */ 731 */
682 - OPERATION_BUILDER_CLASS 732 + OPERATION_BUILDER_CLASS,
733 +
734 + /**
735 + * For add to list.
736 + */
737 + ADD_TO_LIST,
683 } 738 }
739 +
684 } 740 }
......
...@@ -27,8 +27,8 @@ import java.util.Stack; ...@@ -27,8 +27,8 @@ import java.util.Stack;
27 */ 27 */
28 public final class YangFileScanner { 28 public final class YangFileScanner {
29 29
30 - private static final String JAVA_FILE_EXTENTION = ".java"; 30 + private static final String JAVA_FILE_EXTENSION = ".java";
31 - private static final String YANG_FILE_EXTENTION = ".yang"; 31 + private static final String YANG_FILE_EXTENSION = ".yang";
32 32
33 /** 33 /**
34 * Creates an instance of YANG file scanner. 34 * Creates an instance of YANG file scanner.
...@@ -45,9 +45,8 @@ public final class YangFileScanner { ...@@ -45,9 +45,8 @@ public final class YangFileScanner {
45 * @throws IOException when files get deleted while performing the 45 * @throws IOException when files get deleted while performing the
46 * operations 46 * operations
47 */ 47 */
48 - public static List<String> getJavaFiles(String root) throws IOException { 48 + static List<String> getJavaFiles(String root) throws IOException {
49 - 49 + return getFiles(root, JAVA_FILE_EXTENSION);
50 - return getFiles(root, JAVA_FILE_EXTENTION);
51 } 50 }
52 51
53 /** 52 /**
...@@ -60,8 +59,7 @@ public final class YangFileScanner { ...@@ -60,8 +59,7 @@ public final class YangFileScanner {
60 * operations 59 * operations
61 */ 60 */
62 public static List<String> getYangFiles(String root) throws IOException { 61 public static List<String> getYangFiles(String root) throws IOException {
63 - 62 + return getFiles(root, YANG_FILE_EXTENSION);
64 - return getFiles(root, YANG_FILE_EXTENTION);
65 } 63 }
66 64
67 /** 65 /**
...@@ -73,22 +71,22 @@ public final class YangFileScanner { ...@@ -73,22 +71,22 @@ public final class YangFileScanner {
73 * @throws NullPointerException when no file is there 71 * @throws NullPointerException when no file is there
74 * @throws IOException when files get deleted while performing the operations 72 * @throws IOException when files get deleted while performing the operations
75 */ 73 */
76 - public static List<String> getFiles(String root, String extension) throws IOException { 74 + private static List<String> getFiles(String root, String extension) throws IOException {
77 75
78 List<String> store = new LinkedList<>(); 76 List<String> store = new LinkedList<>();
79 Stack<String> stack = new Stack<>(); 77 Stack<String> stack = new Stack<>();
80 stack.push(root); 78 stack.push(root);
81 File file; 79 File file;
82 - File[] filelist; 80 + File[] fileList;
83 try { 81 try {
84 while (!stack.empty()) { 82 while (!stack.empty()) {
85 root = stack.pop(); 83 root = stack.pop();
86 file = new File(root); 84 file = new File(root);
87 - filelist = file.listFiles(); 85 + fileList = file.listFiles();
88 - if ((filelist == null) || (filelist.length == 0)) { 86 + if ((fileList == null) || (fileList.length == 0)) {
89 continue; 87 continue;
90 } 88 }
91 - for (File current : filelist) { 89 + for (File current : fileList) {
92 if (current.isDirectory()) { 90 if (current.isDirectory()) {
93 stack.push(current.toString()); 91 stack.push(current.toString());
94 } else { 92 } else {
......
...@@ -62,6 +62,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.SPACE; ...@@ -62,6 +62,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
62 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; 62 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
63 import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE; 63 import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE;
64 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; 64 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX;
65 +import static org.onosproject.yangutils.utils.io.impl.CopyrightHeader.getCopyrightHeader;
65 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents; 66 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents;
66 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; 67 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle;
67 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO; 68 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO;
...@@ -87,10 +88,16 @@ public final class YangIoUtils { ...@@ -87,10 +88,16 @@ public final class YangIoUtils {
87 * 88 *
88 * @param path directory path 89 * @param path directory path
89 * @return directory structure 90 * @return directory structure
91 + * @throws IOException when fails to do IO operations
90 */ 92 */
91 - public static File createDirectories(String path) { 93 + public static File createDirectories(String path) throws IOException {
92 File generatedDir = new File(path); 94 File generatedDir = new File(path);
93 - generatedDir.mkdirs(); 95 + if (!generatedDir.exists()) {
96 + boolean isGenerated = generatedDir.mkdirs();
97 + if (!isGenerated) {
98 + throw new IOException("failed to generated directory " + path);
99 + }
100 + }
94 return generatedDir; 101 return generatedDir;
95 } 102 }
96 103
...@@ -113,22 +120,26 @@ public final class YangIoUtils { ...@@ -113,22 +120,26 @@ public final class YangIoUtils {
113 try { 120 try {
114 121
115 File packageInfo = new File(path + SLASH + "package-info.java"); 122 File packageInfo = new File(path + SLASH + "package-info.java");
116 - packageInfo.createNewFile(); 123 + if (!packageInfo.exists()) {
117 - 124 + boolean isGenerated = packageInfo.createNewFile();
125 + if (!isGenerated) {
126 + throw new IOException("failed to generated package-info " + path);
127 + }
128 + }
118 FileWriter fileWriter = new FileWriter(packageInfo); 129 FileWriter fileWriter = new FileWriter(packageInfo);
119 BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); 130 BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
120 131
121 - bufferedWriter.write(CopyrightHeader.getCopyrightHeader()); 132 + bufferedWriter.write(getCopyrightHeader());
122 bufferedWriter.write(getJavaDoc(PACKAGE_INFO, classInfo, isChildNode, pluginConfig)); 133 bufferedWriter.write(getJavaDoc(PACKAGE_INFO, classInfo, isChildNode, pluginConfig));
123 String pkg = PACKAGE + SPACE + pack + SEMI_COLAN; 134 String pkg = PACKAGE + SPACE + pack + SEMI_COLAN;
124 if (pkg.length() > LINE_SIZE) { 135 if (pkg.length() > LINE_SIZE) {
125 - pkg = whenDelimiterIsPersent(pkg, LINE_SIZE); 136 + pkg = whenDelimiterIsPresent(pkg, LINE_SIZE);
126 } 137 }
127 bufferedWriter.write(pkg); 138 bufferedWriter.write(pkg);
128 bufferedWriter.close(); 139 bufferedWriter.close();
129 fileWriter.close(); 140 fileWriter.close();
130 } catch (IOException e) { 141 } catch (IOException e) {
131 - throw new IOException("Exception occured while creating package info file."); 142 + throw new IOException("Exception occurred while creating package info file.");
132 } 143 }
133 } 144 }
134 145
...@@ -192,11 +203,11 @@ public final class YangIoUtils { ...@@ -192,11 +203,11 @@ public final class YangIoUtils {
192 while (!stack.empty()) { 203 while (!stack.empty()) {
193 root = stack.pop(); 204 root = stack.pop();
194 File file = new File(root); 205 File file = new File(root);
195 - File[] filelist = file.listFiles(); 206 + File[] fileList = file.listFiles();
196 - if (filelist == null || filelist.length == 0) { 207 + if (fileList == null || fileList.length == 0) {
197 continue; 208 continue;
198 } 209 }
199 - for (File current : filelist) { 210 + for (File current : fileList) {
200 if (current.isDirectory()) { 211 if (current.isDirectory()) {
201 stack.push(current.toString()); 212 stack.push(current.toString());
202 if (current.getName().endsWith("-Temp")) { 213 if (current.getName().endsWith("-Temp")) {
...@@ -215,12 +226,12 @@ public final class YangIoUtils { ...@@ -215,12 +226,12 @@ public final class YangIoUtils {
215 * Removes extra char from the string. 226 * Removes extra char from the string.
216 * 227 *
217 * @param valueString string to be trimmed 228 * @param valueString string to be trimmed
218 - * @param removalStirng extra chars 229 + * @param removalString extra chars
219 * @return new string 230 * @return new string
220 */ 231 */
221 - public static String trimAtLast(String valueString, String removalStirng) { 232 + public static String trimAtLast(String valueString, String removalString) {
222 StringBuilder stringBuilder = new StringBuilder(valueString); 233 StringBuilder stringBuilder = new StringBuilder(valueString);
223 - int index = valueString.lastIndexOf(removalStirng); 234 + int index = valueString.lastIndexOf(removalString);
224 if (index != -1) { 235 if (index != -1) {
225 stringBuilder.deleteCharAt(index); 236 stringBuilder.deleteCharAt(index);
226 } 237 }
...@@ -302,9 +313,9 @@ public final class YangIoUtils { ...@@ -302,9 +313,9 @@ public final class YangIoUtils {
302 */ 313 */
303 public static File validateLineLength(File dataFile) 314 public static File validateLineLength(File dataFile)
304 throws IOException { 315 throws IOException {
305 - File tempFile = dataFile;
306 FileReader fileReader = new FileReader(dataFile); 316 FileReader fileReader = new FileReader(dataFile);
307 BufferedReader bufferReader = new BufferedReader(fileReader); 317 BufferedReader bufferReader = new BufferedReader(fileReader);
318 + String append;
308 try { 319 try {
309 StringBuilder stringBuilder = new StringBuilder(); 320 StringBuilder stringBuilder = new StringBuilder();
310 String line = bufferReader.readLine(); 321 String line = bufferReader.readLine();
...@@ -312,20 +323,21 @@ public final class YangIoUtils { ...@@ -312,20 +323,21 @@ public final class YangIoUtils {
312 while (line != null) { 323 while (line != null) {
313 if (line.length() > LINE_SIZE) { 324 if (line.length() > LINE_SIZE) {
314 if (line.contains(PERIOD)) { 325 if (line.contains(PERIOD)) {
315 - line = whenDelimiterIsPersent(line, LINE_SIZE); 326 + line = whenDelimiterIsPresent(line, LINE_SIZE);
316 } else if (line.contains(SPACE)) { 327 } else if (line.contains(SPACE)) {
317 line = whenSpaceIsPresent(line, LINE_SIZE); 328 line = whenSpaceIsPresent(line, LINE_SIZE);
318 } 329 }
319 stringBuilder.append(line); 330 stringBuilder.append(line);
320 } else { 331 } else {
321 - stringBuilder.append(line + NEW_LINE); 332 + append = line + NEW_LINE;
333 + stringBuilder.append(append);
322 } 334 }
323 line = bufferReader.readLine(); 335 line = bufferReader.readLine();
324 } 336 }
325 - FileWriter writer = new FileWriter(tempFile); 337 + FileWriter writer = new FileWriter(dataFile);
326 writer.write(stringBuilder.toString()); 338 writer.write(stringBuilder.toString());
327 writer.close(); 339 writer.close();
328 - return tempFile; 340 + return dataFile;
329 } finally { 341 } finally {
330 fileReader.close(); 342 fileReader.close();
331 bufferReader.close(); 343 bufferReader.close();
...@@ -333,14 +345,15 @@ public final class YangIoUtils { ...@@ -333,14 +345,15 @@ public final class YangIoUtils {
333 } 345 }
334 346
335 /* When delimiters are present in the given line. */ 347 /* When delimiters are present in the given line. */
336 - private static String whenDelimiterIsPersent(String line, int lineSize) { 348 + private static String whenDelimiterIsPresent(String line, int lineSize) {
337 StringBuilder stringBuilder = new StringBuilder(); 349 StringBuilder stringBuilder = new StringBuilder();
338 - 350 + String append;
339 if (line.length() > lineSize) { 351 if (line.length() > lineSize) {
340 String[] strArray = line.split(Pattern.quote(PERIOD)); 352 String[] strArray = line.split(Pattern.quote(PERIOD));
341 stringBuilder = updateString(strArray, stringBuilder, PERIOD, lineSize); 353 stringBuilder = updateString(strArray, stringBuilder, PERIOD, lineSize);
342 } else { 354 } else {
343 - stringBuilder.append(line + NEW_LINE); 355 + append = line + NEW_LINE;
356 + stringBuilder.append(append);
344 } 357 }
345 String[] strArray = stringBuilder.toString().split(NEW_LINE); 358 String[] strArray = stringBuilder.toString().split(NEW_LINE);
346 StringBuilder tempBuilder = new StringBuilder(); 359 StringBuilder tempBuilder = new StringBuilder();
...@@ -353,7 +366,8 @@ public final class YangIoUtils { ...@@ -353,7 +366,8 @@ public final class YangIoUtils {
353 tempBuilder.append(whenSpaceIsPresent(str, SUB_LINE_SIZE)); 366 tempBuilder.append(whenSpaceIsPresent(str, SUB_LINE_SIZE));
354 } 367 }
355 } else { 368 } else {
356 - tempBuilder.append(str + NEW_LINE); 369 + append = str + NEW_LINE;
370 + tempBuilder.append(append);
357 } 371 }
358 } 372 }
359 return tempBuilder.toString(); 373 return tempBuilder.toString();
...@@ -363,11 +377,13 @@ public final class YangIoUtils { ...@@ -363,11 +377,13 @@ public final class YangIoUtils {
363 /* When spaces are present in the given line. */ 377 /* When spaces are present in the given line. */
364 private static String whenSpaceIsPresent(String line, int lineSize) { 378 private static String whenSpaceIsPresent(String line, int lineSize) {
365 StringBuilder stringBuilder = new StringBuilder(); 379 StringBuilder stringBuilder = new StringBuilder();
380 + String append;
366 if (line.length() > lineSize) { 381 if (line.length() > lineSize) {
367 String[] strArray = line.split(SPACE); 382 String[] strArray = line.split(SPACE);
368 stringBuilder = updateString(strArray, stringBuilder, SPACE, lineSize); 383 stringBuilder = updateString(strArray, stringBuilder, SPACE, lineSize);
369 } else { 384 } else {
370 - stringBuilder.append(line + NEW_LINE); 385 + append = line + NEW_LINE;
386 + stringBuilder.append(append);
371 } 387 }
372 388
373 String[] strArray = stringBuilder.toString().split(NEW_LINE); 389 String[] strArray = stringBuilder.toString().split(NEW_LINE);
...@@ -379,7 +395,8 @@ public final class YangIoUtils { ...@@ -379,7 +395,8 @@ public final class YangIoUtils {
379 tempBuilder = updateString(strArr, tempBuilder, SPACE, SUB_LINE_SIZE); 395 tempBuilder = updateString(strArr, tempBuilder, SPACE, SUB_LINE_SIZE);
380 } 396 }
381 } else { 397 } else {
382 - tempBuilder.append(str + NEW_LINE); 398 + append = str + NEW_LINE;
399 + tempBuilder.append(append);
383 } 400 }
384 } 401 }
385 return tempBuilder.toString(); 402 return tempBuilder.toString();
...@@ -390,28 +407,34 @@ public final class YangIoUtils { ...@@ -390,28 +407,34 @@ public final class YangIoUtils {
390 int lineSize) { 407 int lineSize) {
391 408
392 StringBuilder tempBuilder = new StringBuilder(); 409 StringBuilder tempBuilder = new StringBuilder();
410 + String append;
393 for (String str : strArray) { 411 for (String str : strArray) {
394 - tempBuilder.append(str + string); 412 + append = str + string;
413 + tempBuilder.append(append);
395 if (tempBuilder.length() > lineSize) { 414 if (tempBuilder.length() > lineSize) {
396 String tempString = stringBuilder.toString(); 415 String tempString = stringBuilder.toString();
397 stringBuilder.delete(ZERO, stringBuilder.length()); 416 stringBuilder.delete(ZERO, stringBuilder.length());
398 tempString = trimAtLast(tempString, string); 417 tempString = trimAtLast(tempString, string);
399 stringBuilder.append(tempString); 418 stringBuilder.append(tempString);
400 if (string.equals(PERIOD)) { 419 if (string.equals(PERIOD)) {
401 - stringBuilder.append(NEW_LINE + TWELVE_SPACE_INDENTATION + PERIOD + str + string); 420 + append = NEW_LINE + TWELVE_SPACE_INDENTATION + PERIOD + str + string;
421 + stringBuilder.append(append);
402 } else { 422 } else {
403 - stringBuilder.append(NEW_LINE + TWELVE_SPACE_INDENTATION + str + string); 423 + append = NEW_LINE + TWELVE_SPACE_INDENTATION + str + string;
424 + stringBuilder.append(append);
404 } 425 }
405 tempBuilder.delete(ZERO, tempBuilder.length()); 426 tempBuilder.delete(ZERO, tempBuilder.length());
406 tempBuilder.append(TWELVE_SPACE_INDENTATION); 427 tempBuilder.append(TWELVE_SPACE_INDENTATION);
407 } else { 428 } else {
408 - stringBuilder.append(str + string); 429 + append = str + string;
430 + stringBuilder.append(append);
409 } 431 }
410 } 432 }
411 String tempString = stringBuilder.toString(); 433 String tempString = stringBuilder.toString();
412 tempString = trimAtLast(tempString, string); 434 tempString = trimAtLast(tempString, string);
413 stringBuilder.delete(ZERO, stringBuilder.length()); 435 stringBuilder.delete(ZERO, stringBuilder.length());
414 - stringBuilder.append(tempString + NEW_LINE); 436 + append = tempString + NEW_LINE;
437 + stringBuilder.append(append);
415 return stringBuilder; 438 return stringBuilder;
416 } 439 }
417 440
...@@ -464,7 +487,7 @@ public final class YangIoUtils { ...@@ -464,7 +487,7 @@ public final class YangIoUtils {
464 * @param consecCapitalCaseRemover which requires the restriction of consecutive capital case 487 * @param consecCapitalCaseRemover which requires the restriction of consecutive capital case
465 * @return string without consecutive capital case 488 * @return string without consecutive capital case
466 */ 489 */
467 - public static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) { 490 + private static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) {
468 491
469 for (int k = 0; k < consecCapitalCaseRemover.length(); k++) { 492 for (int k = 0; k < consecCapitalCaseRemover.length(); k++) {
470 if (k + 1 < consecCapitalCaseRemover.length()) { 493 if (k + 1 < consecCapitalCaseRemover.length()) {
...@@ -487,7 +510,7 @@ public final class YangIoUtils { ...@@ -487,7 +510,7 @@ public final class YangIoUtils {
487 * @param conflictResolver object of YANG to java naming conflict util 510 * @param conflictResolver object of YANG to java naming conflict util
488 * @return prefixed camel case string 511 * @return prefixed camel case string
489 */ 512 */
490 - public static String addPrefix(String camelCasePrefix, YangToJavaNamingConflictUtil conflictResolver) { 513 + private static String addPrefix(String camelCasePrefix, YangToJavaNamingConflictUtil conflictResolver) {
491 514
492 String prefix = getPrefixForIdentifier(conflictResolver); 515 String prefix = getPrefixForIdentifier(conflictResolver);
493 if (camelCasePrefix.matches(REGEX_FOR_FIRST_DIGIT)) { 516 if (camelCasePrefix.matches(REGEX_FOR_FIRST_DIGIT)) {
...@@ -508,7 +531,7 @@ public final class YangIoUtils { ...@@ -508,7 +531,7 @@ public final class YangIoUtils {
508 * @param conflictResolver object of YANG to java naming conflict util 531 * @param conflictResolver object of YANG to java naming conflict util
509 * @return camel case rule checked string 532 * @return camel case rule checked string
510 */ 533 */
511 - public static String applyCamelCaseRule(String[] stringArray, YangToJavaNamingConflictUtil conflictResolver) { 534 + private static String applyCamelCaseRule(String[] stringArray, YangToJavaNamingConflictUtil conflictResolver) {
512 535
513 String ruleChecker = stringArray[0].toLowerCase(); 536 String ruleChecker = stringArray[0].toLowerCase();
514 int i; 537 int i;
...@@ -551,8 +574,8 @@ public final class YangIoUtils { ...@@ -551,8 +574,8 @@ public final class YangIoUtils {
551 * @param conflictResolver object of YANG to java naming conflict util 574 * @param conflictResolver object of YANG to java naming conflict util
552 * @return camel cased string 575 * @return camel cased string
553 */ 576 */
554 - public static String upperCaseConflictResolver(String[] stringArray, 577 + private static String upperCaseConflictResolver(String[] stringArray,
555 - YangToJavaNamingConflictUtil conflictResolver) { 578 + YangToJavaNamingConflictUtil conflictResolver) {
556 579
557 for (int l = 0; l < stringArray.length; l++) { 580 for (int l = 0; l < stringArray.length; l++) {
558 String[] upperCaseSplitArray = stringArray[l].split(REGEX_WITH_UPPERCASE); 581 String[] upperCaseSplitArray = stringArray[l].split(REGEX_WITH_UPPERCASE);
...@@ -579,7 +602,7 @@ public final class YangIoUtils { ...@@ -579,7 +602,7 @@ public final class YangIoUtils {
579 } 602 }
580 stringArray[l] = strBuilder.toString(); 603 stringArray[l] = strBuilder.toString();
581 } 604 }
582 - List<String> result = new ArrayList<String>(); 605 + List<String> result = new ArrayList<>();
583 for (String element : stringArray) { 606 for (String element : stringArray) {
584 String[] capitalCaseSplitArray = element.split(REGEX_WITH_UPPERCASE); 607 String[] capitalCaseSplitArray = element.split(REGEX_WITH_UPPERCASE);
585 for (String letter : capitalCaseSplitArray) { 608 for (String letter : capitalCaseSplitArray) {
...@@ -625,10 +648,8 @@ public final class YangIoUtils { ...@@ -625,10 +648,8 @@ public final class YangIoUtils {
625 yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_IDENTIFIER_SPECIAL_CHAR, COLAN); 648 yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_IDENTIFIER_SPECIAL_CHAR, COLAN);
626 String[] strArray = yangIdentifier.split(COLAN); 649 String[] strArray = yangIdentifier.split(COLAN);
627 if (strArray[0].isEmpty()) { 650 if (strArray[0].isEmpty()) {
628 - List<String> stringArrangement = new ArrayList<String>(); 651 + List<String> stringArrangement = new ArrayList<>();
629 - for (int i = 1; i < strArray.length; i++) { 652 + stringArrangement.addAll(Arrays.asList(strArray).subList(1, strArray.length));
630 - stringArrangement.add(strArray[i]);
631 - }
632 strArray = stringArrangement.toArray(new String[stringArrangement.size()]); 653 strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
633 } 654 }
634 return upperCaseConflictResolver(strArray, conflictResolver); 655 return upperCaseConflictResolver(strArray, conflictResolver);
...@@ -651,10 +672,8 @@ public final class YangIoUtils { ...@@ -651,10 +672,8 @@ public final class YangIoUtils {
651 String[] strArray = prefixForIdentifier.split(COLAN); 672 String[] strArray = prefixForIdentifier.split(COLAN);
652 try { 673 try {
653 if (strArray[0].isEmpty()) { 674 if (strArray[0].isEmpty()) {
654 - List<String> stringArrangement = new ArrayList<String>(); 675 + List<String> stringArrangement = new ArrayList<>();
655 - for (int i = 1; i < strArray.length; i++) { 676 + stringArrangement.addAll(Arrays.asList(strArray).subList(1, strArray.length));
656 - stringArrangement.add(strArray[i]);
657 - }
658 strArray = stringArrangement.toArray(new String[stringArrangement.size()]); 677 strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
659 } 678 }
660 prefixForIdentifier = strArray[0]; 679 prefixForIdentifier = strArray[0];
......
...@@ -54,7 +54,6 @@ public class IetfYangFileTest { ...@@ -54,7 +54,6 @@ public class IetfYangFileTest {
54 String userDir = System.getProperty("user.dir"); 54 String userDir = System.getProperty("user.dir");
55 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 55 YangPluginConfig yangPluginConfig = new YangPluginConfig();
56 yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/"); 56 yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/");
57 - yangPluginConfig.setManagerCodeGenDir("target/ietfyang/l3vpnservice/");
58 57
59 utilManager.translateToJava(yangPluginConfig); 58 utilManager.translateToJava(yangPluginConfig);
60 59
......
...@@ -20,9 +20,9 @@ import java.io.IOException; ...@@ -20,9 +20,9 @@ import java.io.IOException;
20 20
21 import org.apache.maven.plugin.MojoExecutionException; 21 import org.apache.maven.plugin.MojoExecutionException;
22 import org.junit.Test; 22 import org.junit.Test;
23 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
23 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
24 import org.onosproject.yangutils.utils.io.impl.YangFileScanner; 25 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
25 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
26 26
27 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; 27 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
28 28
...@@ -49,10 +49,8 @@ public class AugmentTranslatorTest { ...@@ -49,10 +49,8 @@ public class AugmentTranslatorTest {
49 49
50 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 50 YangPluginConfig yangPluginConfig = new YangPluginConfig();
51 yangPluginConfig.setCodeGenDir("target/augmentTranslator/"); 51 yangPluginConfig.setCodeGenDir("target/augmentTranslator/");
52 - yangPluginConfig.setManagerCodeGenDir("target/augmentTranslator/");
53 utilManager.translateToJava(yangPluginConfig); 52 utilManager.translateToJava(yangPluginConfig);
54 53
55 - deleteDirectory("target/augmentTranslator/"); 54 + deleteDirectory("target/augmentTranslator1/");
56 } 55 }
57 -
58 } 56 }
......
...@@ -44,7 +44,6 @@ public final class ChoiceCaseTranslatorTest { ...@@ -44,7 +44,6 @@ public final class ChoiceCaseTranslatorTest {
44 44
45 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 45 YangPluginConfig yangPluginConfig = new YangPluginConfig();
46 yangPluginConfig.setCodeGenDir("target/ChoiceCaseTestGenFile/"); 46 yangPluginConfig.setCodeGenDir("target/ChoiceCaseTestGenFile/");
47 - yangPluginConfig.setManagerCodeGenDir("target/ChoiceCaseTestGenFile/");
48 47
49 generateJavaCode(node, yangPluginConfig); 48 generateJavaCode(node, yangPluginConfig);
50 49
......
...@@ -45,7 +45,6 @@ public final class EnumTranslatorTest { ...@@ -45,7 +45,6 @@ public final class EnumTranslatorTest {
45 45
46 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 46 YangPluginConfig yangPluginConfig = new YangPluginConfig();
47 yangPluginConfig.setCodeGenDir("target/EnumTestGenFile/"); 47 yangPluginConfig.setCodeGenDir("target/EnumTestGenFile/");
48 - yangPluginConfig.setManagerCodeGenDir("target/EnumTestGenFile/");
49 48
50 generateJavaCode(node, yangPluginConfig); 49 generateJavaCode(node, yangPluginConfig);
51 50
......
...@@ -19,6 +19,7 @@ package org.onosproject.yangutils.plugin.manager; ...@@ -19,6 +19,7 @@ package org.onosproject.yangutils.plugin.manager;
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.Iterator; 20 import java.util.Iterator;
21 import java.util.ListIterator; 21 import java.util.ListIterator;
22 +
22 import org.apache.maven.plugin.MojoExecutionException; 23 import org.apache.maven.plugin.MojoExecutionException;
23 import org.junit.Rule; 24 import org.junit.Rule;
24 import org.junit.Test; 25 import org.junit.Test;
...@@ -32,7 +33,6 @@ import org.onosproject.yangutils.datamodel.YangNode; ...@@ -32,7 +33,6 @@ import org.onosproject.yangutils.datamodel.YangNode;
32 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; 33 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
33 import org.onosproject.yangutils.linker.impl.YangLinkerManager; 34 import org.onosproject.yangutils.linker.impl.YangLinkerManager;
34 import org.onosproject.yangutils.parser.exceptions.ParserException; 35 import org.onosproject.yangutils.parser.exceptions.ParserException;
35 -import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
36 import org.onosproject.yangutils.utils.io.impl.YangFileScanner; 36 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
37 37
38 import static org.hamcrest.MatcherAssert.assertThat; 38 import static org.hamcrest.MatcherAssert.assertThat;
...@@ -52,7 +52,6 @@ public class InterFileLeafrefLinkingTest { ...@@ -52,7 +52,6 @@ public class InterFileLeafrefLinkingTest {
52 52
53 private final YangUtilManager utilManager = new YangUtilManager(); 53 private final YangUtilManager utilManager = new YangUtilManager();
54 private final YangLinkerManager yangLinkerManager = new YangLinkerManager(); 54 private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
55 - private final YangUtilsParserManager manager = new YangUtilsParserManager();
56 55
57 /** 56 /**
58 * Checks inter file leafref linking. 57 * Checks inter file leafref linking.
......
...@@ -656,7 +656,6 @@ public class InterFileLinkingTest { ...@@ -656,7 +656,6 @@ public class InterFileLinkingTest {
656 656
657 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 657 YangPluginConfig yangPluginConfig = new YangPluginConfig();
658 yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/"); 658 yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/");
659 - yangPluginConfig.setManagerCodeGenDir("target/interfilewithusesreferringtype/");
660 659
661 utilManager.translateToJava(yangPluginConfig); 660 utilManager.translateToJava(yangPluginConfig);
662 661
...@@ -678,7 +677,6 @@ public class InterFileLinkingTest { ...@@ -678,7 +677,6 @@ public class InterFileLinkingTest {
678 677
679 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 678 YangPluginConfig yangPluginConfig = new YangPluginConfig();
680 yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); 679 yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
681 - yangPluginConfig.setManagerCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
682 680
683 utilManager.translateToJava(yangPluginConfig); 681 utilManager.translateToJava(yangPluginConfig);
684 682
...@@ -700,7 +698,6 @@ public class InterFileLinkingTest { ...@@ -700,7 +698,6 @@ public class InterFileLinkingTest {
700 698
701 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 699 YangPluginConfig yangPluginConfig = new YangPluginConfig();
702 yangPluginConfig.setCodeGenDir("target/interfileietf/"); 700 yangPluginConfig.setCodeGenDir("target/interfileietf/");
703 - yangPluginConfig.setManagerCodeGenDir("target/interfileietf/");
704 701
705 utilManager.translateToJava(yangPluginConfig); 702 utilManager.translateToJava(yangPluginConfig);
706 703
...@@ -722,7 +719,6 @@ public class InterFileLinkingTest { ...@@ -722,7 +719,6 @@ public class InterFileLinkingTest {
722 719
723 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 720 YangPluginConfig yangPluginConfig = new YangPluginConfig();
724 yangPluginConfig.setCodeGenDir("target/usesInContainer/"); 721 yangPluginConfig.setCodeGenDir("target/usesInContainer/");
725 - yangPluginConfig.setManagerCodeGenDir("target/usesInContainer/");
726 722
727 utilManager.translateToJava(yangPluginConfig); 723 utilManager.translateToJava(yangPluginConfig);
728 724
...@@ -744,7 +740,6 @@ public class InterFileLinkingTest { ...@@ -744,7 +740,6 @@ public class InterFileLinkingTest {
744 740
745 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 741 YangPluginConfig yangPluginConfig = new YangPluginConfig();
746 yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/"); 742 yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/");
747 - yangPluginConfig.setManagerCodeGenDir("target/groupingNodeSameAsModule/");
748 743
749 utilManager.translateToJava(yangPluginConfig); 744 utilManager.translateToJava(yangPluginConfig);
750 745
......
...@@ -41,11 +41,10 @@ import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig; ...@@ -41,11 +41,10 @@ import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
41 41
42 import static org.hamcrest.MatcherAssert.assertThat; 42 import static org.hamcrest.MatcherAssert.assertThat;
43 import static org.hamcrest.core.Is.is; 43 import static org.hamcrest.core.Is.is;
44 +import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
44 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED; 45 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
45 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING; 46 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING;
46 -import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; 47 +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.parseJarFile;
47 -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.deSerializeDataModel;
48 -import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.parseJarFile;
49 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.serializeDataModel; 48 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.serializeDataModel;
50 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 49 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
51 import static org.onosproject.yangutils.utils.UtilConstants.TEMP; 50 import static org.onosproject.yangutils.utils.UtilConstants.TEMP;
...@@ -189,7 +188,6 @@ public class InterJarLinkerTest { ...@@ -189,7 +188,6 @@ public class InterJarLinkerTest {
189 188
190 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 189 YangPluginConfig yangPluginConfig = new YangPluginConfig();
191 yangPluginConfig.setCodeGenDir(TARGET); 190 yangPluginConfig.setCodeGenDir(TARGET);
192 - yangPluginConfig.setManagerCodeGenDir(TARGET);
193 191
194 utilManager.translateToJava(yangPluginConfig); 192 utilManager.translateToJava(yangPluginConfig);
195 193
...@@ -206,7 +204,7 @@ public class InterJarLinkerTest { ...@@ -206,7 +204,7 @@ public class InterJarLinkerTest {
206 File folder = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_FOLDER); 204 File folder = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_FOLDER);
207 File file = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_MANAGER); 205 File file = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_MANAGER);
208 assertThat(true, is(folder.exists())); 206 assertThat(true, is(folder.exists()));
209 - assertThat(true, is(file.exists())); 207 + assertThat(false, is(file.exists()));
210 } 208 }
211 209
212 /** 210 /**
...@@ -304,7 +302,7 @@ public class InterJarLinkerTest { ...@@ -304,7 +302,7 @@ public class InterJarLinkerTest {
304 */ 302 */
305 private void addInterJarRootNodes(String jarFile) throws IOException { 303 private void addInterJarRootNodes(String jarFile) throws IOException {
306 try { 304 try {
307 - List<YangNode> interJarResolvedNodes = deSerializeDataModel(parseJarFile(jarFile, TARGET)); 305 + List<YangNode> interJarResolvedNodes = parseJarFile(jarFile, TARGET);
308 306
309 for (YangNode node : interJarResolvedNodes) { 307 for (YangNode node : interJarResolvedNodes) {
310 YangFileInfo dependentFileInfo = new YangFileInfo(); 308 YangFileInfo dependentFileInfo = new YangFileInfo();
...@@ -326,7 +324,6 @@ public class InterJarLinkerTest { ...@@ -326,7 +324,6 @@ public class InterJarLinkerTest {
326 324
327 File file = new File(TARGET + TARGET_RESOURCE_PATH); 325 File file = new File(TARGET + TARGET_RESOURCE_PATH);
328 File[] files = file.listFiles(); 326 File[] files = file.listFiles();
329 -
330 String[] source = new String[files.length]; 327 String[] source = new String[files.length];
331 328
332 for (int i = 0; i < files.length; i++) { 329 for (int i = 0; i < files.length; i++) {
......
1 -/*
2 - * Copyright 2016-present Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -package org.onosproject.yangutils.plugin.manager;
18 -
19 -import java.io.File;
20 -import java.io.IOException;
21 -
22 -import org.apache.maven.plugin.MojoExecutionException;
23 -import org.junit.Test;
24 -import org.onosproject.yangutils.parser.exceptions.ParserException;
25 -import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
26 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
27 -
28 -import static org.hamcrest.core.Is.is;
29 -import static org.junit.Assert.assertThat;
30 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
31 -
32 -/**
33 - * Unit test case to test code generation for root nodes.
34 - */
35 -public class ManagerCodeGeneratorTest {
36 -
37 - private final YangUtilManager utilManager = new YangUtilManager();
38 -
39 - /**
40 - * Checks manager translation should not result in any exception.
41 - *
42 - * @throws MojoExecutionException when fails to do mojo operations
43 - */
44 - @Test
45 - public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException {
46 -
47 - String searchDir = "src/test/resources/manager/singleChild";
48 - utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
49 - utilManager.parseYangFileInfoSet();
50 - utilManager.createYangNodeSet();
51 - utilManager.resolveDependenciesUsingLinker();
52 -
53 - YangPluginConfig yangPluginConfig = new YangPluginConfig();
54 - yangPluginConfig.setCodeGenDir("target/manager/");
55 - yangPluginConfig.setManagerCodeGenDir("target/manager/");
56 -
57 - utilManager.translateToJava(yangPluginConfig);
58 - String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java";
59 - String file2 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test6Manager.java";
60 - String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
61 - File manager = new File(file1);
62 - assertThat(false, is(manager.exists()));
63 -
64 - File manager2 = new File(file2);
65 - assertThat(false, is(manager2.exists()));
66 -
67 - File manager3 = new File(file3);
68 - assertThat(true, is(manager3.exists()));
69 -
70 - deleteDirectory("target/manager/");
71 - }
72 -
73 - /**
74 - * Checks manager translation in different package should not result in any exception.
75 - *
76 - * @throws MojoExecutionException when fails to do mojo operations
77 - */
78 - @Test
79 - public void processManagerInDifferentPackageTranslator() throws IOException, ParserException,
80 - MojoExecutionException {
81 -
82 - String searchDir = "src/test/resources/manager/singleChild";
83 - utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
84 - utilManager.parseYangFileInfoSet();
85 - utilManager.createYangNodeSet();
86 - utilManager.resolveDependenciesUsingLinker();
87 -
88 - YangPluginConfig yangPluginConfig = new YangPluginConfig();
89 - yangPluginConfig.setCodeGenDir("target/manager/");
90 - yangPluginConfig.setManagerCodeGenDir("target/manager/");
91 -
92 - utilManager.translateToJava(yangPluginConfig);
93 - String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
94 -
95 - File manager3 = new File(file3);
96 - assertThat(true, is(manager3.exists()));
97 -
98 - deleteDirectory("target/manager/");
99 - deleteDirectory("target/manager1/");
100 - }
101 -
102 - /**
103 - * Checks manager translation in different package should not result in any exception.
104 - *
105 - * @throws MojoExecutionException when fails to do mojo operations
106 - */
107 - @Test
108 - public void processManagerforMultiChildTranslator() throws IOException, ParserException,
109 - MojoExecutionException {
110 -
111 - String searchDir = "src/test/resources/manager/MultiChild";
112 - utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
113 - utilManager.parseYangFileInfoSet();
114 - utilManager.createYangNodeSet();
115 - utilManager.resolveDependenciesUsingLinker();
116 -
117 - YangPluginConfig yangPluginConfig = new YangPluginConfig();
118 - yangPluginConfig.setCodeGenDir("target/manager/");
119 - yangPluginConfig.setManagerCodeGenDir("target/manager/");
120 -
121 - utilManager.translateToJava(yangPluginConfig);
122 - String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java";
123 -
124 - File manager1 = new File(file1);
125 - assertThat(false, is(manager1.exists()));
126 -
127 - String file2 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test6Manager.java";
128 -
129 - File manager2 = new File(file2);
130 - assertThat(false, is(manager2.exists()));
131 -
132 - String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
133 -
134 - File manager3 = new File(file3);
135 - assertThat(false, is(manager3.exists()));
136 -
137 - String file4 = "target/manager/org/onosproject/yang/gen/v1/test8/test/rev20160704/Test8Manager.java";
138 -
139 - File manager4 = new File(file4);
140 - assertThat(true, is(manager4.exists()));
141 -
142 - deleteDirectory("target/manager/");
143 - deleteDirectory("target/manager/");
144 - }
145 -
146 - /**
147 - * Checks manager translation in different package should not result in any exception.
148 - *
149 - * @throws MojoExecutionException when fails to do mojo operations
150 - */
151 - @Test
152 - public void processManagerforMultiChildWithDifferentPackageTranslator() throws IOException, ParserException,
153 - MojoExecutionException {
154 -
155 - String searchDir = "src/test/resources/manager/MultiChild";
156 - utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
157 - utilManager.parseYangFileInfoSet();
158 - utilManager.createYangNodeSet();
159 - utilManager.resolveDependenciesUsingLinker();
160 -
161 - YangPluginConfig yangPluginConfig = new YangPluginConfig();
162 - yangPluginConfig.setCodeGenDir("target/manager/");
163 - yangPluginConfig.setManagerCodeGenDir("target/manager1/");
164 -
165 - utilManager.translateToJava(yangPluginConfig);
166 -
167 - String file1 = "target/manager1/org/onosproject/yang/gen/v1/test8/test/rev20160704/Test8Manager.java";
168 -
169 - File manager1 = new File(file1);
170 - assertThat(true, is(manager1.exists()));
171 -
172 -
173 - String file2 = "target/manager/org/onosproject/yang/gen/v1/test8/test/rev20160704/Test8Service.java";
174 -
175 - File service2 = new File(file2);
176 - assertThat(true, is(service2.exists()));
177 -
178 - deleteDirectory("target/manager/");
179 - deleteDirectory("target/manager1/");
180 - }
181 -}
...@@ -45,12 +45,10 @@ public final class NotificationTranslatorTest { ...@@ -45,12 +45,10 @@ public final class NotificationTranslatorTest {
45 45
46 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 46 YangPluginConfig yangPluginConfig = new YangPluginConfig();
47 yangPluginConfig.setCodeGenDir("target/NotificationTest/"); 47 yangPluginConfig.setCodeGenDir("target/NotificationTest/");
48 - yangPluginConfig.setManagerCodeGenDir("target/NotificationTest1/");
49 48
50 generateJavaCode(node, yangPluginConfig); 49 generateJavaCode(node, yangPluginConfig);
51 50
52 deleteDirectory("target/NotificationTest/"); 51 deleteDirectory("target/NotificationTest/");
53 - deleteDirectory("target/NotificationTest1/");
54 } 52 }
55 53
56 // TODO enhance the test cases, after having a framework of translator test. 54 // TODO enhance the test cases, after having a framework of translator test.
......
...@@ -45,7 +45,6 @@ public final class RpcTranslatorTest { ...@@ -45,7 +45,6 @@ public final class RpcTranslatorTest {
45 45
46 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 46 YangPluginConfig yangPluginConfig = new YangPluginConfig();
47 yangPluginConfig.setCodeGenDir("target/RpcTestGenFile/"); 47 yangPluginConfig.setCodeGenDir("target/RpcTestGenFile/");
48 - yangPluginConfig.setManagerCodeGenDir("target/RpcTestGenFile/");
49 48
50 generateJavaCode(node, yangPluginConfig); 49 generateJavaCode(node, yangPluginConfig);
51 50
......
...@@ -20,9 +20,9 @@ import java.io.IOException; ...@@ -20,9 +20,9 @@ import java.io.IOException;
20 20
21 import org.apache.maven.plugin.MojoExecutionException; 21 import org.apache.maven.plugin.MojoExecutionException;
22 import org.junit.Test; 22 import org.junit.Test;
23 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
23 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
24 import org.onosproject.yangutils.utils.io.impl.YangFileScanner; 25 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
25 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
26 26
27 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; 27 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
28 28
...@@ -49,7 +49,6 @@ public class TypeDefTranslatorTest { ...@@ -49,7 +49,6 @@ public class TypeDefTranslatorTest {
49 49
50 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 50 YangPluginConfig yangPluginConfig = new YangPluginConfig();
51 yangPluginConfig.setCodeGenDir("target/typedefTranslator/"); 51 yangPluginConfig.setCodeGenDir("target/typedefTranslator/");
52 - yangPluginConfig.setManagerCodeGenDir("target/typedefTranslator/");
53 utilManager.translateToJava(yangPluginConfig); 52 utilManager.translateToJava(yangPluginConfig);
54 53
55 deleteDirectory("target/typedefTranslator/"); 54 deleteDirectory("target/typedefTranslator/");
...@@ -63,7 +62,6 @@ public class TypeDefTranslatorTest { ...@@ -63,7 +62,6 @@ public class TypeDefTranslatorTest {
63 @Test 62 @Test
64 public void processTypeDefWithRestrictionsTranslator() throws IOException, ParserException, MojoExecutionException { 63 public void processTypeDefWithRestrictionsTranslator() throws IOException, ParserException, MojoExecutionException {
65 64
66 - /*FIXME: After typedef with leafref is fixed.
67 String searchDir = "src/test/resources/typedefTranslator/with"; 65 String searchDir = "src/test/resources/typedefTranslator/with";
68 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); 66 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
69 utilManager.parseYangFileInfoSet(); 67 utilManager.parseYangFileInfoSet();
...@@ -72,10 +70,10 @@ public class TypeDefTranslatorTest { ...@@ -72,10 +70,10 @@ public class TypeDefTranslatorTest {
72 70
73 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 71 YangPluginConfig yangPluginConfig = new YangPluginConfig();
74 yangPluginConfig.setCodeGenDir("target/typedefTranslator/"); 72 yangPluginConfig.setCodeGenDir("target/typedefTranslator/");
75 - yangPluginConfig.setManagerCodeGenDir("target/typedefTranslator/");
76 utilManager.translateToJava(yangPluginConfig); 73 utilManager.translateToJava(yangPluginConfig);
77 74
78 deleteDirectory("target/typedefTranslator/"); 75 deleteDirectory("target/typedefTranslator/");
79 - */ 76 +
80 } 77 }
78 +
81 } 79 }
......
...@@ -47,7 +47,6 @@ public final class UnionTranslatorTest { ...@@ -47,7 +47,6 @@ public final class UnionTranslatorTest {
47 47
48 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 48 YangPluginConfig yangPluginConfig = new YangPluginConfig();
49 yangPluginConfig.setCodeGenDir("target/UnionTestGenFile/"); 49 yangPluginConfig.setCodeGenDir("target/UnionTestGenFile/");
50 - yangPluginConfig.setManagerCodeGenDir("target/UnionTestGenFile/");
51 50
52 generateJavaCode(node, yangPluginConfig); 51 generateJavaCode(node, yangPluginConfig);
53 52
...@@ -71,7 +70,6 @@ public final class UnionTranslatorTest { ...@@ -71,7 +70,6 @@ public final class UnionTranslatorTest {
71 70
72 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 71 YangPluginConfig yangPluginConfig = new YangPluginConfig();
73 yangPluginConfig.setCodeGenDir("target/unionTranslator/"); 72 yangPluginConfig.setCodeGenDir("target/unionTranslator/");
74 - yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
75 73
76 utilManager.translateToJava(yangPluginConfig); 74 utilManager.translateToJava(yangPluginConfig);
77 deleteDirectory("target/unionTranslator/"); 75 deleteDirectory("target/unionTranslator/");
...@@ -94,7 +92,6 @@ public final class UnionTranslatorTest { ...@@ -94,7 +92,6 @@ public final class UnionTranslatorTest {
94 92
95 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 93 YangPluginConfig yangPluginConfig = new YangPluginConfig();
96 yangPluginConfig.setCodeGenDir("target/unionTranslator/"); 94 yangPluginConfig.setCodeGenDir("target/unionTranslator/");
97 - yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
98 95
99 utilManager.translateToJava(yangPluginConfig); 96 utilManager.translateToJava(yangPluginConfig);
100 deleteDirectory("target/unionTranslator/"); 97 deleteDirectory("target/unionTranslator/");
...@@ -117,7 +114,6 @@ public final class UnionTranslatorTest { ...@@ -117,7 +114,6 @@ public final class UnionTranslatorTest {
117 114
118 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 115 YangPluginConfig yangPluginConfig = new YangPluginConfig();
119 yangPluginConfig.setCodeGenDir("target/unionTranslator/"); 116 yangPluginConfig.setCodeGenDir("target/unionTranslator/");
120 - yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
121 117
122 utilManager.translateToJava(yangPluginConfig); 118 utilManager.translateToJava(yangPluginConfig);
123 deleteDirectory("target/unionTranslator/"); 119 deleteDirectory("target/unionTranslator/");
...@@ -140,7 +136,6 @@ public final class UnionTranslatorTest { ...@@ -140,7 +136,6 @@ public final class UnionTranslatorTest {
140 136
141 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 137 YangPluginConfig yangPluginConfig = new YangPluginConfig();
142 yangPluginConfig.setCodeGenDir("target/unionTranslator/"); 138 yangPluginConfig.setCodeGenDir("target/unionTranslator/");
143 - yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
144 139
145 utilManager.translateToJava(yangPluginConfig); 140 utilManager.translateToJava(yangPluginConfig);
146 deleteDirectory("target/unionTranslator/"); 141 deleteDirectory("target/unionTranslator/");
...@@ -163,7 +158,6 @@ public final class UnionTranslatorTest { ...@@ -163,7 +158,6 @@ public final class UnionTranslatorTest {
163 158
164 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 159 YangPluginConfig yangPluginConfig = new YangPluginConfig();
165 yangPluginConfig.setCodeGenDir("target/unionTranslator/"); 160 yangPluginConfig.setCodeGenDir("target/unionTranslator/");
166 - yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
167 161
168 utilManager.translateToJava(yangPluginConfig); 162 utilManager.translateToJava(yangPluginConfig);
169 deleteDirectory("target/unionTranslator/"); 163 deleteDirectory("target/unionTranslator/");
...@@ -187,7 +181,6 @@ public final class UnionTranslatorTest { ...@@ -187,7 +181,6 @@ public final class UnionTranslatorTest {
187 181
188 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 182 YangPluginConfig yangPluginConfig = new YangPluginConfig();
189 yangPluginConfig.setCodeGenDir("target/unionTranslator/"); 183 yangPluginConfig.setCodeGenDir("target/unionTranslator/");
190 - yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
191 184
192 utilManager.translateToJava(yangPluginConfig); 185 utilManager.translateToJava(yangPluginConfig);
193 deleteDirectory("target/unionTranslator/"); 186 deleteDirectory("target/unionTranslator/");
...@@ -211,7 +204,6 @@ public final class UnionTranslatorTest { ...@@ -211,7 +204,6 @@ public final class UnionTranslatorTest {
211 204
212 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 205 YangPluginConfig yangPluginConfig = new YangPluginConfig();
213 yangPluginConfig.setCodeGenDir("target/unionTranslator/"); 206 yangPluginConfig.setCodeGenDir("target/unionTranslator/");
214 - yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
215 207
216 utilManager.translateToJava(yangPluginConfig); 208 utilManager.translateToJava(yangPluginConfig);
217 deleteDirectory("target/unionTranslator/"); 209 deleteDirectory("target/unionTranslator/");
......
...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.plugin.manager; ...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.plugin.manager;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.List; 20 import java.util.List;
21 +
21 import org.apache.maven.plugin.MojoExecutionException; 22 import org.apache.maven.plugin.MojoExecutionException;
22 import org.junit.Test; 23 import org.junit.Test;
23 import org.onosproject.yangutils.datamodel.ResolvableType; 24 import org.onosproject.yangutils.datamodel.ResolvableType;
...@@ -28,22 +29,24 @@ import org.onosproject.yangutils.datamodel.YangResolutionInfo; ...@@ -28,22 +29,24 @@ import org.onosproject.yangutils.datamodel.YangResolutionInfo;
28 import org.onosproject.yangutils.linker.impl.YangLinkerManager; 29 import org.onosproject.yangutils.linker.impl.YangLinkerManager;
29 import org.onosproject.yangutils.linker.impl.YangXpathLinker; 30 import org.onosproject.yangutils.linker.impl.YangXpathLinker;
30 import org.onosproject.yangutils.utils.io.impl.YangFileScanner; 31 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
32 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
31 33
32 import static org.hamcrest.MatcherAssert.assertThat; 34 import static org.hamcrest.MatcherAssert.assertThat;
33 import static org.hamcrest.core.Is.is; 35 import static org.hamcrest.core.Is.is;
34 import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority; 36 import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority;
37 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
35 38
36 /** 39 /**
37 * Unit test cases for x-path linker. 40 * Unit test cases for x-path linker.
38 */ 41 */
39 public class YangXpathLinkerTest { 42 public class YangXpathLinkerTest {
40 43
41 - private YangUtilManager utilManager = new YangUtilManager();
42 - private YangXpathLinker linker = new YangXpathLinker();
43 - private YangLinkerManager linkerManager = new YangLinkerManager();
44 private static final String INTRA_FILE_PATH = "src/test/resources/xPathLinker/IntraFile/"; 44 private static final String INTRA_FILE_PATH = "src/test/resources/xPathLinker/IntraFile/";
45 private static final String INTER_FILE_PATH = "src/test/resources/xPathLinker/InterFile/"; 45 private static final String INTER_FILE_PATH = "src/test/resources/xPathLinker/InterFile/";
46 private static final String CASE_FILE_PATH = "src/test/resources/xPathLinker/Case/"; 46 private static final String CASE_FILE_PATH = "src/test/resources/xPathLinker/Case/";
47 + private YangUtilManager utilManager = new YangUtilManager();
48 + private YangXpathLinker linker = new YangXpathLinker();
49 + private YangLinkerManager linkerManager = new YangLinkerManager();
47 50
48 /** 51 /**
49 * Unit test case for intra file linking for single level container. 52 * Unit test case for intra file linking for single level container.
...@@ -622,6 +625,7 @@ public class YangXpathLinkerTest { ...@@ -622,6 +625,7 @@ public class YangXpathLinkerTest {
622 linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); 625 linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
623 linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); 626 linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
624 updateFilePriority(utilManager.getYangNodeSet()); 627 updateFilePriority(utilManager.getYangNodeSet());
628 +
625 linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); 629 linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
626 630
627 YangNode targetNode = null; 631 YangNode targetNode = null;
...@@ -649,30 +653,34 @@ public class YangXpathLinkerTest { ...@@ -649,30 +653,34 @@ public class YangXpathLinkerTest {
649 @Test 653 @Test
650 public void processInterFileLinkingInMultipleUses() throws IOException { 654 public void processInterFileLinkingInMultipleUses() throws IOException {
651 655
652 - /** FIXME: once order of linking is done. 656 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "uses/"));
653 - utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "uses/")); 657 + utilManager.parseYangFileInfoSet();
654 - utilManager.parseYangFileInfoSet(); 658 + utilManager.createYangNodeSet();
655 - utilManager.createYangNodeSet(); 659 + linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
656 - linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); 660 + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
657 - linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); 661 + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
658 - linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); 662 + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
659 - linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); 663 + updateFilePriority(utilManager.getYangNodeSet());
660 - linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); 664 + linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
661 - 665 +
662 - YangNode targetNode = null; 666 + YangNode targetNode = null;
663 - String targetNodeName = null; 667 + String targetNodeName = null;
664 - 668 +
665 - for (YangNode node : utilManager.getYangNodeSet()) { 669 + for (YangNode node : utilManager.getYangNodeSet()) {
666 - List<YangAugment> augments = linker.getListOfYangAugment(node); 670 + List<YangAugment> augments = linker.getListOfYangAugment(node);
667 - 671 +
668 - for (YangAugment augment : augments) { 672 + for (YangAugment augment : augments) {
669 - targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1) 673 + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1)
670 - .getNodeIdentifier().getName(); 674 + .getNodeIdentifier().getName();
671 - targetNode = augment.getAugmentedNode(); 675 + targetNode = augment.getAugmentedNode();
672 - } 676 + }
673 - } 677 + }
674 - 678 +
675 - assertThat(true, is(targetNode.getName().equals(targetNodeName))); 679 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
676 - */ 680 + yangPluginConfig.setCodeGenDir("target/xpath/");
681 + utilManager.translateToJava(yangPluginConfig);
682 + assertThat(true, is(targetNode.getName().equals(targetNodeName)));
683 +
684 + deleteDirectory("target/xpath/");
677 } 685 }
678 } 686 }
......
...@@ -26,7 +26,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -26,7 +26,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
26 import static org.hamcrest.core.Is.is; 26 import static org.hamcrest.core.Is.is;
27 import static org.hamcrest.core.IsNot.not; 27 import static org.hamcrest.core.IsNot.not;
28 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getImportText; 28 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getImportText;
29 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination; 29 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefinition;
30 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; 30 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
31 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 31 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
32 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; 32 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET;
...@@ -53,11 +53,11 @@ public class JavaCodeSnippetGenTest { ...@@ -53,11 +53,11 @@ public class JavaCodeSnippetGenTest {
53 /** 53 /**
54 * Unit test for private constructor. 54 * Unit test for private constructor.
55 * 55 *
56 - * @throws SecurityException if any security violation is observed 56 + * @throws SecurityException if any security violation is observed
57 - * @throws NoSuchMethodException if when the method is not found 57 + * @throws NoSuchMethodException if when the method is not found
58 - * @throws IllegalArgumentException if there is illegal argument found 58 + * @throws IllegalArgumentException if there is illegal argument found
59 - * @throws InstantiationException if instantiation is provoked for the private constructor 59 + * @throws InstantiationException if instantiation is provoked for the private constructor
60 - * @throws IllegalAccessException if instance is provoked or a method is provoked 60 + * @throws IllegalAccessException if instance is provoked or a method is provoked
61 * @throws InvocationTargetException when an exception occurs by the method or constructor 61 * @throws InvocationTargetException when an exception occurs by the method or constructor
62 */ 62 */
63 @Test 63 @Test
...@@ -65,7 +65,7 @@ public class JavaCodeSnippetGenTest { ...@@ -65,7 +65,7 @@ public class JavaCodeSnippetGenTest {
65 throws SecurityException, NoSuchMethodException, IllegalArgumentException, 65 throws SecurityException, NoSuchMethodException, IllegalArgumentException,
66 InstantiationException, IllegalAccessException, InvocationTargetException { 66 InstantiationException, IllegalAccessException, InvocationTargetException {
67 67
68 - Class<?>[] classesToConstruct = {JavaCodeSnippetGen.class }; 68 + Class<?>[] classesToConstruct = {JavaCodeSnippetGen.class};
69 for (Class<?> clazz : classesToConstruct) { 69 for (Class<?> clazz : classesToConstruct) {
70 Constructor<?> constructor = clazz.getDeclaredConstructor(); 70 Constructor<?> constructor = clazz.getDeclaredConstructor();
71 constructor.setAccessible(true); 71 constructor.setAccessible(true);
...@@ -102,26 +102,26 @@ public class JavaCodeSnippetGenTest { ...@@ -102,26 +102,26 @@ public class JavaCodeSnippetGenTest {
102 @Test 102 @Test
103 public void testForJavaAttributeInfo() { 103 public void testForJavaAttributeInfo() {
104 104
105 - String attributeWithoutTypePkg = getJavaAttributeDefination(null, STRING_DATA_TYPE, YANG_NAME, 105 + String attributeWithoutTypePkg = getJavaAttributeDefinition(null, STRING_DATA_TYPE, YANG_NAME,
106 - false, PRIVATE); 106 + false, PRIVATE);
107 assertThat(true, is(attributeWithoutTypePkg.equals( 107 assertThat(true, is(attributeWithoutTypePkg.equals(
108 PRIVATE + SPACE + STRING_DATA_TYPE + SPACE + YANG_NAME + SEMI_COLAN + NEW_LINE))); 108 PRIVATE + SPACE + STRING_DATA_TYPE + SPACE + YANG_NAME + SEMI_COLAN + NEW_LINE)));
109 109
110 - String attributeWithTypePkg = getJavaAttributeDefination(JAVA_LANG, STRING_DATA_TYPE, YANG_NAME, 110 + String attributeWithTypePkg = getJavaAttributeDefinition(JAVA_LANG, STRING_DATA_TYPE, YANG_NAME,
111 - false, PRIVATE); 111 + false, PRIVATE);
112 assertThat(true, is(attributeWithTypePkg.equals(PRIVATE + SPACE + JAVA_LANG + PERIOD 112 assertThat(true, is(attributeWithTypePkg.equals(PRIVATE + SPACE + JAVA_LANG + PERIOD
113 + STRING_DATA_TYPE + SPACE + YANG_NAME + SEMI_COLAN + NEW_LINE))); 113 + STRING_DATA_TYPE + SPACE + YANG_NAME + SEMI_COLAN + NEW_LINE)));
114 114
115 - String attributeWithListPkg = getJavaAttributeDefination(JAVA_LANG, STRING_DATA_TYPE, YANG_NAME, 115 + String attributeWithListPkg = getJavaAttributeDefinition(JAVA_LANG, STRING_DATA_TYPE, YANG_NAME,
116 - true, PRIVATE); 116 + true, PRIVATE);
117 - assertThat(true, is(attributeWithListPkg.equals( 117 + assertThat(true, is(attributeWithListPkg.contains(
118 PRIVATE + SPACE + LIST + DIAMOND_OPEN_BRACKET + JAVA_LANG + PERIOD + STRING_DATA_TYPE 118 PRIVATE + SPACE + LIST + DIAMOND_OPEN_BRACKET + JAVA_LANG + PERIOD + STRING_DATA_TYPE
119 - + DIAMOND_CLOSE_BRACKET + SPACE + YANG_NAME + SEMI_COLAN + NEW_LINE))); 119 + + DIAMOND_CLOSE_BRACKET + SPACE + YANG_NAME)));
120 120
121 - String attributeWithListWithoutPkg = getJavaAttributeDefination(null, STRING_DATA_TYPE, YANG_NAME, 121 + String attributeWithListWithoutPkg = getJavaAttributeDefinition(null, STRING_DATA_TYPE, YANG_NAME,
122 - true, PRIVATE); 122 + true, PRIVATE);
123 - assertThat(true, is(attributeWithListWithoutPkg.equals( 123 + assertThat(true, is(attributeWithListWithoutPkg.contains(
124 PRIVATE + SPACE + LIST + DIAMOND_OPEN_BRACKET + STRING_DATA_TYPE + DIAMOND_CLOSE_BRACKET + SPACE 124 PRIVATE + SPACE + LIST + DIAMOND_OPEN_BRACKET + STRING_DATA_TYPE + DIAMOND_CLOSE_BRACKET + SPACE
125 - + YANG_NAME + SEMI_COLAN + NEW_LINE))); 125 + + YANG_NAME)));
126 } 126 }
127 } 127 }
......
...@@ -21,9 +21,9 @@ import java.lang.reflect.InvocationTargetException; ...@@ -21,9 +21,9 @@ import java.lang.reflect.InvocationTargetException;
21 21
22 import org.junit.Test; 22 import org.junit.Test;
23 import org.onosproject.yangutils.datamodel.YangType; 23 import org.onosproject.yangutils.datamodel.YangType;
24 +import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
24 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; 25 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
25 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator; 26 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator;
26 -import org.onosproject.yangutils.datamodel.javadatamodel.YangPluginConfig;
27 27
28 import static org.hamcrest.core.Is.is; 28 import static org.hamcrest.core.Is.is;
29 import static org.hamcrest.core.IsNot.not; 29 import static org.hamcrest.core.IsNot.not;
...@@ -131,7 +131,7 @@ public final class MethodsGeneratorTest { ...@@ -131,7 +131,7 @@ public final class MethodsGeneratorTest {
131 */ 131 */
132 @Test 132 @Test
133 public void getBuildTest() { 133 public void getBuildTest() {
134 - String method = getBuild(CLASS_NAME); 134 + String method = getBuild(CLASS_NAME, false);
135 assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_NAME + SPACE + BUILD 135 assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_NAME + SPACE + BUILD
136 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION 136 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
137 + RETURN + SPACE + NEW + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS 137 + RETURN + SPACE + NEW + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS
...@@ -177,7 +177,7 @@ public final class MethodsGeneratorTest { ...@@ -177,7 +177,7 @@ public final class MethodsGeneratorTest {
177 @Test 177 @Test
178 public void getConstructorStartTest() { 178 public void getConstructorStartTest() {
179 YangPluginConfig pluginConfig = new YangPluginConfig(); 179 YangPluginConfig pluginConfig = new YangPluginConfig();
180 - String method = getConstructorStart(CLASS_NAME, pluginConfig); 180 + String method = getConstructorStart(CLASS_NAME, pluginConfig, false);
181 assertThat(true, is(method.contains(PUBLIC + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + CLASS_NAME 181 assertThat(true, is(method.contains(PUBLIC + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + CLASS_NAME
182 + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE 182 + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE
183 + OPEN_CURLY_BRACKET + NEW_LINE))); 183 + OPEN_CURLY_BRACKET + NEW_LINE)));
......
...@@ -47,7 +47,7 @@ public final class YangIoUtilsTest { ...@@ -47,7 +47,7 @@ public final class YangIoUtilsTest {
47 private static final String CHECK1 = "check1"; 47 private static final String CHECK1 = "check1";
48 private static final String PKG_INFO = "package-info.java"; 48 private static final String PKG_INFO = "package-info.java";
49 private static final String PATH = "src/main/yangmodel/"; 49 private static final String PATH = "src/main/yangmodel/";
50 - private static final String MSG = "Exception occured while creating package info file."; 50 + private static final String MSG = "Exception occurred while creating package info file.";
51 51
52 /** 52 /**
53 * Expected exceptions. 53 * Expected exceptions.
......
...@@ -31,6 +31,19 @@ module test { ...@@ -31,6 +31,19 @@ module test {
31 } 31 }
32 } 32 }
33 33
34 + choice choice1 {
35 + case case1 {
36 + leaf case-leaf {
37 + type int32;
38 + }
39 + container case-container3 {
40 + leaf leafs {
41 + type int64;
42 + }
43 + }
44 + }
45 + }
46 +
34 47
35 augment /cont3 { 48 augment /cont3 {
36 leaf leaf1 { 49 leaf leaf1 {
...@@ -39,10 +52,28 @@ module test { ...@@ -39,10 +52,28 @@ module test {
39 } 52 }
40 53
41 augment /cont1/cont2 { 54 augment /cont1/cont2 {
42 - leaf leaf2 { 55 + leaf-list leaf2 {
43 type int32; 56 type int32;
44 } 57 }
45 } 58 }
59 + augment /choice1 {
60 + leaf-list leaf2 {
61 + type int32;
62 + }
63 + leaf leaf1 {
64 + type int32;
65 + }
66 + container case-container {
67 + leaf leafs {
68 + type int64;
69 + }
70 + }
71 + container case-container2 {
72 + leaf leafs {
73 + type int64;
74 + }
75 + }
76 + }
46 77
47 augment /test1:cont1/test1:cont2 { 78 augment /test1:cont1/test1:cont2 {
48 leaf a { 79 leaf a {
...@@ -57,10 +88,25 @@ module test { ...@@ -57,10 +88,25 @@ module test {
57 } 88 }
58 89
59 augment /test1:cont1/test1:cont2/test1:cont1s/test1:cont1s/test2:aa { 90 augment /test1:cont1/test1:cont2/test1:cont1s/test1:cont1s/test2:aa {
60 - leaf a { 91 + leaf name {
92 + type string;
93 + }
94 + leaf surname {
95 + type string;
96 + }
97 + leaf-list aleaflist {
61 type int32; 98 type int32;
62 } 99 }
63 - container aa { 100 + container cont1 {
101 + }
102 + list alist {
103 + key "name";
104 + leaf name {
105 + type string;
106 + }
107 + leaf-list surname {
108 + type string;
109 + }
64 } 110 }
65 } 111 }
66 112
......
...@@ -2,9 +2,7 @@ module test { ...@@ -2,9 +2,7 @@ module test {
2 namespace "xpath:intra:single"; 2 namespace "xpath:intra:single";
3 prefix test ; 3 prefix test ;
4 4
5 - include test1;
6 include test2; 5 include test2;
7 - include test4;
8 6
9 organization ""; 7 organization "";
10 contact ""; 8 contact "";
...@@ -21,11 +19,5 @@ module test { ...@@ -21,11 +19,5 @@ module test {
21 type int32; 19 type int32;
22 } 20 }
23 } 21 }
24 -
25 - augment /group1/cont3/cont4/cont8 {
26 - leaf a {
27 - type int32;
28 - }
29 - }
30 } 22 }
31 23
......
...@@ -4,8 +4,6 @@ submodule test1 { ...@@ -4,8 +4,6 @@ submodule test1 {
4 prefix test; 4 prefix test;
5 } 5 }
6 6
7 - include test4;
8 -
9 organization ""; 7 organization "";
10 contact ""; 8 contact "";
11 9
...@@ -35,13 +33,5 @@ submodule test1 { ...@@ -35,13 +33,5 @@ submodule test1 {
35 } 33 }
36 } 34 }
37 35
38 - augment /group1/cont3/cont4 {
39 - container cont8 {
40 - leaf leaf8 {
41 - type int32;
42 - }
43 - }
44 - }
45 -
46 } 36 }
47 37
......
...@@ -3,8 +3,8 @@ submodule test2{ ...@@ -3,8 +3,8 @@ submodule test2{
3 prefix test; 3 prefix test;
4 } 4 }
5 5
6 + include test3;
6 include test1; 7 include test1;
7 - include test4;
8 8
9 organization ""; 9 organization "";
10 contact ""; 10 contact "";
...@@ -52,5 +52,13 @@ submodule test2{ ...@@ -52,5 +52,13 @@ submodule test2{
52 52
53 } 53 }
54 } 54 }
55 +
56 + augment /group1/cont3/cont4 {
57 + container cont8 {
58 + leaf leaf8 {
59 + type int32;
60 + }
61 + }
62 + }
55 } 63 }
56 64
......
1 -submodule test4 { 1 +submodule test3 {
2 2
3 belongs-to test { 3 belongs-to test {
4 prefix test; 4 prefix test;
5 } 5 }
6 - 6 +
7 - include test2;
8 organization ""; 7 organization "";
9 contact ""; 8 contact "";
10 9
...@@ -27,11 +26,5 @@ submodule test4 { ...@@ -27,11 +26,5 @@ submodule test4 {
27 } 26 }
28 } 27 }
29 } 28 }
30 -
31 - augment /ethernet/cont11 {
32 - leaf leaf11 {
33 - type int32;
34 - }
35 - }
36 29
37 } 30 }
......