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
715 additions
and
883 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 | } | ... | ... |
utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
... | @@ -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 | /** | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -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. | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -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 | /** | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
... | @@ -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 | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
... | @@ -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(); | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -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 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -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 { | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -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. | ... | ... |
utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/RpcTranslatorTest.java
... | @@ -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 | } | ... | ... |
-
Please register or login to post a comment