Committed by
Patrick Liu
[ONOS-4839] update file priority for translator and OP param file impl defect fix
Change-Id: Ieaef43f915996ed0a34dfa17c338ab612716b2bc
Showing
44 changed files
with
1620 additions
and
1390 deletions
... | @@ -32,6 +32,11 @@ public class YangAtomicPath implements Serializable { | ... | @@ -32,6 +32,11 @@ public class YangAtomicPath implements Serializable { |
32 | private List<YangPathPredicate> pathPredicatesList; | 32 | private List<YangPathPredicate> pathPredicatesList; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | + * Resolved node for the absolute path. | ||
36 | + */ | ||
37 | + private YangNode resolvedNode; | ||
38 | + | ||
39 | + /** | ||
35 | * Returns the node identifier. | 40 | * Returns the node identifier. |
36 | * | 41 | * |
37 | * @return the node identifier | 42 | * @return the node identifier |
... | @@ -75,4 +80,23 @@ public class YangAtomicPath implements Serializable { | ... | @@ -75,4 +80,23 @@ public class YangAtomicPath implements Serializable { |
75 | public void addLeavesPredicate(YangPathPredicate predicatesExp) { | 80 | public void addLeavesPredicate(YangPathPredicate predicatesExp) { |
76 | getPathPredicatesList().add(predicatesExp); | 81 | getPathPredicatesList().add(predicatesExp); |
77 | } | 82 | } |
83 | + | ||
84 | + | ||
85 | + /** | ||
86 | + * Returns resolved node. | ||
87 | + * | ||
88 | + * @return resolved node | ||
89 | + */ | ||
90 | + public YangNode getResolvedNode() { | ||
91 | + return resolvedNode; | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Sets resolved node. | ||
96 | + * | ||
97 | + * @param resolvedNode resolved node | ||
98 | + */ | ||
99 | + public void setResolvedNode(YangNode resolvedNode) { | ||
100 | + this.resolvedNode = resolvedNode; | ||
101 | + } | ||
78 | } | 102 | } | ... | ... |
... | @@ -15,10 +15,8 @@ | ... | @@ -15,10 +15,8 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.datamodel; | 16 | package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | -import java.util.HashMap; | ||
19 | import java.util.LinkedList; | 18 | import java.util.LinkedList; |
20 | import java.util.List; | 19 | import java.util.List; |
21 | -import java.util.Map; | ||
22 | 20 | ||
23 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
24 | import org.onosproject.yangutils.datamodel.utils.Parsable; | 22 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
... | @@ -130,11 +128,6 @@ public class YangAugment | ... | @@ -130,11 +128,6 @@ public class YangAugment |
130 | private YangNode augmentedNode; | 128 | private YangNode augmentedNode; |
131 | 129 | ||
132 | /** | 130 | /** |
133 | - * All resolved nodes in given xPath. | ||
134 | - */ | ||
135 | - private Map<YangAtomicPath, YangNode> resolveNodeInPath; | ||
136 | - | ||
137 | - /** | ||
138 | * Status of resolution. If completely resolved enum value is "RESOLVED", if not enum value is "UNRESOLVED", in case | 131 | * Status of resolution. If completely resolved enum value is "RESOLVED", if not enum value is "UNRESOLVED", in case |
139 | * reference of grouping/typedef is added to uses/type but it's not resolved value of enum should be | 132 | * reference of grouping/typedef is added to uses/type but it's not resolved value of enum should be |
140 | * "INTRA_FILE_RESOLVED". | 133 | * "INTRA_FILE_RESOLVED". |
... | @@ -156,7 +149,6 @@ public class YangAugment | ... | @@ -156,7 +149,6 @@ public class YangAugment |
156 | */ | 149 | */ |
157 | public YangAugment() { | 150 | public YangAugment() { |
158 | super(YangNodeType.AUGMENT_NODE); | 151 | super(YangNodeType.AUGMENT_NODE); |
159 | - resolveNodeInPath = new HashMap<>(); | ||
160 | resolvableStatus = ResolvableStatus.UNRESOLVED; | 152 | resolvableStatus = ResolvableStatus.UNRESOLVED; |
161 | } | 153 | } |
162 | 154 | ||
... | @@ -447,21 +439,4 @@ public class YangAugment | ... | @@ -447,21 +439,4 @@ public class YangAugment |
447 | return null; | 439 | return null; |
448 | } | 440 | } |
449 | 441 | ||
450 | - /** | ||
451 | - * Returns all resolved node in path. | ||
452 | - * | ||
453 | - * @return all resolved node in path | ||
454 | - */ | ||
455 | - public Map<YangAtomicPath, YangNode> getResolveNodeInPath() { | ||
456 | - return resolveNodeInPath; | ||
457 | - } | ||
458 | - | ||
459 | - /** | ||
460 | - * Sets all resolved node in path. | ||
461 | - * | ||
462 | - * @param resolveNodeInPath all resolved node in path | ||
463 | - */ | ||
464 | - public void setResolveNodeInPath(Map<YangAtomicPath, YangNode> resolveNodeInPath) { | ||
465 | - this.resolveNodeInPath = resolveNodeInPath; | ||
466 | - } | ||
467 | } | 442 | } | ... | ... |
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 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +/** | ||
19 | + * Abstraction of an entity which represent operation parameter info for augmentable node. | ||
20 | + */ | ||
21 | +public interface YangAugmentedOpParamInfo extends YangAugmentedInfo { | ||
22 | + | ||
23 | + /** | ||
24 | + * Returns class object of base class. | ||
25 | + * | ||
26 | + * @return class object of base class | ||
27 | + */ | ||
28 | + Class<?> getBaseClass(); | ||
29 | + | ||
30 | + /** | ||
31 | + * Returns if augmented info's contents matches. | ||
32 | + * | ||
33 | + * @param augmentedInfo augmented info | ||
34 | + * @return true or false | ||
35 | + */ | ||
36 | + boolean isFilterContentMatch(Object augmentedInfo); | ||
37 | +} |
... | @@ -79,7 +79,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -79,7 +79,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
79 | */ | 79 | */ |
80 | public class YangGrouping | 80 | public class YangGrouping |
81 | extends YangNode | 81 | extends YangNode |
82 | - implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector { | 82 | + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangTranslatorOperatorNode { |
83 | 83 | ||
84 | private static final long serialVersionUID = 806201607L; | 84 | private static final long serialVersionUID = 806201607L; |
85 | 85 | ... | ... |
... | @@ -64,6 +64,11 @@ public abstract class YangNode | ... | @@ -64,6 +64,11 @@ public abstract class YangNode |
64 | private int priority; | 64 | private int priority; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | + * Flag if the node is for translation. | ||
68 | + */ | ||
69 | + private boolean isToTranslate = true; | ||
70 | + | ||
71 | + /** | ||
67 | * Returns the priority of the node. | 72 | * Returns the priority of the node. |
68 | * | 73 | * |
69 | * @return priority of the node | 74 | * @return priority of the node |
... | @@ -268,6 +273,7 @@ public abstract class YangNode | ... | @@ -268,6 +273,7 @@ public abstract class YangNode |
268 | /** | 273 | /** |
269 | * Clones the current node contents and create a new node. | 274 | * Clones the current node contents and create a new node. |
270 | * | 275 | * |
276 | + * @param yangUses YANG uses | ||
271 | * @return cloned node | 277 | * @return cloned node |
272 | * @throws CloneNotSupportedException clone is not supported by the referred | 278 | * @throws CloneNotSupportedException clone is not supported by the referred |
273 | * node | 279 | * node |
... | @@ -297,6 +303,7 @@ public abstract class YangNode | ... | @@ -297,6 +303,7 @@ public abstract class YangNode |
297 | * | 303 | * |
298 | * @param srcRootNode source node for sub tree cloning | 304 | * @param srcRootNode source node for sub tree cloning |
299 | * @param dstRootNode destination node where the sub tree needs to be cloned | 305 | * @param dstRootNode destination node where the sub tree needs to be cloned |
306 | + * @param yangUses YANG uses | ||
300 | * @throws DataModelException data model error | 307 | * @throws DataModelException data model error |
301 | */ | 308 | */ |
302 | public static void cloneSubTree(YangNode srcRootNode, YangNode dstRootNode, YangUses yangUses) | 309 | public static void cloneSubTree(YangNode srcRootNode, YangNode dstRootNode, YangUses yangUses) |
... | @@ -411,6 +418,24 @@ public abstract class YangNode | ... | @@ -411,6 +418,24 @@ public abstract class YangNode |
411 | } | 418 | } |
412 | 419 | ||
413 | /** | 420 | /** |
421 | + * /** Returns true if translation required. | ||
422 | + * | ||
423 | + * @return true if translation required | ||
424 | + */ | ||
425 | + public boolean isToTranslate() { | ||
426 | + return isToTranslate; | ||
427 | + } | ||
428 | + | ||
429 | + /** | ||
430 | + * Sest true if translation required. | ||
431 | + * | ||
432 | + * @param toTranslate true if translation required. | ||
433 | + */ | ||
434 | + public void setToTranslate(boolean toTranslate) { | ||
435 | + isToTranslate = toTranslate; | ||
436 | + } | ||
437 | + | ||
438 | + /** | ||
414 | * Adds a new next sibling. | 439 | * Adds a new next sibling. |
415 | * | 440 | * |
416 | * @param newSibling new sibling to be added | 441 | * @param newSibling new sibling to be added | ... | ... |
1 | + | ||
2 | +/* | ||
3 | + * Copyright 2016-present Open Networking Laboratory | ||
4 | + * | ||
5 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | + * you may not use this file except in compliance with the License. | ||
7 | + * You may obtain a copy of the License at | ||
8 | + * | ||
9 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | + * | ||
11 | + * Unless required by applicable law or agreed to in writing, software | ||
12 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | + * See the License for the specific language governing permissions and | ||
15 | + * limitations under the License. | ||
16 | + */ | ||
17 | + | ||
18 | +package org.onosproject.yangutils.datamodel; | ||
19 | + | ||
20 | +/** | ||
21 | + * Abstraction of an entity which provides info about whether to translate module/submodule in manager and service | ||
22 | + * classes. | ||
23 | + */ | ||
24 | +public interface YangTranslatorOperatorNode { | ||
25 | +} |
... | @@ -57,7 +57,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -57,7 +57,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
57 | /** | 57 | /** |
58 | * Represents data model node to maintain information defined in YANG typedef. | 58 | * Represents data model node to maintain information defined in YANG typedef. |
59 | */ | 59 | */ |
60 | -public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, YangTypeHolder, CollisionDetector { | 60 | +public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, YangTypeHolder, CollisionDetector, |
61 | + YangTranslatorOperatorNode { | ||
61 | 62 | ||
62 | private static final long serialVersionUID = 806201615L; | 63 | private static final long serialVersionUID = 806201615L; |
63 | 64 | ... | ... |
... | @@ -370,6 +370,7 @@ public final class DataModelUtils { | ... | @@ -370,6 +370,7 @@ public final class DataModelUtils { |
370 | * | 370 | * |
371 | * @param clonedLeaf cloned leaf in uses from grouping | 371 | * @param clonedLeaf cloned leaf in uses from grouping |
372 | * @param leafParentHolder holder of the leaf from uses | 372 | * @param leafParentHolder holder of the leaf from uses |
373 | + * @param yangUses YANG uses | ||
373 | * @return entity of leafref which has to be resolved | 374 | * @return entity of leafref which has to be resolved |
374 | * @throws DataModelException data model error | 375 | * @throws DataModelException data model error |
375 | */ | 376 | */ | ... | ... |
... | @@ -19,7 +19,7 @@ package org.onosproject.yangutils.linker.impl; | ... | @@ -19,7 +19,7 @@ package org.onosproject.yangutils.linker.impl; |
19 | /** | 19 | /** |
20 | * Enum for prefix resolver type when augment has come in path. | 20 | * Enum for prefix resolver type when augment has come in path. |
21 | */ | 21 | */ |
22 | -public enum PrefixResolverType { | 22 | +enum PrefixResolverType { |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * When prefix changes from inter file to intra file. | 25 | * When prefix changes from inter file to intra file. |
... | @@ -37,12 +37,12 @@ public enum PrefixResolverType { | ... | @@ -37,12 +37,12 @@ public enum PrefixResolverType { |
37 | INTER_TO_INTER, | 37 | INTER_TO_INTER, |
38 | 38 | ||
39 | /** | 39 | /** |
40 | - * When no prefix change occurres. | 40 | + * When no prefix change occurs. |
41 | */ | 41 | */ |
42 | NO_PREFIX_CHANGE_FOR_INTRA, | 42 | NO_PREFIX_CHANGE_FOR_INTRA, |
43 | 43 | ||
44 | /** | 44 | /** |
45 | - * When no prefix change occurres. | 45 | + * When no prefix change occurs. |
46 | */ | 46 | */ |
47 | NO_PREFIX_CHANGE_FOR_INTER | 47 | NO_PREFIX_CHANGE_FOR_INTER |
48 | } | 48 | } | ... | ... |
... | @@ -18,13 +18,11 @@ package org.onosproject.yangutils.linker.impl; | ... | @@ -18,13 +18,11 @@ package org.onosproject.yangutils.linker.impl; |
18 | 18 | ||
19 | import java.util.Collections; | 19 | import java.util.Collections; |
20 | import java.util.HashSet; | 20 | import java.util.HashSet; |
21 | -import java.util.Iterator; | ||
22 | import java.util.LinkedList; | 21 | import java.util.LinkedList; |
23 | import java.util.List; | 22 | import java.util.List; |
24 | import java.util.Set; | 23 | import java.util.Set; |
24 | + | ||
25 | import org.onosproject.yangutils.datamodel.ResolvableType; | 25 | import org.onosproject.yangutils.datamodel.ResolvableType; |
26 | -import org.onosproject.yangutils.datamodel.YangImport; | ||
27 | -import org.onosproject.yangutils.datamodel.YangInclude; | ||
28 | import org.onosproject.yangutils.datamodel.YangNode; | 26 | import org.onosproject.yangutils.datamodel.YangNode; |
29 | import org.onosproject.yangutils.datamodel.YangReferenceResolver; | 27 | import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
30 | import org.onosproject.yangutils.datamodel.YangSubModule; | 28 | import org.onosproject.yangutils.datamodel.YangSubModule; |
... | @@ -32,6 +30,7 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ... | @@ -32,6 +30,7 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
32 | import org.onosproject.yangutils.linker.YangLinker; | 30 | import org.onosproject.yangutils.linker.YangLinker; |
33 | import org.onosproject.yangutils.linker.exceptions.LinkerException; | 31 | import org.onosproject.yangutils.linker.exceptions.LinkerException; |
34 | 32 | ||
33 | +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority; | ||
35 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 34 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
36 | 35 | ||
37 | /** | 36 | /** |
... | @@ -191,52 +190,4 @@ public class YangLinkerManager | ... | @@ -191,52 +190,4 @@ public class YangLinkerManager |
191 | } | 190 | } |
192 | } | 191 | } |
193 | 192 | ||
194 | - /** | ||
195 | - * Updates the priority for all the input files. | ||
196 | - * | ||
197 | - * @param yangNodeSet set of YANG files info | ||
198 | - */ | ||
199 | - public void updateFilePriority(Set<YangNode> yangNodeSet) { | ||
200 | - for (YangNode yangNode : yangNodeSet) { | ||
201 | - updateFilePriorityOfNode(yangNode); | ||
202 | - } | ||
203 | - } | ||
204 | - | ||
205 | - /** | ||
206 | - * Updates priority of the node. | ||
207 | - * | ||
208 | - * @param yangNode YANG node information | ||
209 | - */ | ||
210 | - public void updateFilePriorityOfNode(YangNode yangNode) { | ||
211 | - int curNodePriority = yangNode.getPriority(); | ||
212 | - if (yangNode instanceof YangReferenceResolver) { | ||
213 | - List<YangImport> yangImportList = ((YangReferenceResolver) yangNode).getImportList(); | ||
214 | - if (yangImportList != null && !yangImportList.isEmpty()) { | ||
215 | - Iterator<YangImport> importInfoIterator = yangImportList.iterator(); | ||
216 | - // Run through the imported list to update priority. | ||
217 | - while (importInfoIterator.hasNext()) { | ||
218 | - YangImport yangImport = importInfoIterator.next(); | ||
219 | - YangNode importedNode = yangImport.getImportedNode(); | ||
220 | - if (curNodePriority >= importedNode.getPriority()) { | ||
221 | - importedNode.setPriority(curNodePriority + 1); | ||
222 | - updateFilePriorityOfNode(importedNode); | ||
223 | - } | ||
224 | - } | ||
225 | - } | ||
226 | - | ||
227 | - List<YangInclude> yangIncludeList = ((YangReferenceResolver) yangNode).getIncludeList(); | ||
228 | - if (yangIncludeList != null && !yangIncludeList.isEmpty()) { | ||
229 | - Iterator<YangInclude> includeInfoIterator = yangIncludeList.iterator(); | ||
230 | - // Run through the imported list to update priority. | ||
231 | - while (includeInfoIterator.hasNext()) { | ||
232 | - YangInclude yangInclude = includeInfoIterator.next(); | ||
233 | - YangNode includedNode = yangInclude.getIncludedNode(); | ||
234 | - if (curNodePriority >= includedNode.getPriority()) { | ||
235 | - includedNode.setPriority(curNodePriority + 1); | ||
236 | - updateFilePriorityOfNode(includedNode); | ||
237 | - } | ||
238 | - } | ||
239 | - } | ||
240 | - } | ||
241 | - } | ||
242 | } | 193 | } | ... | ... |
... | @@ -16,24 +16,29 @@ | ... | @@ -16,24 +16,29 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.linker.impl; | 17 | package org.onosproject.yangutils.linker.impl; |
18 | 18 | ||
19 | +import java.util.ArrayList; | ||
20 | +import java.util.Iterator; | ||
21 | +import java.util.List; | ||
22 | +import java.util.Set; | ||
23 | +import java.util.regex.Pattern; | ||
24 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangAugment; | 25 | import org.onosproject.yangutils.datamodel.YangAugment; |
20 | import org.onosproject.yangutils.datamodel.YangAugmentableNode; | 26 | import org.onosproject.yangutils.datamodel.YangAugmentableNode; |
21 | import org.onosproject.yangutils.datamodel.YangAugmentedInfo; | 27 | import org.onosproject.yangutils.datamodel.YangAugmentedInfo; |
22 | import org.onosproject.yangutils.datamodel.YangCase; | 28 | import org.onosproject.yangutils.datamodel.YangCase; |
23 | import org.onosproject.yangutils.datamodel.YangChoice; | 29 | import org.onosproject.yangutils.datamodel.YangChoice; |
30 | +import org.onosproject.yangutils.datamodel.YangImport; | ||
31 | +import org.onosproject.yangutils.datamodel.YangInclude; | ||
24 | import org.onosproject.yangutils.datamodel.YangLeaf; | 32 | import org.onosproject.yangutils.datamodel.YangLeaf; |
25 | import org.onosproject.yangutils.datamodel.YangLeafList; | 33 | import org.onosproject.yangutils.datamodel.YangLeafList; |
26 | import org.onosproject.yangutils.datamodel.YangLeafRef; | 34 | import org.onosproject.yangutils.datamodel.YangLeafRef; |
27 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 35 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
28 | import org.onosproject.yangutils.datamodel.YangNode; | 36 | import org.onosproject.yangutils.datamodel.YangNode; |
29 | import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | 37 | import org.onosproject.yangutils.datamodel.YangNodeIdentifier; |
38 | +import org.onosproject.yangutils.datamodel.YangReferenceResolver; | ||
30 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; | 39 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
31 | import org.onosproject.yangutils.linker.exceptions.LinkerException; | 40 | import org.onosproject.yangutils.linker.exceptions.LinkerException; |
32 | 41 | ||
33 | -import java.util.ArrayList; | ||
34 | -import java.util.List; | ||
35 | -import java.util.regex.Pattern; | ||
36 | - | ||
37 | import static org.onosproject.yangutils.utils.UtilConstants.COLON; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.COLON; |
38 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
39 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING; |
... | @@ -43,13 +48,13 @@ import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING; | ... | @@ -43,13 +48,13 @@ import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING; |
43 | */ | 48 | */ |
44 | public final class YangLinkerUtils { | 49 | public final class YangLinkerUtils { |
45 | 50 | ||
46 | - private YangLinkerUtils() { | ||
47 | - } | ||
48 | - | ||
49 | private static final int IDENTIFIER_LENGTH = 64; | 51 | private static final int IDENTIFIER_LENGTH = 64; |
50 | private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_.-]*"); | 52 | private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_.-]*"); |
51 | private static final String XML = "xml"; | 53 | private static final String XML = "xml"; |
52 | 54 | ||
55 | + private YangLinkerUtils() { | ||
56 | + } | ||
57 | + | ||
53 | /** | 58 | /** |
54 | * Detects collision between target nodes leaf/leaf-list or child node with augmented leaf/leaf-list or child node. | 59 | * Detects collision between target nodes leaf/leaf-list or child node with augmented leaf/leaf-list or child node. |
55 | * | 60 | * |
... | @@ -59,61 +64,75 @@ public final class YangLinkerUtils { | ... | @@ -59,61 +64,75 @@ public final class YangLinkerUtils { |
59 | private static void detectCollision(YangNode targetNode, YangAugment augment) { | 64 | private static void detectCollision(YangNode targetNode, YangAugment augment) { |
60 | YangNode targetNodesChild = targetNode.getChild(); | 65 | YangNode targetNodesChild = targetNode.getChild(); |
61 | YangNode augmentsChild = augment.getChild(); | 66 | YangNode augmentsChild = augment.getChild(); |
62 | - YangLeavesHolder augmentsLeavesHolder = augment; | 67 | + YangNode parent = targetNode; |
68 | + if (targetNode instanceof YangAugment) { | ||
69 | + parent = targetNode.getParent(); | ||
70 | + } else { | ||
71 | + while (parent.getParent() != null) { | ||
72 | + parent = parent.getParent(); | ||
73 | + } | ||
74 | + } | ||
63 | if (targetNode instanceof YangChoice) { | 75 | if (targetNode instanceof YangChoice) { |
64 | - if (augmentsLeavesHolder.getListOfLeaf() != null | 76 | + // no need to check here. |
65 | - || augmentsLeavesHolder.getListOfLeafList() != null) { | 77 | + } else { |
66 | - throw new LinkerException("target node " + targetNode.getName() | 78 | + detectCollisionInLeaveHolders(targetNode, augment); |
67 | - + "is a instance of choice. it can " + | 79 | + while (augmentsChild != null) { |
68 | - "only be augmented with leaf using a case node."); | 80 | + detectCollisionInChildNodes(targetNodesChild, augmentsChild, targetNode.getName(), parent.getName()); |
81 | + augmentsChild = augmentsChild.getNextSibling(); | ||
69 | } | 82 | } |
83 | + } | ||
84 | + } | ||
85 | + | ||
86 | + /*Detects collision between leaves/leaflists*/ | ||
87 | + private static void detectCollisionInLeaveHolders(YangNode targetNode, YangAugment augment) { | ||
88 | + YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode; | ||
89 | + YangNode parent = targetNode; | ||
90 | + if (targetNode instanceof YangAugment) { | ||
91 | + parent = targetNode.getParent(); | ||
70 | } else { | 92 | } else { |
71 | - YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode; | 93 | + while (parent.getParent() != null) { |
72 | - | 94 | + parent = parent.getParent(); |
73 | - YangNode parent = targetNode; | ||
74 | - if (targetNode instanceof YangAugment) { | ||
75 | - parent = targetNode.getParent(); | ||
76 | - } else { | ||
77 | - while (parent.getParent() != null) { | ||
78 | - parent = parent.getParent(); | ||
79 | - } | ||
80 | } | 95 | } |
81 | - if (augmentsLeavesHolder.getListOfLeaf() != null && augmentsLeavesHolder.getListOfLeaf().size() != 0 | 96 | + } |
82 | - && targetNodesLeavesHolder.getListOfLeaf() != null) { | 97 | + if (augment.getListOfLeaf() != null && augment.getListOfLeaf().size() != 0 |
83 | - for (YangLeaf leaf : augmentsLeavesHolder.getListOfLeaf()) { | 98 | + && targetNodesLeavesHolder.getListOfLeaf() != null) { |
84 | - for (YangLeaf targetLeaf : targetNodesLeavesHolder.getListOfLeaf()) { | 99 | + for (YangLeaf leaf : augment.getListOfLeaf()) { |
85 | - if (targetLeaf.getName().equals(leaf.getName())) { | 100 | + for (YangLeaf targetLeaf : targetNodesLeavesHolder.getListOfLeaf()) { |
86 | - throw new LinkerException("target node " + targetNode.getName() | 101 | + if (targetLeaf.getName().equals(leaf.getName())) { |
87 | - + " contains augmented leaf " + leaf.getName() + " in module " | 102 | + throw new LinkerException("target node " + targetNode.getName() |
88 | - + parent.getName()); | 103 | + + " contains augmented leaf " + leaf.getName() + " in module " |
89 | - } | 104 | + + parent.getName()); |
90 | } | 105 | } |
91 | } | 106 | } |
92 | - } else if (augmentsLeavesHolder.getListOfLeafList() != null | 107 | + } |
93 | - && augmentsLeavesHolder.getListOfLeafList().size() != 0 | 108 | + } else if (augment.getListOfLeafList() != null |
94 | - && targetNodesLeavesHolder.getListOfLeafList() != null) { | 109 | + && augment.getListOfLeafList().size() != 0 |
95 | - for (YangLeafList leafList : augmentsLeavesHolder.getListOfLeafList()) { | 110 | + && augment.getListOfLeafList() != null) { |
96 | - for (YangLeafList targetLeafList : targetNodesLeavesHolder.getListOfLeafList()) { | 111 | + for (YangLeafList leafList : augment.getListOfLeafList()) { |
97 | - if (targetLeafList.getName().equals(leafList.getName())) { | 112 | + for (YangLeafList targetLeafList : targetNodesLeavesHolder.getListOfLeafList()) { |
98 | - throw new LinkerException("target node " + targetNode.getName() | 113 | + if (targetLeafList.getName().equals(leafList.getName())) { |
99 | - + " contains augmented leaf-list" + leafList.getName() + " in module " | 114 | + throw new LinkerException("target node " + targetNode.getName() |
100 | - + parent.getName()); | 115 | + + " contains augmented leaf-list" + leafList.getName() + " in module " |
101 | - } | 116 | + + parent.getName()); |
102 | } | 117 | } |
103 | } | 118 | } |
104 | - } else { | 119 | + } |
105 | - while (augmentsChild != null) { | 120 | + } |
106 | - while (targetNodesChild != null) { | 121 | + } |
107 | - if (targetNodesChild.getName().equals(augmentsChild.getName())) { | 122 | + |
108 | - throw new LinkerException("target node " + targetNode.getName() | 123 | + /*Detects collision for child nodes.*/ |
109 | - + " contains augmented child node" + augmentsChild.getName() + " in module " | 124 | + private static void detectCollisionInChildNodes(YangNode targetNodesChild, YangNode augmentsChild, String |
110 | - + parent.getName()); | 125 | + targetName, String parentName) { |
111 | - } | 126 | + while (augmentsChild != null) { |
112 | - targetNodesChild = targetNodesChild.getNextSibling(); | 127 | + while (targetNodesChild != null) { |
113 | - } | 128 | + if (targetNodesChild.getName().equals(augmentsChild.getName())) { |
114 | - augmentsChild = augmentsChild.getNextSibling(); | 129 | + throw new LinkerException("target node " + targetName |
130 | + + " contains augmented child node" + augmentsChild.getName() + " in module " | ||
131 | + + parentName); | ||
115 | } | 132 | } |
133 | + targetNodesChild = targetNodesChild.getNextSibling(); | ||
116 | } | 134 | } |
135 | + augmentsChild = augmentsChild.getNextSibling(); | ||
117 | } | 136 | } |
118 | } | 137 | } |
119 | 138 | ||
... | @@ -124,7 +143,7 @@ public final class YangLinkerUtils { | ... | @@ -124,7 +143,7 @@ public final class YangLinkerUtils { |
124 | * @param targetNode target node | 143 | * @param targetNode target node |
125 | * @param augment augment node | 144 | * @param augment augment node |
126 | */ | 145 | */ |
127 | - public static void detectCollisionForAugmentedNode(YangNode targetNode, YangAugment augment) { | 146 | + static void detectCollisionForAugmentedNode(YangNode targetNode, YangAugment augment) { |
128 | // Detect collision for target node and augment node. | 147 | // Detect collision for target node and augment node. |
129 | detectCollision(targetNode, augment); | 148 | detectCollision(targetNode, augment); |
130 | List<YangAugmentedInfo> yangAugmentedInfo = ((YangAugmentableNode) targetNode).getAugmentedInfoList(); | 149 | List<YangAugmentedInfo> yangAugmentedInfo = ((YangAugmentableNode) targetNode).getAugmentedInfoList(); |
... | @@ -228,4 +247,49 @@ public final class YangLinkerUtils { | ... | @@ -228,4 +247,49 @@ public final class YangLinkerUtils { |
228 | return identifier; | 247 | return identifier; |
229 | } | 248 | } |
230 | } | 249 | } |
250 | + | ||
251 | + /** | ||
252 | + * Updates the priority for all the input files. | ||
253 | + * | ||
254 | + * @param yangNodeSet set of YANG files info | ||
255 | + */ | ||
256 | + public static void updateFilePriority(Set<YangNode> yangNodeSet) { | ||
257 | + for (YangNode yangNode : yangNodeSet) { | ||
258 | + updateFilePriorityOfNode(yangNode); | ||
259 | + } | ||
260 | + } | ||
261 | + | ||
262 | + /** | ||
263 | + * Updates priority of the node. | ||
264 | + * | ||
265 | + * @param yangNode YANG node information | ||
266 | + */ | ||
267 | + public static void updateFilePriorityOfNode(YangNode yangNode) { | ||
268 | + int curNodePriority = yangNode.getPriority(); | ||
269 | + if (yangNode instanceof YangReferenceResolver) { | ||
270 | + List<YangImport> yangImportList = ((YangReferenceResolver) yangNode).getImportList(); | ||
271 | + Iterator<YangImport> importInfoIterator = yangImportList.iterator(); | ||
272 | + // Run through the imported list to update priority. | ||
273 | + while (importInfoIterator.hasNext()) { | ||
274 | + YangImport yangImport = importInfoIterator.next(); | ||
275 | + YangNode importedNode = yangImport.getImportedNode(); | ||
276 | + if (curNodePriority >= importedNode.getPriority()) { | ||
277 | + importedNode.setPriority(curNodePriority + 1); | ||
278 | + updateFilePriorityOfNode(importedNode); | ||
279 | + } | ||
280 | + } | ||
281 | + | ||
282 | + List<YangInclude> yangIncludeList = ((YangReferenceResolver) yangNode).getIncludeList(); | ||
283 | + Iterator<YangInclude> includeInfoIterator = yangIncludeList.iterator(); | ||
284 | + // Run through the imported list to update priority. | ||
285 | + while (includeInfoIterator.hasNext()) { | ||
286 | + YangInclude yangInclude = includeInfoIterator.next(); | ||
287 | + YangNode includedNode = yangInclude.getIncludedNode(); | ||
288 | + if (curNodePriority >= includedNode.getPriority()) { | ||
289 | + includedNode.setPriority(curNodePriority + 1); | ||
290 | + updateFilePriorityOfNode(includedNode); | ||
291 | + } | ||
292 | + } | ||
293 | + } | ||
294 | + } | ||
231 | } | 295 | } | ... | ... |
... | @@ -1209,7 +1209,6 @@ public class YangResolutionInfoImpl<T> | ... | @@ -1209,7 +1209,6 @@ public class YangResolutionInfoImpl<T> |
1209 | detectCollisionForAugmentedNode(targetNode, augment); | 1209 | detectCollisionForAugmentedNode(targetNode, augment); |
1210 | ((YangAugmentableNode) targetNode).addAugmentation(augment); | 1210 | ((YangAugmentableNode) targetNode).addAugmentation(augment); |
1211 | augment.setAugmentedNode(targetNode); | 1211 | augment.setAugmentedNode(targetNode); |
1212 | - augment.setResolveNodeInPath(xPathLinker.getResolvedNodes()); | ||
1213 | Resolvable resolvable = (Resolvable) entityToResolve; | 1212 | Resolvable resolvable = (Resolvable) entityToResolve; |
1214 | resolvable.setResolvableStatus(RESOLVED); | 1213 | resolvable.setResolvableStatus(RESOLVED); |
1215 | } else { | 1214 | } else { | ... | ... |
... | @@ -16,6 +16,12 @@ | ... | @@ -16,6 +16,12 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.linker.impl; | 17 | package org.onosproject.yangutils.linker.impl; |
18 | 18 | ||
19 | +import java.util.ArrayList; | ||
20 | +import java.util.HashMap; | ||
21 | +import java.util.Iterator; | ||
22 | +import java.util.List; | ||
23 | +import java.util.Map; | ||
24 | +import java.util.Stack; | ||
19 | import org.onosproject.yangutils.datamodel.YangAtomicPath; | 25 | import org.onosproject.yangutils.datamodel.YangAtomicPath; |
20 | import org.onosproject.yangutils.datamodel.YangAugment; | 26 | import org.onosproject.yangutils.datamodel.YangAugment; |
21 | import org.onosproject.yangutils.datamodel.YangCase; | 27 | import org.onosproject.yangutils.datamodel.YangCase; |
... | @@ -37,13 +43,6 @@ import org.onosproject.yangutils.datamodel.YangTypeDef; | ... | @@ -37,13 +43,6 @@ import org.onosproject.yangutils.datamodel.YangTypeDef; |
37 | import org.onosproject.yangutils.datamodel.YangUses; | 43 | import org.onosproject.yangutils.datamodel.YangUses; |
38 | import org.onosproject.yangutils.linker.exceptions.LinkerException; | 44 | import org.onosproject.yangutils.linker.exceptions.LinkerException; |
39 | 45 | ||
40 | -import java.util.ArrayList; | ||
41 | -import java.util.HashMap; | ||
42 | -import java.util.Iterator; | ||
43 | -import java.util.List; | ||
44 | -import java.util.Map; | ||
45 | -import java.util.Stack; | ||
46 | - | ||
47 | import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTER; | 46 | import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTER; |
48 | import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTRA; | 47 | import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTRA; |
49 | import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTRA_TO_INTER; | 48 | import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTRA_TO_INTER; |
... | @@ -63,14 +62,12 @@ public class YangXpathLinker<T> { | ... | @@ -63,14 +62,12 @@ public class YangXpathLinker<T> { |
63 | private YangNode rootNode; | 62 | private YangNode rootNode; |
64 | private Map<YangAtomicPath, PrefixResolverType> prefixResolverTypes; | 63 | private Map<YangAtomicPath, PrefixResolverType> prefixResolverTypes; |
65 | private String curPrefix; | 64 | private String curPrefix; |
66 | - private Map<YangAtomicPath, YangNode> resolvedNodes; | ||
67 | 65 | ||
68 | /** | 66 | /** |
69 | * Creates an instance of x-path linker. | 67 | * Creates an instance of x-path linker. |
70 | */ | 68 | */ |
71 | public YangXpathLinker() { | 69 | public YangXpathLinker() { |
72 | absPaths = new ArrayList<>(); | 70 | absPaths = new ArrayList<>(); |
73 | - setResolvedNodes(new HashMap<>()); | ||
74 | } | 71 | } |
75 | 72 | ||
76 | /** | 73 | /** |
... | @@ -156,31 +153,13 @@ public class YangXpathLinker<T> { | ... | @@ -156,31 +153,13 @@ public class YangXpathLinker<T> { |
156 | } | 153 | } |
157 | 154 | ||
158 | /** | 155 | /** |
159 | - * Returns resolved nodes. | ||
160 | - * | ||
161 | - * @return resolved nodes | ||
162 | - */ | ||
163 | - public Map<YangAtomicPath, YangNode> getResolvedNodes() { | ||
164 | - return resolvedNodes; | ||
165 | - } | ||
166 | - | ||
167 | - /** | ||
168 | - * Sets resolved nodes. | ||
169 | - * | ||
170 | - * @param resolvedNodes resolved nodes | ||
171 | - */ | ||
172 | - private void setResolvedNodes(Map<YangAtomicPath, YangNode> resolvedNodes) { | ||
173 | - this.resolvedNodes = resolvedNodes; | ||
174 | - } | ||
175 | - | ||
176 | - /** | ||
177 | * Adds node to resolved nodes. | 156 | * Adds node to resolved nodes. |
178 | * | 157 | * |
179 | * @param path absolute path | 158 | * @param path absolute path |
180 | * @param node resolved node | 159 | * @param node resolved node |
181 | */ | 160 | */ |
182 | private void addToResolvedNodes(YangAtomicPath path, YangNode node) { | 161 | private void addToResolvedNodes(YangAtomicPath path, YangNode node) { |
183 | - getResolvedNodes().put(path, node); | 162 | + path.setResolvedNode(node); |
184 | } | 163 | } |
185 | 164 | ||
186 | /** | 165 | /** |
... | @@ -205,13 +184,13 @@ public class YangXpathLinker<T> { | ... | @@ -205,13 +184,13 @@ public class YangXpathLinker<T> { |
205 | * Process absolute node path for target leaf. | 184 | * Process absolute node path for target leaf. |
206 | * | 185 | * |
207 | * @param atomicPaths atomic path node list | 186 | * @param atomicPaths atomic path node list |
208 | - * @param root root node | 187 | + * @param root root node |
209 | - * @param leafref instance of YANG leafref | 188 | + * @param leafref instance of YANG leafref |
210 | * @return linked target node | 189 | * @return linked target node |
211 | */ | 190 | */ |
212 | public T processLeafRefXpathLinking(List<YangAtomicPath> atomicPaths, YangNode root, YangLeafRef leafref) { | 191 | public T processLeafRefXpathLinking(List<YangAtomicPath> atomicPaths, YangNode root, YangLeafRef leafref) { |
213 | 192 | ||
214 | - YangNode targetNode = null; | 193 | + YangNode targetNode; |
215 | setRootNode(root); | 194 | setRootNode(root); |
216 | setPrefixResolverTypes(new HashMap<>()); | 195 | setPrefixResolverTypes(new HashMap<>()); |
217 | parsePrefixResolverList(atomicPaths); | 196 | parsePrefixResolverList(atomicPaths); |
... | @@ -260,11 +239,8 @@ public class YangXpathLinker<T> { | ... | @@ -260,11 +239,8 @@ public class YangXpathLinker<T> { |
260 | * @param leafref instance of YANG leafref | 239 | * @param leafref instance of YANG leafref |
261 | */ | 240 | */ |
262 | private void validateInvalidNodesInThePath(YangLeafRef leafref) { | 241 | private void validateInvalidNodesInThePath(YangLeafRef leafref) { |
263 | - Map<YangAtomicPath, YangNode> nodes = getResolvedNodes(); | 242 | + for (YangAtomicPath absolutePath : (Iterable<YangAtomicPath>) leafref.getAtomicPath()) { |
264 | - Iterator<Map.Entry<YangAtomicPath, YangNode>> nodesIterator = nodes.entrySet().iterator(); | 243 | + YangNode nodeInPath = absolutePath.getResolvedNode(); |
265 | - while (nodesIterator.hasNext()) { | ||
266 | - Map.Entry<YangAtomicPath, YangNode> nodeInList = nodesIterator.next(); | ||
267 | - YangNode nodeInPath = nodeInList.getValue(); | ||
268 | 244 | ||
269 | if (nodeInPath instanceof YangGrouping || nodeInPath instanceof YangUses | 245 | if (nodeInPath instanceof YangGrouping || nodeInPath instanceof YangUses |
270 | || nodeInPath instanceof YangTypeDef || nodeInPath instanceof YangCase | 246 | || nodeInPath instanceof YangTypeDef || nodeInPath instanceof YangCase |
... | @@ -331,9 +307,7 @@ public class YangXpathLinker<T> { | ... | @@ -331,9 +307,7 @@ public class YangXpathLinker<T> { |
331 | YangLeavesHolder holder = (YangLeavesHolder) targetNode; | 307 | YangLeavesHolder holder = (YangLeavesHolder) targetNode; |
332 | List<YangLeaf> leaves = holder.getListOfLeaf(); | 308 | List<YangLeaf> leaves = holder.getListOfLeaf(); |
333 | if (leaves != null && !leaves.isEmpty()) { | 309 | if (leaves != null && !leaves.isEmpty()) { |
334 | - Iterator<YangLeaf> leafIterator = leaves.listIterator(); | 310 | + for (YangLeaf leaf : leaves) { |
335 | - while (leafIterator.hasNext()) { | ||
336 | - YangLeaf leaf = leafIterator.next(); | ||
337 | if (leaf.getName().equals(leafName)) { | 311 | if (leaf.getName().equals(leafName)) { |
338 | return leaf; | 312 | return leaf; |
339 | } | 313 | } |
... | @@ -357,9 +331,7 @@ public class YangXpathLinker<T> { | ... | @@ -357,9 +331,7 @@ public class YangXpathLinker<T> { |
357 | YangLeavesHolder holder = (YangLeavesHolder) targetNode; | 331 | YangLeavesHolder holder = (YangLeavesHolder) targetNode; |
358 | List<YangLeafList> leavesList = holder.getListOfLeafList(); | 332 | List<YangLeafList> leavesList = holder.getListOfLeafList(); |
359 | if (leavesList != null && !leavesList.isEmpty()) { | 333 | if (leavesList != null && !leavesList.isEmpty()) { |
360 | - Iterator<YangLeafList> leafListIterator = leavesList.listIterator(); | 334 | + for (YangLeafList leafList : leavesList) { |
361 | - while (leafListIterator.hasNext()) { | ||
362 | - YangLeafList leafList = leafListIterator.next(); | ||
363 | if (leafList.getName().equals(leafListName)) { | 335 | if (leafList.getName().equals(leafListName)) { |
364 | return leafList; | 336 | return leafList; |
365 | } | 337 | } | ... | ... |
... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.plugin.manager; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.plugin.manager; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | import java.util.HashSet; | 20 | import java.util.HashSet; |
21 | -import java.util.Iterator; | ||
22 | import java.util.List; | 21 | import java.util.List; |
23 | import java.util.Set; | 22 | import java.util.Set; |
24 | import org.apache.maven.artifact.repository.ArtifactRepository; | 23 | import org.apache.maven.artifact.repository.ArtifactRepository; |
... | @@ -43,6 +42,7 @@ import org.sonatype.plexus.build.incremental.BuildContext; | ... | @@ -43,6 +42,7 @@ import org.sonatype.plexus.build.incremental.BuildContext; |
43 | 42 | ||
44 | import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES; | 43 | import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES; |
45 | import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE; | 44 | import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE; |
45 | +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority; | ||
46 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; | 46 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; |
47 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.copyYangFilesToTarget; | 47 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.copyYangFilesToTarget; |
48 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.resolveInterJarDependencies; | 48 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.resolveInterJarDependencies; |
... | @@ -67,17 +67,14 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirP | ... | @@ -67,17 +67,14 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirP |
67 | public class YangUtilManager | 67 | public class YangUtilManager |
68 | extends AbstractMojo { | 68 | extends AbstractMojo { |
69 | 69 | ||
70 | + private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG); | ||
70 | private YangNode rootNode; | 71 | private YangNode rootNode; |
71 | // YANG file information set. | 72 | // YANG file information set. |
72 | private Set<YangFileInfo> yangFileInfoSet = new HashSet<>(); | 73 | private Set<YangFileInfo> yangFileInfoSet = new HashSet<>(); |
73 | private YangUtilsParser yangUtilsParser = new YangUtilsParserManager(); | 74 | private YangUtilsParser yangUtilsParser = new YangUtilsParserManager(); |
74 | private YangLinker yangLinker = new YangLinkerManager(); | 75 | private YangLinker yangLinker = new YangLinkerManager(); |
75 | private YangFileInfo curYangFileInfo = new YangFileInfo(); | 76 | private YangFileInfo curYangFileInfo = new YangFileInfo(); |
76 | - | ||
77 | private Set<YangNode> yangNodeSet = new HashSet<>(); | 77 | private Set<YangNode> yangNodeSet = new HashSet<>(); |
78 | - | ||
79 | - private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG); | ||
80 | - | ||
81 | /** | 78 | /** |
82 | * Source directory for YANG files. | 79 | * Source directory for YANG files. |
83 | */ | 80 | */ |
... | @@ -144,9 +141,15 @@ public class YangUtilManager | ... | @@ -144,9 +141,15 @@ public class YangUtilManager |
144 | @Component | 141 | @Component |
145 | private BuildContext context; | 142 | private BuildContext context; |
146 | 143 | ||
144 | + /** | ||
145 | + * Local maven repository. | ||
146 | + */ | ||
147 | @Parameter(readonly = true, defaultValue = "${localRepository}") | 147 | @Parameter(readonly = true, defaultValue = "${localRepository}") |
148 | private ArtifactRepository localRepository; | 148 | private ArtifactRepository localRepository; |
149 | 149 | ||
150 | + /** | ||
151 | + * Remote maven repositories. | ||
152 | + */ | ||
150 | @Parameter(readonly = true, defaultValue = "${project.remoteArtifactRepositories}") | 153 | @Parameter(readonly = true, defaultValue = "${project.remoteArtifactRepositories}") |
151 | private List<ArtifactRepository> remoteRepository; | 154 | private List<ArtifactRepository> remoteRepository; |
152 | 155 | ||
... | @@ -196,7 +199,7 @@ public class YangUtilManager | ... | @@ -196,7 +199,7 @@ public class YangUtilManager |
196 | return; | 199 | return; |
197 | } | 200 | } |
198 | // Resolve inter jar dependency. | 201 | // Resolve inter jar dependency. |
199 | - resolveInterJardependency(); | 202 | + resolveInterJarDependency(); |
200 | 203 | ||
201 | // Carry out the parsing for all the YANG files. | 204 | // Carry out the parsing for all the YANG files. |
202 | parseYangFileInfoSet(); | 205 | parseYangFileInfoSet(); |
... | @@ -205,7 +208,7 @@ public class YangUtilManager | ... | @@ -205,7 +208,7 @@ public class YangUtilManager |
205 | resolveDependenciesUsingLinker(); | 208 | resolveDependenciesUsingLinker(); |
206 | 209 | ||
207 | // Perform translation to JAVA. | 210 | // Perform translation to JAVA. |
208 | - translateToJava(getYangFileInfoSet(), yangPlugin); | 211 | + translateToJava(yangPlugin); |
209 | 212 | ||
210 | // Serialize data model. | 213 | // Serialize data model. |
211 | serializeDataModel(getDirectory(baseDir, outputDirectory), getYangFileInfoSet(), project, true); | 214 | serializeDataModel(getDirectory(baseDir, outputDirectory), getYangFileInfoSet(), project, true); |
... | @@ -237,7 +240,7 @@ public class YangUtilManager | ... | @@ -237,7 +240,7 @@ public class YangUtilManager |
237 | * | 240 | * |
238 | * @return YANG node set | 241 | * @return YANG node set |
239 | */ | 242 | */ |
240 | - public Set<YangNode> getYangNodeSet() { | 243 | + Set<YangNode> getYangNodeSet() { |
241 | return yangNodeSet; | 244 | return yangNodeSet; |
242 | } | 245 | } |
243 | 246 | ||
... | @@ -246,12 +249,13 @@ public class YangUtilManager | ... | @@ -246,12 +249,13 @@ public class YangUtilManager |
246 | * | 249 | * |
247 | * @throws IOException when fails to do IO operations | 250 | * @throws IOException when fails to do IO operations |
248 | */ | 251 | */ |
249 | - public void resolveInterJardependency() throws IOException { | 252 | + private void resolveInterJarDependency() throws IOException { |
250 | try { | 253 | try { |
251 | List<YangNode> interJarResolvedNodes = resolveInterJarDependencies(project, localRepository, | 254 | List<YangNode> interJarResolvedNodes = resolveInterJarDependencies(project, localRepository, |
252 | remoteRepository, getDirectory(baseDir, outputDirectory)); | 255 | remoteRepository, getDirectory(baseDir, outputDirectory)); |
253 | for (YangNode node : interJarResolvedNodes) { | 256 | for (YangNode node : interJarResolvedNodes) { |
254 | YangFileInfo dependentFileInfo = new YangFileInfo(); | 257 | YangFileInfo dependentFileInfo = new YangFileInfo(); |
258 | + node.setToTranslate(false); | ||
255 | dependentFileInfo.setRootNode(node); | 259 | dependentFileInfo.setRootNode(node); |
256 | dependentFileInfo.setForTranslator(false); | 260 | dependentFileInfo.setForTranslator(false); |
257 | dependentFileInfo.setYangFileName(node.getName()); | 261 | dependentFileInfo.setYangFileName(node.getName()); |
... | @@ -281,7 +285,7 @@ public class YangUtilManager | ... | @@ -281,7 +285,7 @@ public class YangUtilManager |
281 | /** | 285 | /** |
282 | * Creates YANG nodes set. | 286 | * Creates YANG nodes set. |
283 | */ | 287 | */ |
284 | - public void createYangNodeSet() { | 288 | + void createYangNodeSet() { |
285 | for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { | 289 | for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { |
286 | getYangNodeSet().add(yangFileInfo.getRootNode()); | 290 | getYangNodeSet().add(yangFileInfo.getRootNode()); |
287 | } | 291 | } |
... | @@ -339,19 +343,15 @@ public class YangUtilManager | ... | @@ -339,19 +343,15 @@ public class YangUtilManager |
339 | /** | 343 | /** |
340 | * Translates to java code corresponding to the YANG schema. | 344 | * Translates to java code corresponding to the YANG schema. |
341 | * | 345 | * |
342 | - * @param yangFileInfoSet YANG file information | 346 | + * @param yangPlugin YANG plugin config |
343 | - * @param yangPlugin YANG plugin config | 347 | + * @throws IOException when fails to generate java code file the current node |
344 | - * @throws IOException when fails to generate java code file the current | ||
345 | - * node | ||
346 | */ | 348 | */ |
347 | - public void translateToJava(Set<YangFileInfo> yangFileInfoSet, YangPluginConfig yangPlugin) | 349 | + public void translateToJava(YangPluginConfig yangPlugin) |
348 | throws IOException { | 350 | throws IOException { |
349 | - Iterator<YangFileInfo> yangFileIterator = yangFileInfoSet.iterator(); | 351 | + updateFilePriority(getYangNodeSet()); |
350 | - while (yangFileIterator.hasNext()) { | 352 | + for (YangNode node : getYangNodeSet()) { |
351 | - YangFileInfo yangFileInfo = yangFileIterator.next(); | 353 | + if (node.isToTranslate()) { |
352 | - setCurYangFileInfo(yangFileInfo); | 354 | + generateJavaCode(node, yangPlugin); |
353 | - if (yangFileInfo.isForTranslator()) { | ||
354 | - generateJavaCode(yangFileInfo.getRootNode(), yangPlugin); | ||
355 | } | 355 | } |
356 | } | 356 | } |
357 | } | 357 | } |
... | @@ -383,7 +383,7 @@ public class YangUtilManager | ... | @@ -383,7 +383,7 @@ public class YangUtilManager |
383 | * | 383 | * |
384 | * @param yangFileInfoSet the YANG file info set | 384 | * @param yangFileInfoSet the YANG file info set |
385 | */ | 385 | */ |
386 | - public void setYangFileInfoSet(Set<YangFileInfo> yangFileInfoSet) { | 386 | + void setYangFileInfoSet(Set<YangFileInfo> yangFileInfoSet) { |
387 | this.yangFileInfoSet = yangFileInfoSet; | 387 | this.yangFileInfoSet = yangFileInfoSet; |
388 | } | 388 | } |
389 | 389 | ||
... | @@ -392,7 +392,7 @@ public class YangUtilManager | ... | @@ -392,7 +392,7 @@ public class YangUtilManager |
392 | * | 392 | * |
393 | * @return the yangFileInfo | 393 | * @return the yangFileInfo |
394 | */ | 394 | */ |
395 | - public YangFileInfo getCurYangFileInfo() { | 395 | + private YangFileInfo getCurYangFileInfo() { |
396 | return curYangFileInfo; | 396 | return curYangFileInfo; |
397 | } | 397 | } |
398 | 398 | ||
... | @@ -401,7 +401,7 @@ public class YangUtilManager | ... | @@ -401,7 +401,7 @@ public class YangUtilManager |
401 | * | 401 | * |
402 | * @param yangFileInfo the yangFileInfo to set | 402 | * @param yangFileInfo the yangFileInfo to set |
403 | */ | 403 | */ |
404 | - public void setCurYangFileInfo(YangFileInfo yangFileInfo) { | 404 | + private void setCurYangFileInfo(YangFileInfo yangFileInfo) { |
405 | curYangFileInfo = yangFileInfo; | 405 | curYangFileInfo = yangFileInfo; |
406 | } | 406 | } |
407 | } | 407 | } | ... | ... |
... | @@ -88,6 +88,12 @@ public final class GeneratedJavaFileType { | ... | @@ -88,6 +88,12 @@ public final class GeneratedJavaFileType { |
88 | public static final int GENERATE_EVENT_SUBJECT_CLASS = 1024; | 88 | public static final int GENERATE_EVENT_SUBJECT_CLASS = 1024; |
89 | 89 | ||
90 | /** | 90 | /** |
91 | + * Java classes for events. | ||
92 | + */ | ||
93 | + public static final int GENERATE_ALL_EVENT_CLASS_MASK = GENERATE_EVENT_CLASS | GENERATE_EVENT_LISTENER_INTERFACE | ||
94 | + | GENERATE_EVENT_SUBJECT_CLASS; | ||
95 | + | ||
96 | + /** | ||
91 | * Identity listener class. | 97 | * Identity listener class. |
92 | */ | 98 | */ |
93 | public static final int GENERATE_IDENTITY_CLASS = 2048; | 99 | public static final int GENERATE_IDENTITY_CLASS = 2048; | ... | ... |
utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
... | @@ -42,6 +42,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | ... | @@ -42,6 +42,7 @@ 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_OP_PARAM_INFO_CLASS; | ||
45 | import static java.util.Collections.sort; | 46 | import static java.util.Collections.sort; |
46 | 47 | ||
47 | /** | 48 | /** |
... | @@ -289,4 +290,14 @@ public class JavaImportData { | ... | @@ -289,4 +290,14 @@ public class JavaImportData { |
289 | public String getYangAugmentedInfoImport() { | 290 | public String getYangAugmentedInfoImport() { |
290 | return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS; | 291 | return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS; |
291 | } | 292 | } |
293 | + | ||
294 | + /** | ||
295 | + * Returns import string for YangAugmentedOpParamInfo class. | ||
296 | + * | ||
297 | + * @return import string for YangAugmentedOpParamInfo class | ||
298 | + */ | ||
299 | + public String getYangAugmentedOpParamInfoImport() { | ||
300 | + return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + | ||
301 | + YANG_AUGMENTED_OP_PARAM_INFO_CLASS; | ||
302 | + } | ||
292 | } | 303 | } | ... | ... |
... | @@ -23,6 +23,7 @@ import org.onosproject.yangutils.datamodel.YangTypeHolder; | ... | @@ -23,6 +23,7 @@ import org.onosproject.yangutils.datamodel.YangTypeHolder; |
23 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
24 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 24 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
25 | 25 | ||
26 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ALL_EVENT_CLASS_MASK; | ||
26 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; | 27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; |
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
... | @@ -56,6 +57,11 @@ public class TempJavaCodeFragmentFiles { | ... | @@ -56,6 +57,11 @@ public class TempJavaCodeFragmentFiles { |
56 | private TempJavaEnumerationFragmentFiles enumerationTempFiles; | 57 | private TempJavaEnumerationFragmentFiles enumerationTempFiles; |
57 | 58 | ||
58 | /** | 59 | /** |
60 | + * Has the temporary files required for enumeration generated classes. | ||
61 | + */ | ||
62 | + private TempJavaEventFragmentFiles tempJavaEventFragmentFiles; | ||
63 | + | ||
64 | + /** | ||
59 | * Creates an instance of temporary java code fragment. | 65 | * Creates an instance of temporary java code fragment. |
60 | * | 66 | * |
61 | * @param javaFileInfo generated java file info | 67 | * @param javaFileInfo generated java file info |
... | @@ -80,6 +86,10 @@ public class TempJavaCodeFragmentFiles { | ... | @@ -80,6 +86,10 @@ public class TempJavaCodeFragmentFiles { |
80 | setServiceTempFiles(new TempJavaServiceFragmentFiles(javaFileInfo)); | 86 | setServiceTempFiles(new TempJavaServiceFragmentFiles(javaFileInfo)); |
81 | } | 87 | } |
82 | 88 | ||
89 | + if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) { | ||
90 | + setEventFragmentFiles(new TempJavaEventFragmentFiles(javaFileInfo)); | ||
91 | + } | ||
92 | + | ||
83 | } | 93 | } |
84 | 94 | ||
85 | /** | 95 | /** |
... | @@ -156,10 +166,29 @@ public class TempJavaCodeFragmentFiles { | ... | @@ -156,10 +166,29 @@ public class TempJavaCodeFragmentFiles { |
156 | } | 166 | } |
157 | 167 | ||
158 | /** | 168 | /** |
169 | + * Retrieves the temp file handle for event file generation. | ||
170 | + * | ||
171 | + * @return temp file handle for enumeration file generation | ||
172 | + */ | ||
173 | + public TempJavaEventFragmentFiles getEventFragmentFiles() { | ||
174 | + return tempJavaEventFragmentFiles; | ||
175 | + } | ||
176 | + | ||
177 | + /** | ||
178 | + * Sets temp file handle for event file generation. | ||
179 | + * | ||
180 | + * @param tempJavaEventFragmentFiles temp file handle for event file generation | ||
181 | + */ | ||
182 | + public void setEventFragmentFiles(TempJavaEventFragmentFiles tempJavaEventFragmentFiles) { | ||
183 | + this.tempJavaEventFragmentFiles = tempJavaEventFragmentFiles; | ||
184 | + } | ||
185 | + | ||
186 | + | ||
187 | + /** | ||
159 | * Constructs java code exit. | 188 | * Constructs java code exit. |
160 | * | 189 | * |
161 | * @param fileType generated file type | 190 | * @param fileType generated file type |
162 | - * @param curNode current YANG node | 191 | + * @param curNode current YANG node |
163 | * @throws IOException when fails to generate java files | 192 | * @throws IOException when fails to generate java files |
164 | */ | 193 | */ |
165 | public void generateJavaFile(int fileType, YangNode curNode) | 194 | public void generateJavaFile(int fileType, YangNode curNode) |
... | @@ -183,6 +212,13 @@ public class TempJavaCodeFragmentFiles { | ... | @@ -183,6 +212,13 @@ public class TempJavaCodeFragmentFiles { |
183 | getServiceTempFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, curNode); | 212 | getServiceTempFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, curNode); |
184 | } | 213 | } |
185 | 214 | ||
215 | + /** | ||
216 | + * Creates event, event listener and event subject files. | ||
217 | + */ | ||
218 | + if (fileType == GENERATE_ALL_EVENT_CLASS_MASK) { | ||
219 | + getEventFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, curNode); | ||
220 | + } | ||
221 | + | ||
186 | /* | 222 | /* |
187 | * Creats enumeration class file. | 223 | * Creats enumeration class file. |
188 | */ | 224 | */ | ... | ... |
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.translator.tojava; | ||
18 | + | ||
19 | +import java.io.File; | ||
20 | +import java.io.IOException; | ||
21 | +import java.util.ArrayList; | ||
22 | +import java.util.List; | ||
23 | + | ||
24 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
25 | +import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; | ||
26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
27 | + | ||
28 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | ||
29 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_ENUM_MASK; | ||
30 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_METHOD_MASK; | ||
31 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_ATTRIBUTE_MASK; | ||
32 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_GETTER_MASK; | ||
33 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_SETTER_MASK; | ||
34 | +import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; | ||
35 | +import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; | ||
36 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventFile; | ||
37 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventListenerFile; | ||
38 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventSubjectFile; | ||
39 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; | ||
40 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; | ||
41 | +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; | ||
42 | +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; | ||
43 | +import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | ||
44 | +import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; | ||
45 | +import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | ||
46 | +import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | ||
47 | +import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | ||
48 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; | ||
49 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; | ||
50 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD; | ||
51 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
52 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; | ||
53 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
54 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
55 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | ||
56 | + | ||
57 | +/** | ||
58 | + * Represent temporary java fragments for event files. | ||
59 | + */ | ||
60 | +public class TempJavaEventFragmentFiles | ||
61 | + extends TempJavaFragmentFiles { | ||
62 | + /** | ||
63 | + * File name for generated class file for special type like union, typedef suffix. | ||
64 | + */ | ||
65 | + public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject"; | ||
66 | + | ||
67 | + /** | ||
68 | + * File name for event enum temp file. | ||
69 | + */ | ||
70 | + | ||
71 | + private static final String EVENT_ENUM_FILE_NAME = "EventEnum"; | ||
72 | + | ||
73 | + /** | ||
74 | + * File name for event method temp file. | ||
75 | + */ | ||
76 | + private static final String EVENT_METHOD_FILE_NAME = "EventMethod"; | ||
77 | + | ||
78 | + /** | ||
79 | + * File name for event subject attribute temp file. | ||
80 | + */ | ||
81 | + private static final String EVENT_SUBJECT_ATTRIBUTE_FILE_NAME = "EventSubjectAttribute"; | ||
82 | + | ||
83 | + /** | ||
84 | + * File name for event subject getter temp file. | ||
85 | + */ | ||
86 | + private static final String EVENT_SUBJECT_GETTER_FILE_NAME = "EventSubjectGetter"; | ||
87 | + | ||
88 | + /** | ||
89 | + * File name for event subject setter temp file. | ||
90 | + */ | ||
91 | + private static final String EVENT_SUBJECT_SETTER_FILE_NAME = "EventSubjectSetter"; | ||
92 | + | ||
93 | + /** | ||
94 | + * File name for generated class file for special type like union, typedef suffix. | ||
95 | + */ | ||
96 | + private static final String EVENT_FILE_NAME_SUFFIX = "Event"; | ||
97 | + | ||
98 | + /** | ||
99 | + * File name for generated class file for special type like union, typedef suffix. | ||
100 | + */ | ||
101 | + private static final String EVENT_LISTENER_FILE_NAME_SUFFIX = "Listener"; | ||
102 | + | ||
103 | + private static final String JAVA_FILE_EXTENSION = ".java"; | ||
104 | + | ||
105 | + /** | ||
106 | + * Java file handle for event subject file. | ||
107 | + */ | ||
108 | + private File eventSubjectJavaFileHandle; | ||
109 | + | ||
110 | + /** | ||
111 | + * Java file handle for event listener file. | ||
112 | + */ | ||
113 | + private File eventListenerJavaFileHandle; | ||
114 | + | ||
115 | + /** | ||
116 | + * Java file handle for event file. | ||
117 | + */ | ||
118 | + private File eventJavaFileHandle; | ||
119 | + | ||
120 | + /** | ||
121 | + * Java file handle for event enum impl file. | ||
122 | + */ | ||
123 | + private File eventEnumTempFileHandle; | ||
124 | + | ||
125 | + /** | ||
126 | + * Java file handle for event method impl file. | ||
127 | + */ | ||
128 | + private File eventMethodTempFileHandle; | ||
129 | + | ||
130 | + /** | ||
131 | + * Java file handle for event subject attribute file. | ||
132 | + */ | ||
133 | + private File eventSubjectAttributeTempFileHandle; | ||
134 | + | ||
135 | + /** | ||
136 | + * Java file handle for event subject getter impl file. | ||
137 | + */ | ||
138 | + private File eventSubjectGetterTempFileHandle; | ||
139 | + | ||
140 | + /** | ||
141 | + * Java file handle for event subject setter impl file. | ||
142 | + */ | ||
143 | + private File eventSubjectSetterTempFileHandle; | ||
144 | + | ||
145 | + /** | ||
146 | + * Creates an instance of temporary java code fragment. | ||
147 | + * | ||
148 | + * @param javaFileInfo generated file information | ||
149 | + * @throws IOException when fails to create new file handle | ||
150 | + */ | ||
151 | + public TempJavaEventFragmentFiles(JavaFileInfo javaFileInfo) | ||
152 | + throws IOException { | ||
153 | + setJavaExtendsListHolder(new JavaExtendsListHolder()); | ||
154 | + setJavaImportData(new JavaImportData()); | ||
155 | + setJavaFileInfo(javaFileInfo); | ||
156 | + setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(), | ||
157 | + getJavaFileInfo().getPackageFilePath())); | ||
158 | + | ||
159 | + addGeneratedTempFile(EVENT_ENUM_MASK); | ||
160 | + addGeneratedTempFile(EVENT_METHOD_MASK); | ||
161 | + addGeneratedTempFile(EVENT_SUBJECT_ATTRIBUTE_MASK); | ||
162 | + addGeneratedTempFile(EVENT_SUBJECT_GETTER_MASK); | ||
163 | + addGeneratedTempFile(EVENT_SUBJECT_SETTER_MASK); | ||
164 | + | ||
165 | + setEventEnumTempFileHandle(getTemporaryFileHandle(EVENT_ENUM_FILE_NAME)); | ||
166 | + setEventMethodTempFileHandle(getTemporaryFileHandle(EVENT_METHOD_FILE_NAME)); | ||
167 | + setEventSubjectAttributeTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_ATTRIBUTE_FILE_NAME)); | ||
168 | + setEventSubjectGetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_GETTER_FILE_NAME)); | ||
169 | + setEventSubjectSetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_SETTER_FILE_NAME)); | ||
170 | + } | ||
171 | + | ||
172 | + /*Adds event method contents to event file.*/ | ||
173 | + private static String getEventFileContents(String eventClassname, String classname) { | ||
174 | + return "\n" + | ||
175 | + " /**\n" + | ||
176 | + " * Creates " + classname + " event with type and subject.\n" + | ||
177 | + " *\n" + | ||
178 | + " * @param type event type\n" + | ||
179 | + " * @param subject subject " + classname + "\n" + | ||
180 | + " */\n" + | ||
181 | + " public " + eventClassname + "(Type type, " + getCapitalCase(classname) + " subject) {\n" + | ||
182 | + " super(type, subject);\n" + | ||
183 | + " }\n" + | ||
184 | + "\n" + | ||
185 | + " /**\n" + | ||
186 | + " * Creates " + classname + " event with type, subject and time.\n" + | ||
187 | + " *\n" + | ||
188 | + " * @param type event type\n" + | ||
189 | + " * @param subject subject " + classname + "\n" + | ||
190 | + " * @param time time of event\n" + | ||
191 | + " */\n" + | ||
192 | + " public " + eventClassname + "(Type type, " + getCapitalCase(classname) | ||
193 | + + " subject, long time) {\n" + | ||
194 | + " super(type, subject, time);\n" + | ||
195 | + " }\n" + | ||
196 | + "\n"; | ||
197 | + } | ||
198 | + | ||
199 | + /** | ||
200 | + * Returns event's java file handle. | ||
201 | + * | ||
202 | + * @return java file handle | ||
203 | + */ | ||
204 | + private File getEventJavaFileHandle() { | ||
205 | + return eventJavaFileHandle; | ||
206 | + } | ||
207 | + | ||
208 | + /** | ||
209 | + * Sets event's java file handle. | ||
210 | + * | ||
211 | + * @param eventJavaFileHandle file handle for event | ||
212 | + */ | ||
213 | + private void setEventJavaFileHandle(File eventJavaFileHandle) { | ||
214 | + this.eventJavaFileHandle = eventJavaFileHandle; | ||
215 | + } | ||
216 | + | ||
217 | + /** | ||
218 | + * Returns event listeners's java file handle. | ||
219 | + * | ||
220 | + * @return java file handle | ||
221 | + */ | ||
222 | + private File getEventListenerJavaFileHandle() { | ||
223 | + return eventListenerJavaFileHandle; | ||
224 | + } | ||
225 | + | ||
226 | + /** | ||
227 | + * Sets event's java file handle. | ||
228 | + * | ||
229 | + * @param eventListenerJavaFileHandle file handle for event | ||
230 | + */ | ||
231 | + private void setEventListenerJavaFileHandle(File eventListenerJavaFileHandle) { | ||
232 | + this.eventListenerJavaFileHandle = eventListenerJavaFileHandle; | ||
233 | + } | ||
234 | + | ||
235 | + /** | ||
236 | + * Returns event subject's java file handle. | ||
237 | + * | ||
238 | + * @return java file handle | ||
239 | + */ | ||
240 | + private File getEventSubjectJavaFileHandle() { | ||
241 | + return eventSubjectJavaFileHandle; | ||
242 | + } | ||
243 | + | ||
244 | + /** | ||
245 | + * Sets event's subject java file handle. | ||
246 | + * | ||
247 | + * @param eventSubjectJavaFileHandle file handle for event's subject | ||
248 | + */ | ||
249 | + private void setEventSubjectJavaFileHandle(File eventSubjectJavaFileHandle) { | ||
250 | + this.eventSubjectJavaFileHandle = eventSubjectJavaFileHandle; | ||
251 | + } | ||
252 | + | ||
253 | + public void generateJavaFile(int fileType, YangNode curNode) throws IOException { | ||
254 | + generateEventJavaFile(curNode); | ||
255 | + generateEventListenerJavaFile(curNode); | ||
256 | + generateEventSubjectJavaFile(curNode); | ||
257 | + } | ||
258 | + | ||
259 | + /** | ||
260 | + * Constructs java code exit. | ||
261 | + * | ||
262 | + * @param curNode current YANG node | ||
263 | + * @throws IOException when fails to generate java files | ||
264 | + */ | ||
265 | + public void generateEventJavaFile(YangNode curNode) | ||
266 | + throws IOException { | ||
267 | + | ||
268 | + List<String> imports = new ArrayList<>(); | ||
269 | + | ||
270 | + imports.add(getJavaImportData().getAbstractEventsImport()); | ||
271 | + String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()); | ||
272 | + String nodeName = curNodeInfo + EVENT_STRING; | ||
273 | + | ||
274 | + addEnumMethod(nodeName, curNodeInfo + EVENT_SUBJECT_NAME_SUFFIX); | ||
275 | + | ||
276 | + /** | ||
277 | + * Creates event interface file. | ||
278 | + */ | ||
279 | + setEventJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + EVENT_FILE_NAME_SUFFIX)); | ||
280 | + generateEventFile(getEventJavaFileHandle(), curNode, imports); | ||
281 | + | ||
282 | + /** | ||
283 | + * Close all the file handles. | ||
284 | + */ | ||
285 | + freeTemporaryResources(false); | ||
286 | + } | ||
287 | + | ||
288 | + /** | ||
289 | + * Constructs java code exit. | ||
290 | + * | ||
291 | + * @param curNode current YANG node | ||
292 | + * @throws IOException when fails to generate java files | ||
293 | + */ | ||
294 | + public void generateEventListenerJavaFile(YangNode curNode) | ||
295 | + throws IOException { | ||
296 | + | ||
297 | + List<String> imports = new ArrayList<>(); | ||
298 | + | ||
299 | + imports.add(getJavaImportData().getEventListenerImport()); | ||
300 | + String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) | ||
301 | + .getJavaFileInfo().getJavaName()); | ||
302 | + /** | ||
303 | + * Creates event listener interface file. | ||
304 | + */ | ||
305 | + setEventListenerJavaFileHandle( | ||
306 | + getJavaFileHandle(curNode, curNodeInfo + EVENT_LISTENER_FILE_NAME_SUFFIX)); | ||
307 | + generateEventListenerFile(getEventListenerJavaFileHandle(), curNode, imports); | ||
308 | + | ||
309 | + /** | ||
310 | + * Close all the file handles. | ||
311 | + */ | ||
312 | + freeTemporaryResources(false); | ||
313 | + } | ||
314 | + | ||
315 | + /** | ||
316 | + * Constructs java code exit. | ||
317 | + * | ||
318 | + * @param curNode current YANG node | ||
319 | + * @throws IOException when fails to generate java files | ||
320 | + */ | ||
321 | + public void generateEventSubjectJavaFile(YangNode curNode) | ||
322 | + throws IOException { | ||
323 | + | ||
324 | + String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) | ||
325 | + .getJavaFileInfo().getJavaName()); | ||
326 | + /** | ||
327 | + * Creates event interface file. | ||
328 | + */ | ||
329 | + setEventSubjectJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + | ||
330 | + TempJavaEventFragmentFiles.EVENT_SUBJECT_NAME_SUFFIX)); | ||
331 | + generateEventSubjectFile(getEventSubjectJavaFileHandle(), curNode); | ||
332 | + | ||
333 | + /** | ||
334 | + * Close all the file handles. | ||
335 | + */ | ||
336 | + freeTemporaryResources(false); | ||
337 | + } | ||
338 | + | ||
339 | + /** | ||
340 | + * Returns event enum temp file. | ||
341 | + * | ||
342 | + * @return event enum temp file | ||
343 | + */ | ||
344 | + public File getEventEnumTempFileHandle() { | ||
345 | + return eventEnumTempFileHandle; | ||
346 | + } | ||
347 | + | ||
348 | + /** | ||
349 | + * Sets event enum temp file. | ||
350 | + * | ||
351 | + * @param eventEnumTempFileHandle event enum temp file | ||
352 | + */ | ||
353 | + public void setEventEnumTempFileHandle(File eventEnumTempFileHandle) { | ||
354 | + this.eventEnumTempFileHandle = eventEnumTempFileHandle; | ||
355 | + } | ||
356 | + | ||
357 | + /** | ||
358 | + * Returns event method temp file. | ||
359 | + * | ||
360 | + * @return event method temp file | ||
361 | + */ | ||
362 | + public File getEventMethodTempFileHandle() { | ||
363 | + return eventMethodTempFileHandle; | ||
364 | + } | ||
365 | + | ||
366 | + /** | ||
367 | + * Sets event method temp file. | ||
368 | + * | ||
369 | + * @param eventMethodTempFileHandle event method temp file | ||
370 | + */ | ||
371 | + public void setEventMethodTempFileHandle(File eventMethodTempFileHandle) { | ||
372 | + this.eventMethodTempFileHandle = eventMethodTempFileHandle; | ||
373 | + } | ||
374 | + | ||
375 | + /** | ||
376 | + * Returns event subject attribute temp file. | ||
377 | + * | ||
378 | + * @return event subject attribute temp file | ||
379 | + */ | ||
380 | + public File getEventSubjectAttributeTempFileHandle() { | ||
381 | + return eventSubjectAttributeTempFileHandle; | ||
382 | + } | ||
383 | + | ||
384 | + /** | ||
385 | + * Sets event subject attribute temp file. | ||
386 | + * | ||
387 | + * @param eventSubjectAttributeTempFileHandle event subject attribute temp file | ||
388 | + */ | ||
389 | + public void setEventSubjectAttributeTempFileHandle(File eventSubjectAttributeTempFileHandle) { | ||
390 | + this.eventSubjectAttributeTempFileHandle = eventSubjectAttributeTempFileHandle; | ||
391 | + } | ||
392 | + | ||
393 | + /** | ||
394 | + * Returns event subject getter temp file. | ||
395 | + * | ||
396 | + * @return event subject getter temp file | ||
397 | + */ | ||
398 | + public File getEventSubjectGetterTempFileHandle() { | ||
399 | + return eventSubjectGetterTempFileHandle; | ||
400 | + } | ||
401 | + | ||
402 | + /** | ||
403 | + * Sets event subject getter temp file. | ||
404 | + * | ||
405 | + * @param eventSubjectGetterTempFileHandle event subject getter temp file | ||
406 | + */ | ||
407 | + public void setEventSubjectGetterTempFileHandle(File eventSubjectGetterTempFileHandle) { | ||
408 | + this.eventSubjectGetterTempFileHandle = eventSubjectGetterTempFileHandle; | ||
409 | + } | ||
410 | + | ||
411 | + /** | ||
412 | + * Returns event subject setter temp file. | ||
413 | + * | ||
414 | + * @return event subject setter temp file | ||
415 | + */ | ||
416 | + public File getEventSubjectSetterTempFileHandle() { | ||
417 | + return eventSubjectSetterTempFileHandle; | ||
418 | + } | ||
419 | + | ||
420 | + /** | ||
421 | + * Sets event subject setter temp file. | ||
422 | + * | ||
423 | + * @param eventSubjectSetterTempFileHandle event subject setter temp file | ||
424 | + */ | ||
425 | + public void setEventSubjectSetterTempFileHandle(File eventSubjectSetterTempFileHandle) { | ||
426 | + this.eventSubjectSetterTempFileHandle = eventSubjectSetterTempFileHandle; | ||
427 | + } | ||
428 | + | ||
429 | + /** | ||
430 | + * Adds java snippet for events to event subject file. | ||
431 | + * | ||
432 | + * @param curNode current node | ||
433 | + * @param pluginConfig plugin configurations | ||
434 | + * @throws IOException when fails to do IO operations | ||
435 | + */ | ||
436 | + public void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig) | ||
437 | + throws IOException { | ||
438 | + | ||
439 | + String currentInfo = getCapitalCase(getCamelCase(curNode.getName(), | ||
440 | + pluginConfig.getConflictResolver())); | ||
441 | + String notificationName = curNode.getName(); | ||
442 | + | ||
443 | + JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, | ||
444 | + getCapitalCase(currentInfo)); | ||
445 | + | ||
446 | + JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData(qualifiedTypeInfo, getSmallCase(currentInfo), | ||
447 | + null, false, false); | ||
448 | + | ||
449 | + /*Adds java info for event in respective temp files.*/ | ||
450 | + addEventEnum(notificationName, pluginConfig); | ||
451 | + addEventSubjectAttribute(javaAttributeInfo, pluginConfig); | ||
452 | + addEventSubjectGetter(javaAttributeInfo, pluginConfig); | ||
453 | + addEventSubjectSetter(javaAttributeInfo, pluginConfig, currentInfo); | ||
454 | + } | ||
455 | + | ||
456 | + /*Adds event to enum temp file.*/ | ||
457 | + private void addEventEnum(String notificationName, YangPluginConfig pluginConfig) | ||
458 | + throws IOException { | ||
459 | + appendToFile(getEventEnumTempFileHandle(), | ||
460 | + getJavaDoc(ENUM_ATTRIBUTE, notificationName, false, pluginConfig) + FOUR_SPACE_INDENTATION | ||
461 | + + getEnumJavaAttribute(notificationName).toUpperCase() + COMMA + NEW_LINE); | ||
462 | + } | ||
463 | + | ||
464 | + /*Adds event method in event class*/ | ||
465 | + private void addEnumMethod(String eventClassname, String className) | ||
466 | + throws IOException { | ||
467 | + appendToFile(getEventMethodTempFileHandle(), getEventFileContents(eventClassname, className)); | ||
468 | + } | ||
469 | + | ||
470 | + /*Adds events to event subject file.*/ | ||
471 | + private void addEventSubjectAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) | ||
472 | + throws IOException { | ||
473 | + appendToFile(getEventSubjectAttributeTempFileHandle(), | ||
474 | + FOUR_SPACE_INDENTATION + parseAttribute(attr, pluginConfig)); | ||
475 | + } | ||
476 | + | ||
477 | + /*Adds getter method for event in event subject class.*/ | ||
478 | + private void addEventSubjectGetter(JavaAttributeInfo attr, YangPluginConfig pluginConfig) | ||
479 | + throws IOException { | ||
480 | + appendToFile(getEventSubjectGetterTempFileHandle(), | ||
481 | + getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) | ||
482 | + + getGetterForClass(attr, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE); | ||
483 | + } | ||
484 | + | ||
485 | + /*Adds setter method for event in event subject class.*/ | ||
486 | + private void addEventSubjectSetter(JavaAttributeInfo attr, YangPluginConfig pluginConfig, String className) | ||
487 | + throws IOException { | ||
488 | + appendToFile(getEventSubjectSetterTempFileHandle(), | ||
489 | + getJavaDoc(MANAGER_SETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) | ||
490 | + + getSetterForClass(attr, className, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE); | ||
491 | + } | ||
492 | + | ||
493 | + /** | ||
494 | + * Returns a temporary file handle for the event's file type. | ||
495 | + * | ||
496 | + * @param name file name | ||
497 | + * @return temporary file handle | ||
498 | + * @throws IOException when fails to create new file handle | ||
499 | + */ | ||
500 | + private File getJavaFileHandle(YangNode curNode, String name) | ||
501 | + throws IOException { | ||
502 | + | ||
503 | + JavaFileInfo parentInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | ||
504 | + JavaFileInfo childInfo = ((JavaFileInfoContainer) curNode.getChild()).getJavaFileInfo(); | ||
505 | + | ||
506 | + return getFileObject(getDirPath(parentInfo), name, JAVA_FILE_EXTENSION, | ||
507 | + childInfo.getBaseCodeGenPath()); | ||
508 | + } | ||
509 | + | ||
510 | + /** | ||
511 | + * Returns the directory path. | ||
512 | + * | ||
513 | + * @return directory path | ||
514 | + */ | ||
515 | + private String getDirPath(JavaFileInfo parentInfo) { | ||
516 | + return (parentInfo.getPackageFilePath() + SLASH + parentInfo.getJavaName()).toLowerCase(); | ||
517 | + } | ||
518 | +} |
... | @@ -19,19 +19,17 @@ import java.io.File; | ... | @@ -19,19 +19,17 @@ import java.io.File; |
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | import java.util.List; | 20 | import java.util.List; |
21 | 21 | ||
22 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
22 | import org.onosproject.yangutils.datamodel.YangAugmentableNode; | 23 | import org.onosproject.yangutils.datamodel.YangAugmentableNode; |
23 | import org.onosproject.yangutils.datamodel.YangCase; | 24 | import org.onosproject.yangutils.datamodel.YangCase; |
24 | import org.onosproject.yangutils.datamodel.YangLeaf; | 25 | import org.onosproject.yangutils.datamodel.YangLeaf; |
25 | import org.onosproject.yangutils.datamodel.YangLeafList; | 26 | import org.onosproject.yangutils.datamodel.YangLeafList; |
26 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 27 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
27 | -import org.onosproject.yangutils.datamodel.YangList; | ||
28 | import org.onosproject.yangutils.datamodel.YangModule; | 28 | import org.onosproject.yangutils.datamodel.YangModule; |
29 | import org.onosproject.yangutils.datamodel.YangNode; | 29 | import org.onosproject.yangutils.datamodel.YangNode; |
30 | import org.onosproject.yangutils.datamodel.YangSubModule; | 30 | import org.onosproject.yangutils.datamodel.YangSubModule; |
31 | -import org.onosproject.yangutils.datamodel.YangUses; | ||
32 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 31 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
33 | import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; | 32 | import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; |
34 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; | ||
35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; | 33 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; |
36 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | 34 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
37 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | 35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
... | @@ -69,9 +67,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato | ... | @@ -69,9 +67,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato |
69 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile; | 67 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile; |
70 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; | 68 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; |
71 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; | 69 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; |
72 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports; | ||
73 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateOpParamBuilderClassFile; | 70 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateOpParamBuilderClassFile; |
74 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateOpParamImplClassFile; | 71 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateOpParamImplClassFile; |
72 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports; | ||
75 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; | 73 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
76 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; | 74 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
77 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedConstructor; | 75 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedConstructor; |
... | @@ -99,15 +97,16 @@ import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; | ... | @@ -99,15 +97,16 @@ import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; |
99 | import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; | 97 | import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; |
100 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; | 98 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; |
101 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 99 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
100 | +import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; | ||
102 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 101 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
102 | +import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; | ||
103 | +import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED; | ||
103 | import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE; | 104 | import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE; |
104 | import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALITY; | 105 | import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALITY; |
105 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 106 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
106 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; | 107 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
107 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 108 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
108 | -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; | 109 | +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; |
109 | -import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; | ||
110 | -import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED; | ||
111 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; | 110 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
112 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; | 111 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; |
113 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; | 112 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
... | @@ -340,6 +339,11 @@ public class TempJavaFragmentFiles { | ... | @@ -340,6 +339,11 @@ public class TempJavaFragmentFiles { |
340 | private boolean isAttributePresent; | 339 | private boolean isAttributePresent; |
341 | 340 | ||
342 | /** | 341 | /** |
342 | + * Base code gen path. | ||
343 | + */ | ||
344 | + private String baseCodePath; | ||
345 | + | ||
346 | + /** | ||
343 | * Temporary file handle for augments copy constructor method of class. | 347 | * Temporary file handle for augments copy constructor method of class. |
344 | */ | 348 | */ |
345 | private File augmentConstructorImplTempFileHandle; | 349 | private File augmentConstructorImplTempFileHandle; |
... | @@ -358,9 +362,15 @@ public class TempJavaFragmentFiles { | ... | @@ -358,9 +362,15 @@ public class TempJavaFragmentFiles { |
358 | setJavaExtendsListHolder(new JavaExtendsListHolder()); | 362 | setJavaExtendsListHolder(new JavaExtendsListHolder()); |
359 | setJavaImportData(new JavaImportData()); | 363 | setJavaImportData(new JavaImportData()); |
360 | setJavaFileInfo(javaFileInfo); | 364 | setJavaFileInfo(javaFileInfo); |
361 | - setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(), | 365 | + if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_SERVICE_AND_MANAGER) != 0) { |
362 | - getJavaFileInfo().getPackageFilePath())); | 366 | + setBaseCodePath(getJavaFileInfo().getPluginConfig().getCodeGenDir()); |
363 | - | 367 | + setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getPluginConfig().getCodeGenDir(), |
368 | + getJavaFileInfo().getPackageFilePath())); | ||
369 | + } else { | ||
370 | + setBaseCodePath(getJavaFileInfo().getBaseCodeGenPath()); | ||
371 | + setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(), | ||
372 | + getJavaFileInfo().getPackageFilePath())); | ||
373 | + } | ||
364 | /* | 374 | /* |
365 | * Initialize getter when generation file type matches to interface | 375 | * Initialize getter when generation file type matches to interface |
366 | * mask. | 376 | * mask. |
... | @@ -584,6 +594,24 @@ public class TempJavaFragmentFiles { | ... | @@ -584,6 +594,24 @@ public class TempJavaFragmentFiles { |
584 | } | 594 | } |
585 | 595 | ||
586 | /** | 596 | /** |
597 | + * Returns base code path. | ||
598 | + * | ||
599 | + * @return base code path | ||
600 | + */ | ||
601 | + public String getBaseCodePath() { | ||
602 | + return baseCodePath; | ||
603 | + } | ||
604 | + | ||
605 | + /** | ||
606 | + * Sets base code path. | ||
607 | + * | ||
608 | + * @param baseCodePath base code path | ||
609 | + */ | ||
610 | + public void setBaseCodePath(String baseCodePath) { | ||
611 | + this.baseCodePath = baseCodePath; | ||
612 | + } | ||
613 | + | ||
614 | + /* | ||
587 | * Retrieves the absolute path where the file needs to be generated. | 615 | * Retrieves the absolute path where the file needs to be generated. |
588 | * | 616 | * |
589 | * @return absolute path where the file needs to be generated | 617 | * @return absolute path where the file needs to be generated |
... | @@ -1180,7 +1208,7 @@ public class TempJavaFragmentFiles { | ... | @@ -1180,7 +1208,7 @@ public class TempJavaFragmentFiles { |
1180 | */ | 1208 | */ |
1181 | File getJavaFileHandle(String fileName) | 1209 | File getJavaFileHandle(String fileName) |
1182 | throws IOException { | 1210 | throws IOException { |
1183 | - return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getJavaFileInfo()); | 1211 | + return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getBaseCodePath()); |
1184 | } | 1212 | } |
1185 | 1213 | ||
1186 | /** | 1214 | /** |
... | @@ -1500,6 +1528,8 @@ public class TempJavaFragmentFiles { | ... | @@ -1500,6 +1528,8 @@ public class TempJavaFragmentFiles { |
1500 | if (curNode instanceof YangModule || curNode instanceof YangSubModule) { | 1528 | if (curNode instanceof YangModule || curNode instanceof YangSubModule) { |
1501 | addResolvedAugmentedDataNodeImports(curNode); | 1529 | addResolvedAugmentedDataNodeImports(curNode); |
1502 | } | 1530 | } |
1531 | + TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode) | ||
1532 | + .getTempJavaCodeFragmentFiles().getBeanTempFiles(); | ||
1503 | List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles() | 1533 | List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles() |
1504 | .getJavaImportData().getImports(); | 1534 | .getJavaImportData().getImports(); |
1505 | 1535 | ||
... | @@ -1539,17 +1569,9 @@ public class TempJavaFragmentFiles { | ... | @@ -1539,17 +1569,9 @@ public class TempJavaFragmentFiles { |
1539 | if (curNode instanceof YangCase) { | 1569 | if (curNode instanceof YangCase) { |
1540 | removeCaseImport(imports); | 1570 | removeCaseImport(imports); |
1541 | } | 1571 | } |
1542 | - if (curNode instanceof YangJavaAugment) { | ||
1543 | - updateAugmentConstructorTempFile(curNode, curInfo.getPluginConfig()); | ||
1544 | - YangJavaAugment augment = (YangJavaAugment) curNode; | ||
1545 | - List<JavaQualifiedTypeInfo> infoList = augment.getExtendedClassInfo(); | ||
1546 | - for (JavaQualifiedTypeInfo info : infoList) { | ||
1547 | - if (info.getClassInfo() | ||
1548 | - .equals(getCapitalCase(getCamelCase(augment.getAugmentedNode().getName(), null)))) { | ||
1549 | - removeAugmentedImport(imports, info); | ||
1550 | - } | ||
1551 | 1572 | ||
1552 | - } | 1573 | + if (curNode instanceof YangAugment) { |
1574 | + removeAugmentedInfoImport(imports); | ||
1553 | } | 1575 | } |
1554 | } | 1576 | } |
1555 | if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & IMPL_CLASS_MASK) != 0) { | 1577 | if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & IMPL_CLASS_MASK) != 0) { |
... | @@ -1557,7 +1579,7 @@ public class TempJavaFragmentFiles { | ... | @@ -1557,7 +1579,7 @@ public class TempJavaFragmentFiles { |
1557 | addImportsToStringAndHasCodeMethods(imports, true); | 1579 | addImportsToStringAndHasCodeMethods(imports, true); |
1558 | } | 1580 | } |
1559 | if (curNode instanceof YangAugmentableNode) { | 1581 | if (curNode instanceof YangAugmentableNode) { |
1560 | - addImportsForAugmentableClass(imports); | 1582 | + addImportsForAugmentableClass(imports, true); |
1561 | } | 1583 | } |
1562 | sortImports(imports); | 1584 | sortImports(imports); |
1563 | /* | 1585 | /* |
... | @@ -1582,19 +1604,33 @@ public class TempJavaFragmentFiles { | ... | @@ -1582,19 +1604,33 @@ public class TempJavaFragmentFiles { |
1582 | validateLineLength(getImplClassJavaFileHandle()); | 1604 | validateLineLength(getImplClassJavaFileHandle()); |
1583 | } | 1605 | } |
1584 | insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose()); | 1606 | insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose()); |
1585 | - | 1607 | + if (curNode instanceof YangAugmentableNode) { |
1608 | + addImportsForAugmentableClass(imports, false); | ||
1609 | + } | ||
1586 | if (!(curNode instanceof YangModule)) { | 1610 | if (!(curNode instanceof YangModule)) { |
1587 | if (isAttributePresent()) { | 1611 | if (isAttributePresent()) { |
1588 | addImportsToStringAndHasCodeMethods(imports, false); | 1612 | addImportsToStringAndHasCodeMethods(imports, false); |
1589 | } | 1613 | } |
1614 | + if (curNode instanceof YangAugmentableNode) { | ||
1615 | + addYangAugmentedOpParamInfoImport(imports); | ||
1616 | + } | ||
1617 | + JavaQualifiedTypeInfo qualifiedTypeInfo = new JavaQualifiedTypeInfo(); | ||
1618 | + qualifiedTypeInfo.setClassInfo(getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo() | ||
1619 | + .getJavaName())); | ||
1620 | + qualifiedTypeInfo.setPkgInfo(getJavaFileInfo().getPackage()); | ||
1621 | + getJavaExtendsListHolder().addToExtendsList(qualifiedTypeInfo, curNode, | ||
1622 | + tempJavaBeanFragmentFiles); | ||
1590 | addBitsetImport(imports, true); | 1623 | addBitsetImport(imports, true); |
1624 | + if (curNode instanceof YangAugment) { | ||
1625 | + addYangAugmentedOpParamInfoImport(imports); | ||
1626 | + } | ||
1591 | /* | 1627 | /* |
1592 | * Create impl class file. | 1628 | * Create impl class file. |
1593 | */ | 1629 | */ |
1594 | setOpParamClassJavaFileHandle(getJavaFileHandle(getOpParamImplClassName())); | 1630 | setOpParamClassJavaFileHandle(getJavaFileHandle(getOpParamImplClassName())); |
1595 | setOpParamClassJavaFileHandle( | 1631 | setOpParamClassJavaFileHandle( |
1596 | generateOpParamImplClassFile(getOpParamClassJavaFileHandle(), curNode, | 1632 | generateOpParamImplClassFile(getOpParamClassJavaFileHandle(), curNode, |
1597 | - isAttributePresent(), imports)); | 1633 | + isAttributePresent(), imports)); |
1598 | 1634 | ||
1599 | /* | 1635 | /* |
1600 | * Create builder class file. | 1636 | * Create builder class file. |
... | @@ -1603,7 +1639,7 @@ public class TempJavaFragmentFiles { | ... | @@ -1603,7 +1639,7 @@ public class TempJavaFragmentFiles { |
1603 | setBuilderOpParmClassJavaFileHandle(getJavaFileHandle(getOpParamBuilderImplClassName())); | 1639 | setBuilderOpParmClassJavaFileHandle(getJavaFileHandle(getOpParamBuilderImplClassName())); |
1604 | setBuilderOpParmClassJavaFileHandle( | 1640 | setBuilderOpParmClassJavaFileHandle( |
1605 | generateOpParamBuilderClassFile(getBuilderOpParmClassJavaFileHandle(), curNode, | 1641 | generateOpParamBuilderClassFile(getBuilderOpParmClassJavaFileHandle(), curNode, |
1606 | - isAttributePresent())); | 1642 | + isAttributePresent())); |
1607 | /* | 1643 | /* |
1608 | * Append impl class to builder class and close it. | 1644 | * Append impl class to builder class and close it. |
1609 | */ | 1645 | */ |
... | @@ -1613,6 +1649,7 @@ public class TempJavaFragmentFiles { | ... | @@ -1613,6 +1649,7 @@ public class TempJavaFragmentFiles { |
1613 | addBitsetImport(imports, false); | 1649 | addBitsetImport(imports, false); |
1614 | } | 1650 | } |
1615 | insertDataIntoJavaFile(getOpParamClassJavaFileHandle(), getJavaClassDefClose()); | 1651 | insertDataIntoJavaFile(getOpParamClassJavaFileHandle(), getJavaClassDefClose()); |
1652 | + | ||
1616 | } | 1653 | } |
1617 | } | 1654 | } |
1618 | /* | 1655 | /* |
... | @@ -1621,56 +1658,15 @@ public class TempJavaFragmentFiles { | ... | @@ -1621,56 +1658,15 @@ public class TempJavaFragmentFiles { |
1621 | freeTemporaryResources(false); | 1658 | freeTemporaryResources(false); |
1622 | } | 1659 | } |
1623 | 1660 | ||
1624 | - /** | 1661 | + /*Adds import for YANG augmented op param info.*/ |
1625 | - * Updates augment constructor temp file. | 1662 | + private void addYangAugmentedOpParamInfoImport(List<String> imports) { |
1626 | - * | 1663 | + imports.add(getJavaImportData().getYangAugmentedOpParamInfoImport()); |
1627 | - * @param curNode current augment node | ||
1628 | - * @param pluginConfig plugin configurations | ||
1629 | - * @throws IOException when fails to do IO operations | ||
1630 | - */ | ||
1631 | - private void updateAugmentConstructorTempFile(YangNode curNode, YangPluginConfig pluginConfig) | ||
1632 | - throws IOException { | ||
1633 | - YangJavaAugment augment = (YangJavaAugment) curNode; | ||
1634 | - | ||
1635 | - TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode) | ||
1636 | - .getTempJavaCodeFragmentFiles().getBeanTempFiles(); | ||
1637 | - YangNode augmentedNode = augment.getAugmentedNode(); | ||
1638 | - if (augmentedNode instanceof YangLeavesHolder) { | ||
1639 | - YangLeavesHolder holder = (YangLeavesHolder) augmentedNode; | ||
1640 | - if (holder.getListOfLeaf() != null) { | ||
1641 | - for (YangLeaf leaf : holder.getListOfLeaf()) { | ||
1642 | - addAugmentConstructor(getJavaAttributeOfLeaf(this, leaf, | ||
1643 | - pluginConfig), pluginConfig); | ||
1644 | - } | ||
1645 | - | ||
1646 | - } | ||
1647 | - if (holder.getListOfLeafList() != null) { | ||
1648 | - for (YangLeafList leafList : holder.getListOfLeafList()) { | ||
1649 | - addAugmentConstructor(getJavaAttributeOfLeafList(this, leafList, | ||
1650 | - pluginConfig), pluginConfig); | ||
1651 | - } | ||
1652 | - | ||
1653 | - } | ||
1654 | - } | ||
1655 | - augmentedNode = augmentedNode.getChild(); | ||
1656 | - boolean isList = false; | ||
1657 | - while (augmentedNode != null) { | ||
1658 | - if (augmentedNode instanceof YangList) { | ||
1659 | - isList = true; | ||
1660 | - } | ||
1661 | - if (!(augmentedNode instanceof YangUses)) { | ||
1662 | - addAugmentConstructor(getCurNodeAsAttributeInTarget(augmentedNode, augment, isList, | ||
1663 | - tempJavaBeanFragmentFiles), pluginConfig); | ||
1664 | - } | ||
1665 | - augmentedNode = augmentedNode.getNextSibling(); | ||
1666 | - } | ||
1667 | - | ||
1668 | } | 1664 | } |
1669 | 1665 | ||
1670 | /** | 1666 | /** |
1671 | * Adds imports for ToString and HashCodeMethod. | 1667 | * Adds imports for ToString and HashCodeMethod. |
1672 | * | 1668 | * |
1673 | - * @param imports import list | 1669 | + * @param imports import list |
1674 | * @param operation add or remove | 1670 | * @param operation add or remove |
1675 | */ | 1671 | */ |
1676 | public void addImportsToStringAndHasCodeMethods(List<String> imports, boolean operation) { | 1672 | public void addImportsToStringAndHasCodeMethods(List<String> imports, boolean operation) { |
... | @@ -1686,7 +1682,7 @@ public class TempJavaFragmentFiles { | ... | @@ -1686,7 +1682,7 @@ public class TempJavaFragmentFiles { |
1686 | /** | 1682 | /** |
1687 | * Adds imports for bitset method. | 1683 | * Adds imports for bitset method. |
1688 | * | 1684 | * |
1689 | - * @param imports import list | 1685 | + * @param imports import list |
1690 | * @param operation add or remove | 1686 | * @param operation add or remove |
1691 | */ | 1687 | */ |
1692 | public void addBitsetImport(List<String> imports, boolean operation) { | 1688 | public void addBitsetImport(List<String> imports, boolean operation) { |
... | @@ -1701,32 +1697,31 @@ public class TempJavaFragmentFiles { | ... | @@ -1701,32 +1697,31 @@ public class TempJavaFragmentFiles { |
1701 | /** | 1697 | /** |
1702 | * Adds import for map and hash map. | 1698 | * Adds import for map and hash map. |
1703 | * | 1699 | * |
1704 | - * @param imports import list | 1700 | + * @param imports import list |
1701 | + * @param operations true for adding and false for deletion | ||
1705 | */ | 1702 | */ |
1706 | - public void addImportsForAugmentableClass(List<String> imports) { | 1703 | + public void addImportsForAugmentableClass(List<String> imports, boolean operations) { |
1707 | - imports.add(getJavaImportData().getHashMapImport()); | 1704 | + if (operations) { |
1708 | - imports.add(getJavaImportData().getMapImport()); | 1705 | + imports.add(getJavaImportData().getHashMapImport()); |
1709 | - imports.add(getJavaImportData().getYangAugmentedInfoImport()); | 1706 | + imports.add(getJavaImportData().getMapImport()); |
1707 | + imports.add(getJavaImportData().getYangAugmentedInfoImport()); | ||
1708 | + } else { | ||
1709 | + imports.remove(getJavaImportData().getHashMapImport()); | ||
1710 | + imports.remove(getJavaImportData().getMapImport()); | ||
1711 | + } | ||
1710 | } | 1712 | } |
1711 | 1713 | ||
1712 | /** | 1714 | /** |
1713 | - * Removes augmented node import info from import list. | 1715 | + * Removes case import info from import list. |
1714 | * | 1716 | * |
1715 | * @param imports list of imports | 1717 | * @param imports list of imports |
1716 | * @return import for class | 1718 | * @return import for class |
1717 | */ | 1719 | */ |
1718 | - private List<String> removeAugmentedImport(List<String> imports, JavaQualifiedTypeInfo augmentedInfo) { | 1720 | + private List<String> removeCaseImport(List<String> imports) { |
1719 | - String augmentedNodeImport; | 1721 | + if (imports != null && caseImportInfo != null) { |
1720 | - if (imports != null && augmentedInfo != null) { | 1722 | + String caseImport = IMPORT + caseImportInfo.getPkgInfo() + PERIOD + caseImportInfo.getClassInfo() + |
1721 | - augmentedNodeImport = IMPORT + augmentedInfo.getPkgInfo() + PERIOD + getCapitalCase(DEFAULT) | 1723 | + SEMI_COLAN + NEW_LINE; |
1722 | - + augmentedInfo.getClassInfo() + PERIOD + augmentedInfo.getClassInfo() | 1724 | + imports.remove(caseImport); |
1723 | - + BUILDER + SEMI_COLAN + NEW_LINE; | ||
1724 | - imports.remove(augmentedNodeImport); | ||
1725 | - augmentedNodeImport = IMPORT + augmentedInfo.getPkgInfo() + PERIOD | ||
1726 | - + augmentedInfo.getClassInfo() + PERIOD + augmentedInfo.getClassInfo() | ||
1727 | - + BUILDER + SEMI_COLAN + NEW_LINE; | ||
1728 | - imports.remove(augmentedNodeImport); | ||
1729 | - imports.remove(getJavaImportData().getYangAugmentedInfoImport()); | ||
1730 | } | 1725 | } |
1731 | return imports; | 1726 | return imports; |
1732 | } | 1727 | } |
... | @@ -1737,13 +1732,15 @@ public class TempJavaFragmentFiles { | ... | @@ -1737,13 +1732,15 @@ public class TempJavaFragmentFiles { |
1737 | * @param imports list of imports | 1732 | * @param imports list of imports |
1738 | * @return import for class | 1733 | * @return import for class |
1739 | */ | 1734 | */ |
1740 | - private List<String> removeCaseImport(List<String> imports) { | 1735 | + private void removeAugmentedInfoImport(List<String> imports) { |
1741 | - if (imports != null && caseImportInfo != null) { | 1736 | + imports.remove(getJavaImportData().getYangAugmentedInfoImport()); |
1742 | - String caseImport = IMPORT + caseImportInfo.getPkgInfo() + PERIOD + caseImportInfo.getClassInfo() + | 1737 | + |
1743 | - SEMI_COLAN + NEW_LINE; | 1738 | + for (JavaQualifiedTypeInfo type : getJavaImportData().getImportSet()) { |
1744 | - imports.remove(caseImport); | 1739 | + if (type.getClassInfo().equals(YANG_AUGMENTED_INFO)) { |
1740 | + getJavaImportData().getImportSet().remove(type); | ||
1741 | + getJavaExtendsListHolder().getExtendsList().remove(type); | ||
1742 | + } | ||
1745 | } | 1743 | } |
1746 | - return imports; | ||
1747 | } | 1744 | } |
1748 | 1745 | ||
1749 | /** | 1746 | /** |
... | @@ -1827,7 +1824,7 @@ public class TempJavaFragmentFiles { | ... | @@ -1827,7 +1824,7 @@ public class TempJavaFragmentFiles { |
1827 | /** | 1824 | /** |
1828 | * Sets the java file handle for op param class file. | 1825 | * Sets the java file handle for op param class file. |
1829 | * | 1826 | * |
1830 | - * @param opParamClassJavaFileHandle java file handle | 1827 | + * @param opParamClassJavaFileHandle java file handle |
1831 | */ | 1828 | */ |
1832 | public void setOpParamClassJavaFileHandle(File opParamClassJavaFileHandle) { | 1829 | public void setOpParamClassJavaFileHandle(File opParamClassJavaFileHandle) { |
1833 | this.opParamClassJavaFileHandle = opParamClassJavaFileHandle; | 1830 | this.opParamClassJavaFileHandle = opParamClassJavaFileHandle; | ... | ... |
... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.translator.tojava; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.translator.tojava; |
18 | 18 | ||
19 | import java.io.File; | 19 | import java.io.File; |
20 | import java.io.IOException; | 20 | import java.io.IOException; |
21 | -import java.util.ArrayList; | ||
22 | import java.util.List; | 21 | import java.util.List; |
23 | 22 | ||
24 | import org.onosproject.yangutils.datamodel.YangNode; | 23 | import org.onosproject.yangutils.datamodel.YangNode; |
... | @@ -27,52 +26,26 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | ... | @@ -27,52 +26,26 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
27 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; | 26 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; |
28 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 27 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
29 | 28 | ||
30 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | ||
31 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | ||
32 | -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_ENUM_MASK; | ||
33 | -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_METHOD_MASK; | ||
34 | -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_ATTRIBUTE_MASK; | ||
35 | -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_GETTER_MASK; | ||
36 | -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_SETTER_MASK; | ||
37 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK; | 29 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK; |
38 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK; | 30 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK; |
39 | -import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; | ||
40 | -import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; | ||
41 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAnnotationsImports; | 31 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAnnotationsImports; |
42 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addListenersImport; | 32 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addListenersImport; |
43 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; | 33 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; |
44 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventFile; | ||
45 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventListenerFile; | ||
46 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventSubjectFile; | ||
47 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile; | 34 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile; |
48 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile; | 35 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile; |
49 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; | ||
50 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; | 36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
51 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; | ||
52 | -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; | ||
53 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; | 37 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; |
54 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; | 38 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; |
55 | -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; | ||
56 | -import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | ||
57 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
58 | -import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; | ||
59 | -import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | ||
60 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_REG; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_REG; |
61 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; |
62 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
63 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; |
64 | -import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | ||
65 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
66 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; | 45 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
67 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; | ||
68 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; | ||
69 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD; | ||
70 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc; | 46 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc; |
71 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
72 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; | 47 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; |
73 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
74 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 48 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
75 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | ||
76 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; | 49 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
77 | 50 | ||
78 | /** | 51 | /** |
... | @@ -83,10 +56,6 @@ public class TempJavaServiceFragmentFiles | ... | @@ -83,10 +56,6 @@ public class TempJavaServiceFragmentFiles |
83 | extends TempJavaFragmentFiles { | 56 | extends TempJavaFragmentFiles { |
84 | 57 | ||
85 | /** | 58 | /** |
86 | - * File name for generated class file for special type like union, typedef suffix. | ||
87 | - */ | ||
88 | - public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject"; | ||
89 | - /** | ||
90 | * File name for rpc method. | 59 | * File name for rpc method. |
91 | */ | 60 | */ |
92 | private static final String RPC_INTERFACE_FILE_NAME = "Rpc"; | 61 | private static final String RPC_INTERFACE_FILE_NAME = "Rpc"; |
... | @@ -97,69 +66,19 @@ public class TempJavaServiceFragmentFiles | ... | @@ -97,69 +66,19 @@ public class TempJavaServiceFragmentFiles |
97 | private static final String RPC_IMPL_FILE_NAME = "RpcImpl"; | 66 | private static final String RPC_IMPL_FILE_NAME = "RpcImpl"; |
98 | 67 | ||
99 | /** | 68 | /** |
100 | - * File name for event enum temp file. | 69 | + * File name for generated class file for service suffix. |
101 | - */ | ||
102 | - private static final String EVENT_ENUM_FILE_NAME = "EventEnum"; | ||
103 | - | ||
104 | - /** | ||
105 | - * File name for event method temp file. | ||
106 | - */ | ||
107 | - private static final String EVENT_METHOD_FILE_NAME = "EventMethod"; | ||
108 | - | ||
109 | - /** | ||
110 | - * File name for event subject attribute temp file. | ||
111 | - */ | ||
112 | - private static final String EVENT_SUBJECT_ATTRIBUTE_FILE_NAME = "EventSubjectAttribute"; | ||
113 | - | ||
114 | - /** | ||
115 | - * File name for event subject getter temp file. | ||
116 | - */ | ||
117 | - private static final String EVENT_SUBJECT_GETTER_FILE_NAME = "EventSubjectGetter"; | ||
118 | - | ||
119 | - /** | ||
120 | - * File name for event subject setter temp file. | ||
121 | - */ | ||
122 | - private static final String EVENT_SUBJECT_SETTER_FILE_NAME = "EventSubjectSetter"; | ||
123 | - | ||
124 | - /** | ||
125 | - * File name for generated class file for service | ||
126 | - * suffix. | ||
127 | */ | 70 | */ |
128 | private static final String SERVICE_FILE_NAME_SUFFIX = "Service"; | 71 | private static final String SERVICE_FILE_NAME_SUFFIX = "Service"; |
129 | 72 | ||
130 | /** | 73 | /** |
131 | - * File name for generated class file for manager | 74 | + * File name for generated class file for manager suffix. |
132 | - * suffix. | ||
133 | */ | 75 | */ |
134 | private static final String MANAGER_FILE_NAME_SUFFIX = "Manager"; | 76 | private static final String MANAGER_FILE_NAME_SUFFIX = "Manager"; |
135 | 77 | ||
136 | /** | 78 | /** |
137 | - * File name for generated class file for special type like union, typedef | 79 | + * Flag to set the manager files generation. |
138 | - * suffix. | ||
139 | - */ | ||
140 | - private static final String EVENT_FILE_NAME_SUFFIX = "Event"; | ||
141 | - | ||
142 | - /** | ||
143 | - * File name for generated class file for special type like union, typedef | ||
144 | - * suffix. | ||
145 | - */ | ||
146 | - private static final String EVENT_LISTENER_FILE_NAME_SUFFIX = "Listener"; | ||
147 | - private static final String JAVA_FILE_EXTENSION = ".java"; | ||
148 | - | ||
149 | - /** | ||
150 | - * Java file handle for event subject file. | ||
151 | */ | 80 | */ |
152 | - private File eventSubjectJavaFileHandle; | 81 | + boolean isManagerNeedToBeGenerated = false; |
153 | - | ||
154 | - /** | ||
155 | - * Java file handle for event listener file. | ||
156 | - */ | ||
157 | - private File eventListenerJavaFileHandle; | ||
158 | - | ||
159 | - /** | ||
160 | - * Java file handle for event file. | ||
161 | - */ | ||
162 | - private File eventJavaFileHandle; | ||
163 | 82 | ||
164 | /** | 83 | /** |
165 | * Temporary file handle for rpc interface. | 84 | * Temporary file handle for rpc interface. |
... | @@ -177,34 +96,14 @@ public class TempJavaServiceFragmentFiles | ... | @@ -177,34 +96,14 @@ public class TempJavaServiceFragmentFiles |
177 | private File serviceInterfaceJavaFileHandle; | 96 | private File serviceInterfaceJavaFileHandle; |
178 | 97 | ||
179 | /** | 98 | /** |
180 | - * Java file handle for manager impl file. | 99 | + * Path for serive file to be generated. |
181 | - */ | ||
182 | - private File managerJavaFileHandle; | ||
183 | - | ||
184 | - /** | ||
185 | - * Java file handle for event enum impl file. | ||
186 | - */ | ||
187 | - private File eventEnumTempFileHandle; | ||
188 | - | ||
189 | - /** | ||
190 | - * Java file handle for event method impl file. | ||
191 | */ | 100 | */ |
192 | - private File eventMethodTempFileHandle; | 101 | + private String serviceGenPath; |
193 | 102 | ||
194 | /** | 103 | /** |
195 | - * Java file handle for event subject attribute file. | 104 | + * Java file handle for manager impl file. |
196 | - */ | ||
197 | - private File eventSubjectAttributeTempFileHandle; | ||
198 | - | ||
199 | - /** | ||
200 | - * Java file handle for event subject getter impl file. | ||
201 | - */ | ||
202 | - private File eventSubjectGetterTempFileHandle; | ||
203 | - | ||
204 | - /** | ||
205 | - * Java file handle for event subject setter impl file. | ||
206 | */ | 105 | */ |
207 | - private File eventSubjectSetterTempFileHandle; | 106 | + private File managerJavaFileHandle; |
208 | 107 | ||
209 | /** | 108 | /** |
210 | * Creates an instance of temporary java code fragment. | 109 | * Creates an instance of temporary java code fragment. |
... | @@ -217,52 +116,15 @@ public class TempJavaServiceFragmentFiles | ... | @@ -217,52 +116,15 @@ public class TempJavaServiceFragmentFiles |
217 | setJavaExtendsListHolder(new JavaExtendsListHolder()); | 116 | setJavaExtendsListHolder(new JavaExtendsListHolder()); |
218 | setJavaImportData(new JavaImportData()); | 117 | setJavaImportData(new JavaImportData()); |
219 | setJavaFileInfo(javaFileInfo); | 118 | setJavaFileInfo(javaFileInfo); |
119 | + setBaseCodePath(getJavaFileInfo().getBaseCodeGenPath()); | ||
120 | + setServiceGenPath(getJavaFileInfo().getPluginConfig().getCodeGenDir()); | ||
220 | setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(), | 121 | setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(), |
221 | getJavaFileInfo().getPackageFilePath())); | 122 | getJavaFileInfo().getPackageFilePath())); |
222 | addGeneratedTempFile(RPC_INTERFACE_MASK); | 123 | addGeneratedTempFile(RPC_INTERFACE_MASK); |
223 | addGeneratedTempFile(RPC_IMPL_MASK); | 124 | addGeneratedTempFile(RPC_IMPL_MASK); |
224 | 125 | ||
225 | - addGeneratedTempFile(EVENT_ENUM_MASK); | ||
226 | - addGeneratedTempFile(EVENT_METHOD_MASK); | ||
227 | - addGeneratedTempFile(EVENT_SUBJECT_ATTRIBUTE_MASK); | ||
228 | - addGeneratedTempFile(EVENT_SUBJECT_GETTER_MASK); | ||
229 | - addGeneratedTempFile(EVENT_SUBJECT_SETTER_MASK); | ||
230 | - | ||
231 | setRpcInterfaceTempFileHandle(getTemporaryFileHandle(RPC_INTERFACE_FILE_NAME)); | 126 | setRpcInterfaceTempFileHandle(getTemporaryFileHandle(RPC_INTERFACE_FILE_NAME)); |
232 | setRpcImplTempFileHandle(getTemporaryFileHandle(RPC_IMPL_FILE_NAME)); | 127 | setRpcImplTempFileHandle(getTemporaryFileHandle(RPC_IMPL_FILE_NAME)); |
233 | - | ||
234 | - setEventEnumTempFileHandle(getTemporaryFileHandle(EVENT_ENUM_FILE_NAME)); | ||
235 | - setEventMethodTempFileHandle(getTemporaryFileHandle(EVENT_METHOD_FILE_NAME)); | ||
236 | - setEventSubjectAttributeTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_ATTRIBUTE_FILE_NAME)); | ||
237 | - setEventSubjectGetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_GETTER_FILE_NAME)); | ||
238 | - setEventSubjectSetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_SETTER_FILE_NAME)); | ||
239 | - } | ||
240 | - | ||
241 | - /*Adds event method contents to event file.*/ | ||
242 | - private static String getEventFileContents(String eventClassname, String classname) { | ||
243 | - return "\n" + | ||
244 | - " /**\n" + | ||
245 | - " * Creates " + classname + " event with type and subject.\n" + | ||
246 | - " *\n" + | ||
247 | - " * @param type event type\n" + | ||
248 | - " * @param subject subject " + classname + "\n" + | ||
249 | - " */\n" + | ||
250 | - " public " + eventClassname + "(Type type, " + getCapitalCase(classname) + " subject) {\n" + | ||
251 | - " super(type, subject);\n" + | ||
252 | - " }\n" + | ||
253 | - "\n" + | ||
254 | - " /**\n" + | ||
255 | - " * Creates " + classname + " event with type, subject and time.\n" + | ||
256 | - " *\n" + | ||
257 | - " * @param type event type\n" + | ||
258 | - " * @param subject subject " + classname + "\n" + | ||
259 | - " * @param time time of event\n" + | ||
260 | - " */\n" + | ||
261 | - " public " + eventClassname + "(Type type, " + getCapitalCase(classname) | ||
262 | - + " subject, long time) {\n" + | ||
263 | - " super(type, subject, time);\n" + | ||
264 | - " }\n" + | ||
265 | - "\n"; | ||
266 | } | 128 | } |
267 | 129 | ||
268 | /** | 130 | /** |
... | @@ -338,60 +200,6 @@ public class TempJavaServiceFragmentFiles | ... | @@ -338,60 +200,6 @@ public class TempJavaServiceFragmentFiles |
338 | } | 200 | } |
339 | 201 | ||
340 | /** | 202 | /** |
341 | - * Returns event's java file handle. | ||
342 | - * | ||
343 | - * @return java file handle | ||
344 | - */ | ||
345 | - private File getEventJavaFileHandle() { | ||
346 | - return eventJavaFileHandle; | ||
347 | - } | ||
348 | - | ||
349 | - /** | ||
350 | - * Sets event's java file handle. | ||
351 | - * | ||
352 | - * @param eventJavaFileHandle file handle for event | ||
353 | - */ | ||
354 | - private void setEventJavaFileHandle(File eventJavaFileHandle) { | ||
355 | - this.eventJavaFileHandle = eventJavaFileHandle; | ||
356 | - } | ||
357 | - | ||
358 | - /** | ||
359 | - * Returns event listeners's java file handle. | ||
360 | - * | ||
361 | - * @return java file handle | ||
362 | - */ | ||
363 | - private File getEventListenerJavaFileHandle() { | ||
364 | - return eventListenerJavaFileHandle; | ||
365 | - } | ||
366 | - | ||
367 | - /** | ||
368 | - * Sets event's java file handle. | ||
369 | - * | ||
370 | - * @param eventListenerJavaFileHandle file handle for event | ||
371 | - */ | ||
372 | - private void setEventListenerJavaFileHandle(File eventListenerJavaFileHandle) { | ||
373 | - this.eventListenerJavaFileHandle = eventListenerJavaFileHandle; | ||
374 | - } | ||
375 | - | ||
376 | - /** | ||
377 | - * Returns event subject's java file handle. | ||
378 | - * | ||
379 | - * @return java file handle | ||
380 | - */ | ||
381 | - private File getEventSubjectJavaFileHandle() { | ||
382 | - return eventSubjectJavaFileHandle; | ||
383 | - } | ||
384 | - | ||
385 | - /** | ||
386 | - * Sets event's subject java file handle. | ||
387 | - * | ||
388 | - * @param eventSubjectJavaFileHandle file handle for event's subject | ||
389 | - */ | ||
390 | - private void setEventSubjectJavaFileHandle(File eventSubjectJavaFileHandle) { | ||
391 | - this.eventSubjectJavaFileHandle = eventSubjectJavaFileHandle; | ||
392 | - } | ||
393 | - | ||
394 | - /** | ||
395 | * Constructs java code exit. | 203 | * Constructs java code exit. |
396 | * | 204 | * |
397 | * @param fileType generated file type | 205 | * @param fileType generated file type |
... | @@ -403,9 +211,7 @@ public class TempJavaServiceFragmentFiles | ... | @@ -403,9 +211,7 @@ public class TempJavaServiceFragmentFiles |
403 | throws IOException { | 211 | throws IOException { |
404 | List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() | 212 | List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() |
405 | .getJavaImportData().getImports(); | 213 | .getJavaImportData().getImports(); |
406 | - | ||
407 | createPackage(curNode); | 214 | createPackage(curNode); |
408 | - | ||
409 | boolean isNotification = false; | 215 | boolean isNotification = false; |
410 | if (curNode instanceof YangJavaModule) { | 216 | if (curNode instanceof YangJavaModule) { |
411 | if (!((YangJavaModule) curNode).getNotificationNodes().isEmpty()) { | 217 | if (!((YangJavaModule) curNode).getNotificationNodes().isEmpty()) { |
... | @@ -423,9 +229,10 @@ public class TempJavaServiceFragmentFiles | ... | @@ -423,9 +229,10 @@ public class TempJavaServiceFragmentFiles |
423 | /** | 229 | /** |
424 | * Creates rpc interface file. | 230 | * Creates rpc interface file. |
425 | */ | 231 | */ |
232 | + setBaseCodePath(getServiceGenPath()); | ||
426 | setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX))); | 233 | setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX))); |
427 | generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports); | 234 | generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports); |
428 | - | 235 | + setBaseCodePath(getJavaFileInfo().getBaseCodeGenPath()); |
429 | if (isNotification) { | 236 | if (isNotification) { |
430 | addListenersImport(curNode, imports, false, LISTENER_SERVICE); | 237 | addListenersImport(curNode, imports, false, LISTENER_SERVICE); |
431 | addListenersImport(curNode, imports, true, LISTENER_REG); | 238 | addListenersImport(curNode, imports, true, LISTENER_REG); |
... | @@ -434,21 +241,16 @@ public class TempJavaServiceFragmentFiles | ... | @@ -434,21 +241,16 @@ public class TempJavaServiceFragmentFiles |
434 | /** | 241 | /** |
435 | * Create builder class file. | 242 | * Create builder class file. |
436 | */ | 243 | */ |
437 | - setManagerJavaFileHandle(getJavaFileHandle(getJavaClassName(MANAGER_FILE_NAME_SUFFIX))); | 244 | + if (isManagerNeedToBeGenerated()) { |
438 | - generateManagerClassFile(getManagerJavaFileHandle(), imports, curNode); | 245 | + setManagerJavaFileHandle(getJavaFileHandle(getJavaClassName(MANAGER_FILE_NAME_SUFFIX))); |
439 | - | 246 | + generateManagerClassFile(getManagerJavaFileHandle(), imports, curNode); |
440 | - insertDataIntoJavaFile(getManagerJavaFileHandle(), getJavaClassDefClose()); | 247 | + insertDataIntoJavaFile(getManagerJavaFileHandle(), getJavaClassDefClose()); |
248 | + } | ||
441 | if (isNotification) { | 249 | if (isNotification) { |
442 | addListenersImport(curNode, imports, false, LISTENER_REG); | 250 | addListenersImport(curNode, imports, false, LISTENER_REG); |
443 | } | 251 | } |
444 | addAnnotationsImports(imports, false); | 252 | addAnnotationsImports(imports, false); |
445 | 253 | ||
446 | - if (isNotification) { | ||
447 | - generateEventJavaFile(curNode); | ||
448 | - generateEventListenerJavaFile(GENERATE_EVENT_LISTENER_INTERFACE, curNode); | ||
449 | - generateEventSubjectJavaFile(curNode); | ||
450 | - } | ||
451 | - | ||
452 | /** | 254 | /** |
453 | * Close all the file handles. | 255 | * Close all the file handles. |
454 | */ | 256 | */ |
... | @@ -504,87 +306,6 @@ public class TempJavaServiceFragmentFiles | ... | @@ -504,87 +306,6 @@ public class TempJavaServiceFragmentFiles |
504 | } | 306 | } |
505 | 307 | ||
506 | /** | 308 | /** |
507 | - * Constructs java code exit. | ||
508 | - * | ||
509 | - * @param curNode current YANG node | ||
510 | - * @throws IOException when fails to generate java files | ||
511 | - */ | ||
512 | - public void generateEventJavaFile(YangNode curNode) | ||
513 | - throws IOException { | ||
514 | - | ||
515 | - List<String> imports = new ArrayList<>(); | ||
516 | - | ||
517 | - imports.add(getJavaImportData().getAbstractEventsImport()); | ||
518 | - String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()); | ||
519 | - String nodeName = curNodeInfo + EVENT_STRING; | ||
520 | - | ||
521 | - addEnumMethod(nodeName, curNodeInfo + EVENT_SUBJECT_NAME_SUFFIX); | ||
522 | - | ||
523 | - /** | ||
524 | - * Creates event interface file. | ||
525 | - */ | ||
526 | - setEventJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + EVENT_FILE_NAME_SUFFIX)); | ||
527 | - generateEventFile(getEventJavaFileHandle(), curNode, imports); | ||
528 | - | ||
529 | - /** | ||
530 | - * Close all the file handles. | ||
531 | - */ | ||
532 | - freeTemporaryResources(false); | ||
533 | - } | ||
534 | - | ||
535 | - /** | ||
536 | - * Constructs java code exit. | ||
537 | - * | ||
538 | - * @param fileType generated file type | ||
539 | - * @param curNode current YANG node | ||
540 | - * @throws IOException when fails to generate java files | ||
541 | - */ | ||
542 | - public void generateEventListenerJavaFile(int fileType, YangNode curNode) | ||
543 | - throws IOException { | ||
544 | - | ||
545 | - List<String> imports = new ArrayList<>(); | ||
546 | - | ||
547 | - imports.add(getJavaImportData().getEventListenerImport()); | ||
548 | - String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) | ||
549 | - .getJavaFileInfo().getJavaName()); | ||
550 | - /** | ||
551 | - * Creates event listener interface file. | ||
552 | - */ | ||
553 | - setEventListenerJavaFileHandle( | ||
554 | - getJavaFileHandle(curNode, curNodeInfo + EVENT_LISTENER_FILE_NAME_SUFFIX)); | ||
555 | - generateEventListenerFile(getEventListenerJavaFileHandle(), curNode, imports); | ||
556 | - | ||
557 | - /** | ||
558 | - * Close all the file handles. | ||
559 | - */ | ||
560 | - freeTemporaryResources(false); | ||
561 | - } | ||
562 | - | ||
563 | - /** | ||
564 | - * Constructs java code exit. | ||
565 | - * | ||
566 | - * @param curNode current YANG node | ||
567 | - * @throws IOException when fails to generate java files | ||
568 | - */ | ||
569 | - public void generateEventSubjectJavaFile(YangNode curNode) | ||
570 | - throws IOException { | ||
571 | - | ||
572 | - String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) | ||
573 | - .getJavaFileInfo().getJavaName()); | ||
574 | - /** | ||
575 | - * Creates event interface file. | ||
576 | - */ | ||
577 | - setEventSubjectJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + | ||
578 | - EVENT_SUBJECT_NAME_SUFFIX)); | ||
579 | - generateEventSubjectFile(getEventSubjectJavaFileHandle(), curNode); | ||
580 | - | ||
581 | - /** | ||
582 | - * Close all the file handles. | ||
583 | - */ | ||
584 | - freeTemporaryResources(false); | ||
585 | - } | ||
586 | - | ||
587 | - /** | ||
588 | * Removes all temporary file handles. | 309 | * Removes all temporary file handles. |
589 | * | 310 | * |
590 | * @param isErrorOccurred when translator fails to generate java files we need to close all open file handles | 311 | * @param isErrorOccurred when translator fails to generate java files we need to close all open file handles |
... | @@ -599,16 +320,6 @@ public class TempJavaServiceFragmentFiles | ... | @@ -599,16 +320,6 @@ public class TempJavaServiceFragmentFiles |
599 | closeFile(getServiceInterfaceJavaFileHandle(), isError); | 320 | closeFile(getServiceInterfaceJavaFileHandle(), isError); |
600 | closeFile(getManagerJavaFileHandle(), isError); | 321 | closeFile(getManagerJavaFileHandle(), isError); |
601 | 322 | ||
602 | - if (getEventJavaFileHandle() != null) { | ||
603 | - closeFile(getEventJavaFileHandle(), isError); | ||
604 | - } | ||
605 | - if (getEventListenerJavaFileHandle() != null) { | ||
606 | - closeFile(getEventListenerJavaFileHandle(), isError); | ||
607 | - } | ||
608 | - if (getEventSubjectJavaFileHandle() != null) { | ||
609 | - closeFile(getEventSubjectJavaFileHandle(), isError); | ||
610 | - } | ||
611 | - | ||
612 | closeFile(getRpcInterfaceTempFileHandle(), true); | 323 | closeFile(getRpcInterfaceTempFileHandle(), true); |
613 | closeFile(getRpcImplTempFileHandle(), true); | 324 | closeFile(getRpcImplTempFileHandle(), true); |
614 | closeFile(getGetterInterfaceTempFileHandle(), true); | 325 | closeFile(getGetterInterfaceTempFileHandle(), true); |
... | @@ -620,182 +331,39 @@ public class TempJavaServiceFragmentFiles | ... | @@ -620,182 +331,39 @@ public class TempJavaServiceFragmentFiles |
620 | } | 331 | } |
621 | 332 | ||
622 | /** | 333 | /** |
623 | - * Returns event enum temp file. | 334 | + * Returns the path where service file should be generated. |
624 | - * | ||
625 | - * @return event enum temp file | ||
626 | - */ | ||
627 | - public File getEventEnumTempFileHandle() { | ||
628 | - return eventEnumTempFileHandle; | ||
629 | - } | ||
630 | - | ||
631 | - /** | ||
632 | - * Sets event enum temp file. | ||
633 | - * | ||
634 | - * @param eventEnumTempFileHandle event enum temp file | ||
635 | - */ | ||
636 | - public void setEventEnumTempFileHandle(File eventEnumTempFileHandle) { | ||
637 | - this.eventEnumTempFileHandle = eventEnumTempFileHandle; | ||
638 | - } | ||
639 | - | ||
640 | - /** | ||
641 | - * Returns event method temp file. | ||
642 | - * | ||
643 | - * @return event method temp file | ||
644 | - */ | ||
645 | - public File getEventMethodTempFileHandle() { | ||
646 | - return eventMethodTempFileHandle; | ||
647 | - } | ||
648 | - | ||
649 | - /** | ||
650 | - * Sets event method temp file. | ||
651 | - * | ||
652 | - * @param eventMethodTempFileHandle event method temp file | ||
653 | - */ | ||
654 | - public void setEventMethodTempFileHandle(File eventMethodTempFileHandle) { | ||
655 | - this.eventMethodTempFileHandle = eventMethodTempFileHandle; | ||
656 | - } | ||
657 | - | ||
658 | - /** | ||
659 | - * Returns event subject attribute temp file. | ||
660 | - * | ||
661 | - * @return event subject attribute temp file | ||
662 | - */ | ||
663 | - public File getEventSubjectAttributeTempFileHandle() { | ||
664 | - return eventSubjectAttributeTempFileHandle; | ||
665 | - } | ||
666 | - | ||
667 | - /** | ||
668 | - * Sets event subject attribute temp file. | ||
669 | * | 335 | * |
670 | - * @param eventSubjectAttributeTempFileHandle event subject attribute temp file | 336 | + * @return path where service file should be generated |
671 | */ | 337 | */ |
672 | - public void setEventSubjectAttributeTempFileHandle(File eventSubjectAttributeTempFileHandle) { | 338 | + public String getServiceGenPath() { |
673 | - this.eventSubjectAttributeTempFileHandle = eventSubjectAttributeTempFileHandle; | 339 | + return serviceGenPath; |
674 | } | 340 | } |
675 | 341 | ||
676 | /** | 342 | /** |
677 | - * Returns event subject getter temp file. | 343 | + * Sets path where service file should be generated. |
678 | * | 344 | * |
679 | - * @return event subject getter temp file | 345 | + * @param serviceGenPath path where service file should be generated |
680 | */ | 346 | */ |
681 | - public File getEventSubjectGetterTempFileHandle() { | 347 | + public void setServiceGenPath(String serviceGenPath) { |
682 | - return eventSubjectGetterTempFileHandle; | 348 | + this.serviceGenPath = serviceGenPath; |
683 | } | 349 | } |
684 | 350 | ||
685 | /** | 351 | /** |
686 | - * Sets event subject getter temp file. | 352 | + * Returns true if manager needs to be generated. |
687 | * | 353 | * |
688 | - * @param eventSubjectGetterTempFileHandle event subject getter temp file | 354 | + * @return true if manager needs to be generated |
689 | */ | 355 | */ |
690 | - public void setEventSubjectGetterTempFileHandle(File eventSubjectGetterTempFileHandle) { | 356 | + public boolean isManagerNeedToBeGenerated() { |
691 | - this.eventSubjectGetterTempFileHandle = eventSubjectGetterTempFileHandle; | 357 | + return isManagerNeedToBeGenerated; |
692 | - } | ||
693 | - | ||
694 | - /** | ||
695 | - * Returns event subject setter temp file. | ||
696 | - * | ||
697 | - * @return event subject setter temp file | ||
698 | - */ | ||
699 | - public File getEventSubjectSetterTempFileHandle() { | ||
700 | - return eventSubjectSetterTempFileHandle; | ||
701 | - } | ||
702 | - | ||
703 | - /** | ||
704 | - * Sets event subject setter temp file. | ||
705 | - * | ||
706 | - * @param eventSubjectSetterTempFileHandle event subject setter temp file | ||
707 | - */ | ||
708 | - public void setEventSubjectSetterTempFileHandle(File eventSubjectSetterTempFileHandle) { | ||
709 | - this.eventSubjectSetterTempFileHandle = eventSubjectSetterTempFileHandle; | ||
710 | - } | ||
711 | - | ||
712 | - /** | ||
713 | - * Adds java snippet for events to event subject file. | ||
714 | - * | ||
715 | - * @param curNode current node | ||
716 | - * @param pluginConfig plugin configurations | ||
717 | - * @throws IOException when fails to do IO operations | ||
718 | - */ | ||
719 | - public void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig) | ||
720 | - throws IOException { | ||
721 | - | ||
722 | - String currentInfo = getCapitalCase(getCamelCase(curNode.getName(), | ||
723 | - pluginConfig.getConflictResolver())); | ||
724 | - String notificationName = curNode.getName(); | ||
725 | - | ||
726 | - JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, | ||
727 | - getCapitalCase(currentInfo)); | ||
728 | - | ||
729 | - JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData(qualifiedTypeInfo, getSmallCase(currentInfo), | ||
730 | - null, false, false); | ||
731 | - | ||
732 | - /*Adds java info for event in respective temp files.*/ | ||
733 | - addEventEnum(notificationName, pluginConfig); | ||
734 | - addEventSubjectAttribute(javaAttributeInfo, pluginConfig); | ||
735 | - addEventSubjectGetter(javaAttributeInfo, pluginConfig); | ||
736 | - addEventSubjectSetter(javaAttributeInfo, pluginConfig, currentInfo); | ||
737 | - } | ||
738 | - | ||
739 | - /*Adds event to enum temp file.*/ | ||
740 | - private void addEventEnum(String notificationName, YangPluginConfig pluginConfig) | ||
741 | - throws IOException { | ||
742 | - appendToFile(getEventEnumTempFileHandle(), | ||
743 | - getJavaDoc(ENUM_ATTRIBUTE, notificationName, false, pluginConfig) + FOUR_SPACE_INDENTATION | ||
744 | - + getEnumJavaAttribute(notificationName).toUpperCase() + COMMA + NEW_LINE); | ||
745 | - } | ||
746 | - | ||
747 | - /*Adds event method in event class*/ | ||
748 | - private void addEnumMethod(String eventClassname, String className) | ||
749 | - throws IOException { | ||
750 | - appendToFile(getEventMethodTempFileHandle(), getEventFileContents(eventClassname, className)); | ||
751 | - } | ||
752 | - | ||
753 | - /*Adds events to event subject file.*/ | ||
754 | - private void addEventSubjectAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) | ||
755 | - throws IOException { | ||
756 | - appendToFile(getEventSubjectAttributeTempFileHandle(), | ||
757 | - FOUR_SPACE_INDENTATION + parseAttribute(attr, pluginConfig)); | ||
758 | - } | ||
759 | - | ||
760 | - /*Adds getter method for event in event subject class.*/ | ||
761 | - private void addEventSubjectGetter(JavaAttributeInfo attr, YangPluginConfig pluginConfig) | ||
762 | - throws IOException { | ||
763 | - appendToFile(getEventSubjectGetterTempFileHandle(), | ||
764 | - getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) | ||
765 | - + getGetterForClass(attr, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE); | ||
766 | - } | ||
767 | - | ||
768 | - /*Adds setter method for event in event subject class.*/ | ||
769 | - private void addEventSubjectSetter(JavaAttributeInfo attr, YangPluginConfig pluginConfig, String className) | ||
770 | - throws IOException { | ||
771 | - appendToFile(getEventSubjectSetterTempFileHandle(), | ||
772 | - getJavaDoc(MANAGER_SETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) | ||
773 | - + getSetterForClass(attr, className, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE); | ||
774 | } | 358 | } |
775 | 359 | ||
776 | /** | 360 | /** |
777 | - * Returns a temporary file handle for the event's file type. | 361 | + * Sets true if manager needs to be generated. |
778 | * | 362 | * |
779 | - * @param name file name | 363 | + * @param managerNeedToBeGenerated true if manager needs to be generated |
780 | - * @return temporary file handle | ||
781 | - * @throws IOException when fails to create new file handle | ||
782 | */ | 364 | */ |
783 | - private File getJavaFileHandle(YangNode curNode, String name) | 365 | + public void setManagerNeedToBeGenerated(boolean managerNeedToBeGenerated) { |
784 | - throws IOException { | 366 | + isManagerNeedToBeGenerated = managerNeedToBeGenerated; |
785 | - | ||
786 | - JavaFileInfo parentInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | ||
787 | - JavaFileInfo childInfo = ((JavaFileInfoContainer) curNode.getChild()).getJavaFileInfo(); | ||
788 | - | ||
789 | - return getFileObject(getDirPath(parentInfo), name, JAVA_FILE_EXTENSION, | ||
790 | - childInfo); | ||
791 | } | 367 | } |
792 | 368 | ||
793 | - /** | ||
794 | - * Returns the directory path. | ||
795 | - * | ||
796 | - * @return directory path | ||
797 | - */ | ||
798 | - private String getDirPath(JavaFileInfo parentInfo) { | ||
799 | - return (parentInfo.getPackageFilePath() + SLASH + parentInfo.getJavaName()).toLowerCase(); | ||
800 | - } | ||
801 | } | 369 | } | ... | ... |
... | @@ -22,14 +22,15 @@ import java.util.ArrayList; | ... | @@ -22,14 +22,15 @@ import java.util.ArrayList; |
22 | import java.util.List; | 22 | import java.util.List; |
23 | 23 | ||
24 | import org.onosproject.yangutils.datamodel.RpcNotificationContainer; | 24 | import org.onosproject.yangutils.datamodel.RpcNotificationContainer; |
25 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
25 | import org.onosproject.yangutils.datamodel.YangCase; | 26 | import org.onosproject.yangutils.datamodel.YangCase; |
26 | import org.onosproject.yangutils.datamodel.YangChoice; | 27 | import org.onosproject.yangutils.datamodel.YangChoice; |
27 | -import org.onosproject.yangutils.datamodel.YangGrouping; | ||
28 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 28 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
29 | import org.onosproject.yangutils.datamodel.YangModule; | 29 | import org.onosproject.yangutils.datamodel.YangModule; |
30 | import org.onosproject.yangutils.datamodel.YangNode; | 30 | import org.onosproject.yangutils.datamodel.YangNode; |
31 | +import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
31 | import org.onosproject.yangutils.datamodel.YangSubModule; | 32 | import org.onosproject.yangutils.datamodel.YangSubModule; |
32 | -import org.onosproject.yangutils.datamodel.YangTypeDef; | 33 | +import org.onosproject.yangutils.datamodel.YangTranslatorOperatorNode; |
33 | import org.onosproject.yangutils.datamodel.YangTypeHolder; | 34 | import org.onosproject.yangutils.datamodel.YangTypeHolder; |
34 | import org.onosproject.yangutils.datamodel.utils.DataModelUtils; | 35 | import org.onosproject.yangutils.datamodel.utils.DataModelUtils; |
35 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 36 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
... | @@ -40,17 +41,12 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | ... | @@ -40,17 +41,12 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
40 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 41 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
41 | 42 | ||
42 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.isRpcChildNodePresent; | 43 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.isRpcChildNodePresent; |
43 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | ||
44 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | ||
45 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | ||
46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
47 | import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile; | 45 | import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile; |
48 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 46 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
49 | -import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | 47 | +import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED; |
50 | -import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | ||
51 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; | 48 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; |
52 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 49 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
53 | -import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; | ||
54 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; | 50 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; |
55 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG; | 51 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG; |
56 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | 52 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
... | @@ -80,7 +76,8 @@ public final class YangJavaModelUtils { | ... | @@ -80,7 +76,8 @@ public final class YangJavaModelUtils { |
80 | throws IOException { | 76 | throws IOException { |
81 | if (javaCodeGeneratorInfo instanceof YangJavaAugment) { | 77 | if (javaCodeGeneratorInfo instanceof YangJavaAugment) { |
82 | javaCodeGeneratorInfo.getJavaFileInfo() | 78 | javaCodeGeneratorInfo.getJavaFileInfo() |
83 | - .setJavaName(((YangJavaAugment) javaCodeGeneratorInfo).getAugmentClassName()); | 79 | + .setJavaName(getAugmentClassName((YangJavaAugment) javaCodeGeneratorInfo, |
80 | + yangPluginConfig)); | ||
84 | } else { | 81 | } else { |
85 | javaCodeGeneratorInfo.getJavaFileInfo() | 82 | javaCodeGeneratorInfo.getJavaFileInfo() |
86 | .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), | 83 | .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), |
... | @@ -192,7 +189,7 @@ public final class YangJavaModelUtils { | ... | @@ -192,7 +189,7 @@ public final class YangJavaModelUtils { |
192 | * @throws IOException IO operations fails | 189 | * @throws IOException IO operations fails |
193 | */ | 190 | */ |
194 | private static void generateTempFiles(JavaCodeGeneratorInfo javaCodeGeneratorInfo, | 191 | private static void generateTempFiles(JavaCodeGeneratorInfo javaCodeGeneratorInfo, |
195 | - YangPluginConfig yangPluginConfig) | 192 | + YangPluginConfig yangPluginConfig) |
196 | throws IOException { | 193 | throws IOException { |
197 | if (!(javaCodeGeneratorInfo instanceof YangNode)) { | 194 | if (!(javaCodeGeneratorInfo instanceof YangNode)) { |
198 | throw new TranslatorException("translation is not supported for the node"); | 195 | throw new TranslatorException("translation is not supported for the node"); |
... | @@ -215,7 +212,7 @@ public final class YangJavaModelUtils { | ... | @@ -215,7 +212,7 @@ public final class YangJavaModelUtils { |
215 | if (javaCodeGeneratorInfo instanceof YangJavaModule) { | 212 | if (javaCodeGeneratorInfo instanceof YangJavaModule) { |
216 | for (YangNode notificaiton : ((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes()) { | 213 | for (YangNode notificaiton : ((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes()) { |
217 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() | 214 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() |
218 | - .getServiceTempFiles() | 215 | + .getEventFragmentFiles() |
219 | .addJavaSnippetOfEvent(notificaiton, yangPluginConfig); | 216 | .addJavaSnippetOfEvent(notificaiton, yangPluginConfig); |
220 | } | 217 | } |
221 | } | 218 | } |
... | @@ -223,7 +220,7 @@ public final class YangJavaModelUtils { | ... | @@ -223,7 +220,7 @@ public final class YangJavaModelUtils { |
223 | for (YangNode notificaiton : ((YangJavaSubModule) javaCodeGeneratorInfo) | 220 | for (YangNode notificaiton : ((YangJavaSubModule) javaCodeGeneratorInfo) |
224 | .getNotificationNodes()) { | 221 | .getNotificationNodes()) { |
225 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() | 222 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() |
226 | - .getServiceTempFiles() | 223 | + .getEventFragmentFiles() |
227 | .addJavaSnippetOfEvent(notificaiton, yangPluginConfig); | 224 | .addJavaSnippetOfEvent(notificaiton, yangPluginConfig); |
228 | } | 225 | } |
229 | } | 226 | } |
... | @@ -273,57 +270,13 @@ public final class YangJavaModelUtils { | ... | @@ -273,57 +270,13 @@ public final class YangJavaModelUtils { |
273 | TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles(); | 270 | TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles(); |
274 | if (javaCodeGeneratorInfo instanceof YangJavaAugment) { | 271 | if (javaCodeGeneratorInfo instanceof YangJavaAugment) { |
275 | 272 | ||
276 | - JavaQualifiedTypeInfo augmentedBuilderInfo = new JavaQualifiedTypeInfo(); | ||
277 | - JavaQualifiedTypeInfo augmentedBuilderClassInfo = new JavaQualifiedTypeInfo(); | ||
278 | - JavaQualifiedTypeInfo augmentedClassInfo = new JavaQualifiedTypeInfo(); | ||
279 | - JavaQualifiedTypeInfo augmentedImplInfo = new JavaQualifiedTypeInfo(); | ||
280 | - YangNode augmentedNode = ((YangJavaAugment) javaCodeGeneratorInfo).getAugmentedNode(); | ||
281 | - String name = null; | ||
282 | - JavaFileInfo augmentedfileInfo = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo(); | ||
283 | - if (augmentedfileInfo.getJavaName() != null) { | ||
284 | - name = getCapitalCase(augmentedfileInfo.getJavaName()); | ||
285 | - augmentedClassInfo.setClassInfo(name); | ||
286 | - augmentedClassInfo.setPkgInfo(augmentedfileInfo.getPackage()); | ||
287 | - } else { | ||
288 | - name = getCapitalCase(getCamelCase(augmentedNode.getName(), yangPlugin.getConflictResolver())); | ||
289 | - augmentedClassInfo.setClassInfo(name); | ||
290 | - augmentedClassInfo.setPkgInfo(getAugmentedNodesPackage(augmentedNode, | ||
291 | - yangPlugin)); | ||
292 | - } | ||
293 | - | ||
294 | - augmentedBuilderInfo.setClassInfo(name + PERIOD + name + BUILDER); | ||
295 | - augmentedBuilderInfo.setPkgInfo(augmentedClassInfo.getPkgInfo()); | ||
296 | - augmentedBuilderClassInfo.setClassInfo(getCapitalCase(DEFAULT) + name + PERIOD + name + BUILDER); | ||
297 | - augmentedBuilderClassInfo.setPkgInfo(augmentedClassInfo.getPkgInfo()); | ||
298 | - augmentedImplInfo.setClassInfo(getCapitalCase(DEFAULT) + name); | ||
299 | - augmentedImplInfo.setPkgInfo(augmentedBuilderInfo.getPkgInfo()); | ||
300 | - ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedBuilderInfo); | ||
301 | - ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedImplInfo); | ||
302 | - ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedBuilderClassInfo); | ||
303 | - ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedClassInfo); | ||
304 | - javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() | ||
305 | - .addToExtendsList(augmentedClassInfo, (YangNode) javaCodeGeneratorInfo, | ||
306 | - tempJavaCodeFragmentFiles.getBeanTempFiles()); | ||
307 | - javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() | ||
308 | - .addToExtendsList(augmentedBuilderInfo, (YangNode) javaCodeGeneratorInfo, | ||
309 | - tempJavaCodeFragmentFiles.getBeanTempFiles()); | ||
310 | - javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() | ||
311 | - .addToExtendsList(augmentedImplInfo, (YangNode) javaCodeGeneratorInfo, | ||
312 | - tempJavaCodeFragmentFiles.getBeanTempFiles()); | ||
313 | - javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() | ||
314 | - .addToExtendsList(augmentedBuilderClassInfo, (YangNode) javaCodeGeneratorInfo, | ||
315 | - tempJavaCodeFragmentFiles.getBeanTempFiles()); | ||
316 | - | ||
317 | JavaQualifiedTypeInfo yangAugmentedInfo = new JavaQualifiedTypeInfo(); | 273 | JavaQualifiedTypeInfo yangAugmentedInfo = new JavaQualifiedTypeInfo(); |
318 | yangAugmentedInfo.setClassInfo(YANG_AUGMENTED_INFO); | 274 | yangAugmentedInfo.setClassInfo(YANG_AUGMENTED_INFO); |
319 | yangAugmentedInfo.setPkgInfo(YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG); | 275 | yangAugmentedInfo.setPkgInfo(YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG); |
320 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() | 276 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() |
321 | .addToExtendsList(yangAugmentedInfo, (YangNode) javaCodeGeneratorInfo, | 277 | .addToExtendsList(yangAugmentedInfo, (YangNode) javaCodeGeneratorInfo, |
322 | tempJavaCodeFragmentFiles.getBeanTempFiles()); | 278 | tempJavaCodeFragmentFiles.getBeanTempFiles()); |
323 | - | ||
324 | - | ||
325 | } | 279 | } |
326 | - | ||
327 | if (javaCodeGeneratorInfo instanceof YangCase) { | 280 | if (javaCodeGeneratorInfo instanceof YangCase) { |
328 | YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent(); | 281 | YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent(); |
329 | JavaQualifiedTypeInfo parentsInfo = new JavaQualifiedTypeInfo(); | 282 | JavaQualifiedTypeInfo parentsInfo = new JavaQualifiedTypeInfo(); |
... | @@ -378,27 +331,9 @@ public final class YangJavaModelUtils { | ... | @@ -378,27 +331,9 @@ public final class YangJavaModelUtils { |
378 | javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_SERVICE_AND_MANAGER); | 331 | javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_SERVICE_AND_MANAGER); |
379 | } | 332 | } |
380 | 333 | ||
381 | - if (javaCodeGeneratorInfo instanceof YangJavaModule) { | ||
382 | - if (!((YangJavaModule) javaCodeGeneratorInfo) | ||
383 | - .isNotificationChildNodePresent((YangNode) javaCodeGeneratorInfo)) { | ||
384 | - updateCodeGenInfoForEvent(javaCodeGeneratorInfo); | ||
385 | - } | ||
386 | - } else if (javaCodeGeneratorInfo instanceof YangJavaSubModule) { | ||
387 | - if (!((YangJavaSubModule) javaCodeGeneratorInfo) | ||
388 | - .isNotificationChildNodePresent((YangNode) javaCodeGeneratorInfo)) { | ||
389 | - updateCodeGenInfoForEvent(javaCodeGeneratorInfo); | ||
390 | - } | ||
391 | - } | ||
392 | generateTempFiles(javaCodeGeneratorInfo, yangPluginConfig); | 334 | generateTempFiles(javaCodeGeneratorInfo, yangPluginConfig); |
393 | } | 335 | } |
394 | 336 | ||
395 | - /*Updates java code generator info with events info.*/ | ||
396 | - private static void updateCodeGenInfoForEvent(JavaCodeGeneratorInfo javaCodeGeneratorInfo) { | ||
397 | - javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_EVENT_SUBJECT_CLASS); | ||
398 | - javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_EVENT_CLASS); | ||
399 | - javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_EVENT_LISTENER_INTERFACE); | ||
400 | - } | ||
401 | - | ||
402 | /** | 337 | /** |
403 | * Returns the node package string. | 338 | * Returns the node package string. |
404 | * | 339 | * |
... | @@ -429,9 +364,6 @@ public final class YangJavaModelUtils { | ... | @@ -429,9 +364,6 @@ public final class YangJavaModelUtils { |
429 | * @return true if root node contains any data node | 364 | * @return true if root node contains any data node |
430 | */ | 365 | */ |
431 | public static boolean isManagerCodeGenRequired(YangNode node) { | 366 | public static boolean isManagerCodeGenRequired(YangNode node) { |
432 | - YangLeavesHolder holder = (YangLeavesHolder) node; | ||
433 | - | ||
434 | - boolean isCodeReq = true; | ||
435 | 367 | ||
436 | List<YangNode> childNodes = new ArrayList<>(); | 368 | List<YangNode> childNodes = new ArrayList<>(); |
437 | node = node.getChild(); | 369 | node = node.getChild(); |
... | @@ -441,16 +373,19 @@ public final class YangJavaModelUtils { | ... | @@ -441,16 +373,19 @@ public final class YangJavaModelUtils { |
441 | } | 373 | } |
442 | 374 | ||
443 | if (childNodes.size() == 0) { | 375 | if (childNodes.size() == 0) { |
444 | - if (holder.getListOfLeaf() != null && !holder.getListOfLeaf().isEmpty()) { | 376 | + return false; |
445 | - isCodeReq = true; | ||
446 | - } else if (holder.getListOfLeafList() != null && !holder.getListOfLeafList().isEmpty()) { | ||
447 | - isCodeReq = true; | ||
448 | - } | ||
449 | - return isCodeReq; | ||
450 | } else if (childNodes.size() == 1) { | 377 | } else if (childNodes.size() == 1) { |
451 | - return childNodes.get(0) instanceof YangTypeDef && childNodes.get(0) instanceof YangGrouping; | 378 | + return !(childNodes.get(0) instanceof YangTranslatorOperatorNode); |
379 | + } | ||
380 | + List<Boolean> booleanData = new ArrayList<>(); | ||
381 | + for (YangNode child : childNodes) { | ||
382 | + if (child instanceof YangTranslatorOperatorNode) { | ||
383 | + booleanData.add(false); | ||
384 | + } else { | ||
385 | + booleanData.add(true); | ||
386 | + } | ||
452 | } | 387 | } |
453 | - return isCodeReq; | 388 | + return booleanData.contains(true); |
454 | } | 389 | } |
455 | 390 | ||
456 | /** | 391 | /** |
... | @@ -465,8 +400,7 @@ public final class YangJavaModelUtils { | ... | @@ -465,8 +400,7 @@ public final class YangJavaModelUtils { |
465 | File[] files = codeGenDir.listFiles(); | 400 | File[] files = codeGenDir.listFiles(); |
466 | if (files.length >= 1) { | 401 | if (files.length >= 1) { |
467 | for (File file : files) { | 402 | for (File file : files) { |
468 | - if (file.getName().contentEquals(getCapitalCase(info.getJavaName() + MANAGER + ".java")) | 403 | + if (file.getName().contentEquals(getCapitalCase(info.getJavaName() + MANAGER + ".java"))) { |
469 | - || file.getName().contentEquals(getCapitalCase(info.getJavaName() + SERVICE + ".java"))) { | ||
470 | return false; | 404 | return false; |
471 | } | 405 | } |
472 | } | 406 | } |
... | @@ -484,12 +418,11 @@ public final class YangJavaModelUtils { | ... | @@ -484,12 +418,11 @@ public final class YangJavaModelUtils { |
484 | public static String getAugmentedNodesPackage(YangNode node, YangPluginConfig yangPluginConfig) { | 418 | public static String getAugmentedNodesPackage(YangNode node, YangPluginConfig yangPluginConfig) { |
485 | 419 | ||
486 | List<String> clsInfo = new ArrayList<>(); | 420 | List<String> clsInfo = new ArrayList<>(); |
487 | - node = node.getParent(); | 421 | + while (node.getParent() != null) { |
488 | - while (node != null) { | ||
489 | if (!(node instanceof YangModule) | 422 | if (!(node instanceof YangModule) |
490 | || !(node instanceof YangSubModule)) { | 423 | || !(node instanceof YangSubModule)) { |
491 | if (node instanceof YangJavaAugment) { | 424 | if (node instanceof YangJavaAugment) { |
492 | - clsInfo.add(((YangJavaAugment) node).getAugmentClassName()); | 425 | + clsInfo.add(getAugmentClassName((YangAugment) node, yangPluginConfig)); |
493 | } else { | 426 | } else { |
494 | clsInfo.add(getCamelCase(node.getName(), yangPluginConfig.getConflictResolver())); | 427 | clsInfo.add(getCamelCase(node.getName(), yangPluginConfig.getConflictResolver())); |
495 | } | 428 | } |
... | @@ -519,4 +452,21 @@ public final class YangJavaModelUtils { | ... | @@ -519,4 +452,21 @@ public final class YangJavaModelUtils { |
519 | return pkg.toString().toLowerCase(); | 452 | return pkg.toString().toLowerCase(); |
520 | 453 | ||
521 | } | 454 | } |
455 | + | ||
456 | + /** | ||
457 | + * Returns augment class name. | ||
458 | + * | ||
459 | + * @param augment YANG augment | ||
460 | + * @param yangPluginConfig plugin configurations | ||
461 | + * @return augment class name | ||
462 | + */ | ||
463 | + public static String getAugmentClassName(YangAugment augment, YangPluginConfig yangPluginConfig) { | ||
464 | + YangNodeIdentifier nodeId = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier(); | ||
465 | + String name = getCapitalCase(getCamelCase(nodeId.getName(), yangPluginConfig.getConflictResolver())); | ||
466 | + if (nodeId.getPrefix() != null) { | ||
467 | + return AUGMENTED + getCapitalCase(nodeId.getPrefix()) + name; | ||
468 | + } else { | ||
469 | + return AUGMENTED + name; | ||
470 | + } | ||
471 | + } | ||
522 | } | 472 | } | ... | ... |
... | @@ -16,23 +16,17 @@ | ... | @@ -16,23 +16,17 @@ |
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 | -import java.util.ArrayList; | ||
20 | -import java.util.List; | ||
21 | 19 | ||
22 | import org.onosproject.yangutils.datamodel.YangAugment; | 20 | import org.onosproject.yangutils.datamodel.YangAugment; |
23 | -import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
24 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
25 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
26 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; |
27 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
28 | -import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | ||
29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
30 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 26 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
31 | 27 | ||
32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
33 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode; | 29 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode; |
34 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
35 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
36 | 30 | ||
37 | /** | 31 | /** |
38 | * Represents augment information extended to support java code generation. | 32 | * Represents augment information extended to support java code generation. |
... | @@ -44,23 +38,12 @@ public class YangJavaAugment | ... | @@ -44,23 +38,12 @@ public class YangJavaAugment |
44 | private static final long serialVersionUID = 806201632L; | 38 | private static final long serialVersionUID = 806201632L; |
45 | 39 | ||
46 | /** | 40 | /** |
47 | - * Prefix to be added to generated java file for augment node. | ||
48 | - */ | ||
49 | - private static final String AUGMENTED = "Augmented"; | ||
50 | - | ||
51 | - /** | ||
52 | * Contains the information of the java file being generated. | 41 | * Contains the information of the java file being generated. |
53 | */ | 42 | */ |
54 | private JavaFileInfo javaFileInfo; | 43 | private JavaFileInfo javaFileInfo; |
55 | 44 | ||
56 | /** | 45 | /** |
57 | - * TargetNodes java qualified info. | 46 | + * File handle to maintain temporary java code fragments as per the code snippet types. |
58 | - */ | ||
59 | - private List<JavaQualifiedTypeInfo> extendedClassInfo; | ||
60 | - | ||
61 | - /** | ||
62 | - * File handle to maintain temporary java code fragments as per the code | ||
63 | - * snippet types. | ||
64 | */ | 47 | */ |
65 | private transient TempJavaCodeFragmentFiles tempFileHandle; | 48 | private transient TempJavaCodeFragmentFiles tempFileHandle; |
66 | 49 | ||
... | @@ -70,7 +53,6 @@ public class YangJavaAugment | ... | @@ -70,7 +53,6 @@ public class YangJavaAugment |
70 | public YangJavaAugment() { | 53 | public YangJavaAugment() { |
71 | super(); | 54 | super(); |
72 | setJavaFileInfo(new JavaFileInfo()); | 55 | setJavaFileInfo(new JavaFileInfo()); |
73 | - setExtendedClassInfo(new ArrayList<>()); | ||
74 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 56 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
75 | } | 57 | } |
76 | 58 | ||
... | @@ -119,8 +101,7 @@ public class YangJavaAugment | ... | @@ -119,8 +101,7 @@ public class YangJavaAugment |
119 | } | 101 | } |
120 | 102 | ||
121 | /** | 103 | /** |
122 | - * Prepare the information for java code generation corresponding to YANG | 104 | + * Prepare the information for java code generation corresponding to YANG augment info. |
123 | - * augment info. | ||
124 | * | 105 | * |
125 | * @param yangPlugin YANG plugin config | 106 | * @param yangPlugin YANG plugin config |
126 | * @throws TranslatorException translator operation fail | 107 | * @throws TranslatorException translator operation fail |
... | @@ -148,46 +129,4 @@ public class YangJavaAugment | ... | @@ -148,46 +129,4 @@ public class YangJavaAugment |
148 | } | 129 | } |
149 | } | 130 | } |
150 | 131 | ||
151 | - /** | ||
152 | - * Returns augment class name. | ||
153 | - * | ||
154 | - * @return augment class name | ||
155 | - */ | ||
156 | - public String getAugmentClassName() { | ||
157 | - YangNodeIdentifier nodeId = getTargetNode().get(getTargetNode().size() - 1).getNodeIdentifier(); | ||
158 | - String name = getCapitalCase(getCamelCase(nodeId.getName(), null)); | ||
159 | - if (nodeId.getPrefix() != null) { | ||
160 | - return AUGMENTED + getCapitalCase(nodeId.getPrefix()) + name; | ||
161 | - } else { | ||
162 | - return AUGMENTED + name; | ||
163 | - } | ||
164 | - } | ||
165 | - | ||
166 | - /** | ||
167 | - * Returns extended class info. | ||
168 | - * | ||
169 | - * @return extended class info | ||
170 | - */ | ||
171 | - public List<JavaQualifiedTypeInfo> getExtendedClassInfo() { | ||
172 | - return extendedClassInfo; | ||
173 | - } | ||
174 | - | ||
175 | - /** | ||
176 | - * Sets extended class info. | ||
177 | - * | ||
178 | - * @param augmentedInfo extended class info | ||
179 | - */ | ||
180 | - private void setExtendedClassInfo(List<JavaQualifiedTypeInfo> augmentedInfo) { | ||
181 | - extendedClassInfo = augmentedInfo; | ||
182 | - } | ||
183 | - | ||
184 | - /** | ||
185 | - * Adds to extended class info list. | ||
186 | - * | ||
187 | - * @param augmentedInfo extended class info | ||
188 | - */ | ||
189 | - public void addToExtendedClassInfo(JavaQualifiedTypeInfo augmentedInfo) { | ||
190 | - getExtendedClassInfo().add(augmentedInfo); | ||
191 | - } | ||
192 | - | ||
193 | } | 132 | } | ... | ... |
... | @@ -15,6 +15,10 @@ | ... | @@ -15,6 +15,10 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | +import java.io.File; | ||
19 | +import java.io.IOException; | ||
20 | +import java.util.List; | ||
21 | + | ||
18 | import org.onosproject.yangutils.datamodel.YangIdentity; | 22 | import org.onosproject.yangutils.datamodel.YangIdentity; |
19 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
20 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 24 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
... | @@ -25,12 +29,8 @@ import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | ... | @@ -25,12 +29,8 @@ import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 30 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
27 | 31 | ||
28 | -import java.io.File; | ||
29 | -import java.io.IOException; | ||
30 | -import java.util.List; | ||
31 | - | ||
32 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | ||
33 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; |
33 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | ||
34 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.updatePackageInfo; | 34 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.updatePackageInfo; |
35 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; | 35 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; | 36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; |
... | @@ -145,7 +145,7 @@ public class YangJavaIdentity extends YangIdentity | ... | @@ -145,7 +145,7 @@ public class YangJavaIdentity extends YangIdentity |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | - File file = getFileObject(path, className, JAVA_FILE_EXTENSION, getJavaFileInfo()); | 148 | + File file = getFileObject(path, className, JAVA_FILE_EXTENSION, getJavaFileInfo().getBaseCodeGenPath()); |
149 | 149 | ||
150 | initiateJavaFileGeneration(file, GENERATE_IDENTITY_CLASS, imports, this, className); | 150 | initiateJavaFileGeneration(file, GENERATE_IDENTITY_CLASS, imports, this, className); |
151 | closeFile(file, false); | 151 | closeFile(file, false); | ... | ... |
... | @@ -29,14 +29,12 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ... | @@ -29,14 +29,12 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
30 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 30 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
31 | 31 | ||
32 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | 32 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ALL_EVENT_CLASS_MASK; |
33 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | ||
34 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | ||
35 | 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; |
36 | 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; |
37 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode; | 35 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode; |
38 | -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired; | ||
39 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; | 36 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; |
37 | +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired; | ||
40 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 38 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
41 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; | 39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; |
42 | import static org.onosproject.yangutils.utils.UtilConstants.SBI; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.SBI; |
... | @@ -56,8 +54,7 @@ public class YangJavaModule | ... | @@ -56,8 +54,7 @@ public class YangJavaModule |
56 | private JavaFileInfo javaFileInfo; | 54 | private JavaFileInfo javaFileInfo; |
57 | 55 | ||
58 | /** | 56 | /** |
59 | - * File handle to maintain temporary java code fragments as per the code | 57 | + * File handle to maintain temporary java code fragments as per the code snippet types. |
60 | - * snippet types. | ||
61 | */ | 58 | */ |
62 | private transient TempJavaCodeFragmentFiles tempFileHandle; | 59 | private transient TempJavaCodeFragmentFiles tempFileHandle; |
63 | 60 | ||
... | @@ -73,12 +70,7 @@ public class YangJavaModule | ... | @@ -73,12 +70,7 @@ public class YangJavaModule |
73 | super(); | 70 | super(); |
74 | setJavaFileInfo(new JavaFileInfo()); | 71 | setJavaFileInfo(new JavaFileInfo()); |
75 | setNotificationNodes(new ArrayList<>()); | 72 | setNotificationNodes(new ArrayList<>()); |
76 | - int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER; | 73 | + getJavaFileInfo().setGeneratedFileTypes(GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER); |
77 | - if (isNotificationChildNodePresent(this)) { | ||
78 | - gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_EVENT_SUBJECT_CLASS | GENERATE_EVENT_CLASS | ||
79 | - | GENERATE_EVENT_LISTENER_INTERFACE; | ||
80 | - } | ||
81 | - getJavaFileInfo().setGeneratedFileTypes(gentype); | ||
82 | 74 | ||
83 | } | 75 | } |
84 | 76 | ||
... | @@ -135,6 +127,11 @@ public class YangJavaModule | ... | @@ -135,6 +127,11 @@ public class YangJavaModule |
135 | public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { | 127 | public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { |
136 | String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate(), | 128 | String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate(), |
137 | yangPlugin.getConflictResolver()); | 129 | yangPlugin.getConflictResolver()); |
130 | + | ||
131 | + if (isNotificationChildNodePresent(this)) { | ||
132 | + getJavaFileInfo().setGeneratedFileTypes(getJavaFileInfo().getGeneratedFileTypes() | ||
133 | + | GENERATE_ALL_EVENT_CLASS_MASK); | ||
134 | + } | ||
138 | try { | 135 | try { |
139 | generateCodeOfRootNode(this, yangPlugin, modulePkg); | 136 | generateCodeOfRootNode(this, yangPlugin, modulePkg); |
140 | } catch (IOException e) { | 137 | } catch (IOException e) { |
... | @@ -157,17 +154,22 @@ public class YangJavaModule | ... | @@ -157,17 +154,22 @@ public class YangJavaModule |
157 | * | 154 | * |
158 | * The manager class needs to extend the "ListenerRegistry". | 155 | * The manager class needs to extend the "ListenerRegistry". |
159 | */ | 156 | */ |
160 | - | ||
161 | try { | 157 | try { |
162 | - if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { | 158 | + if ((getJavaFileInfo().getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) { |
163 | - if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null) || | 159 | + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, this); |
164 | - (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) { | 160 | + } |
165 | - getTempJavaCodeFragmentFiles() | 161 | + getTempJavaCodeFragmentFiles() |
166 | - .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | 162 | + .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); |
167 | - getTempJavaCodeFragmentFiles() | 163 | + if (isManagerCodeGenRequired(this)) { |
168 | - .generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); | 164 | + if (isGenerationOfCodeReq(getJavaFileInfo())) { |
165 | + if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null) | ||
166 | + || (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) { | ||
167 | + getTempJavaCodeFragmentFiles().getServiceTempFiles().setManagerNeedToBeGenerated(true); | ||
168 | + } | ||
169 | } | 169 | } |
170 | } | 170 | } |
171 | + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); | ||
172 | + | ||
171 | searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + | 173 | searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + |
172 | getJavaFileInfo().getPackageFilePath()); | 174 | getJavaFileInfo().getPackageFilePath()); |
173 | searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() + | 175 | searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() + | ... | ... |
... | @@ -31,14 +31,12 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ... | @@ -31,14 +31,12 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
31 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 31 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
32 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 32 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
33 | 33 | ||
34 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | 34 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ALL_EVENT_CLASS_MASK; |
35 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | ||
36 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | ||
37 | 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; |
38 | 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; |
39 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode; | 37 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode; |
40 | -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired; | ||
41 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; | 38 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; |
39 | +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired; | ||
42 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 40 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
43 | import static org.onosproject.yangutils.utils.UtilConstants.SBI; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.SBI; |
44 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; | 42 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; |
... | @@ -58,8 +56,7 @@ public class YangJavaSubModule | ... | @@ -58,8 +56,7 @@ public class YangJavaSubModule |
58 | private JavaFileInfo javaFileInfo; | 56 | private JavaFileInfo javaFileInfo; |
59 | 57 | ||
60 | /** | 58 | /** |
61 | - * File handle to maintain temporary java code fragments as per the code | 59 | + * File handle to maintain temporary java code fragments as per the code snippet types. |
62 | - * snippet types. | ||
63 | */ | 60 | */ |
64 | private transient TempJavaCodeFragmentFiles tempFileHandle; | 61 | private transient TempJavaCodeFragmentFiles tempFileHandle; |
65 | 62 | ||
... | @@ -76,8 +73,7 @@ public class YangJavaSubModule | ... | @@ -76,8 +73,7 @@ public class YangJavaSubModule |
76 | setJavaFileInfo(new JavaFileInfo()); | 73 | setJavaFileInfo(new JavaFileInfo()); |
77 | int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER; | 74 | int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER; |
78 | if (isNotificationChildNodePresent(this)) { | 75 | if (isNotificationChildNodePresent(this)) { |
79 | - gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_EVENT_SUBJECT_CLASS | GENERATE_EVENT_CLASS | 76 | + gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_ALL_EVENT_CLASS_MASK; |
80 | - | GENERATE_EVENT_LISTENER_INTERFACE; | ||
81 | } | 77 | } |
82 | getJavaFileInfo().setGeneratedFileTypes(gentype); | 78 | getJavaFileInfo().setGeneratedFileTypes(gentype); |
83 | } | 79 | } |
... | @@ -145,6 +141,11 @@ public class YangJavaSubModule | ... | @@ -145,6 +141,11 @@ public class YangJavaSubModule |
145 | public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { | 141 | public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { |
146 | String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()), | 142 | String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()), |
147 | getRevision().getRevDate(), yangPlugin.getConflictResolver()); | 143 | getRevision().getRevDate(), yangPlugin.getConflictResolver()); |
144 | + | ||
145 | + if (isNotificationChildNodePresent(this)) { | ||
146 | + getJavaFileInfo().setGeneratedFileTypes(getJavaFileInfo().getGeneratedFileTypes() | ||
147 | + | GENERATE_ALL_EVENT_CLASS_MASK); | ||
148 | + } | ||
148 | try { | 149 | try { |
149 | generateCodeOfRootNode(this, yangPlugin, subModulePkg); | 150 | generateCodeOfRootNode(this, yangPlugin, subModulePkg); |
150 | } catch (IOException e) { | 151 | } catch (IOException e) { |
... | @@ -169,13 +170,21 @@ public class YangJavaSubModule | ... | @@ -169,13 +170,21 @@ public class YangJavaSubModule |
169 | * The manager class needs to extend the "ListenerRegistry". | 170 | * The manager class needs to extend the "ListenerRegistry". |
170 | */ | 171 | */ |
171 | try { | 172 | try { |
172 | - if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { | 173 | + if ((getJavaFileInfo().getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) { |
173 | - if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null) || | 174 | + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, this); |
174 | - (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) { | 175 | + } |
175 | - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | 176 | + getTempJavaCodeFragmentFiles() |
176 | - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); | 177 | + .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); |
178 | + if (isManagerCodeGenRequired(this)) { | ||
179 | + if (isGenerationOfCodeReq(getJavaFileInfo())) { | ||
180 | + if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null) | ||
181 | + || (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) { | ||
182 | + getTempJavaCodeFragmentFiles().getServiceTempFiles().setManagerNeedToBeGenerated(true); | ||
183 | + } | ||
177 | } | 184 | } |
178 | } | 185 | } |
186 | + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); | ||
187 | + | ||
179 | searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + | 188 | searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + |
180 | getJavaFileInfo().getPackageFilePath()); | 189 | getJavaFileInfo().getPackageFilePath()); |
181 | searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() + | 190 | searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() + |
... | @@ -185,6 +194,7 @@ public class YangJavaSubModule | ... | @@ -185,6 +194,7 @@ public class YangJavaSubModule |
185 | } | 194 | } |
186 | } | 195 | } |
187 | 196 | ||
197 | + | ||
188 | /** | 198 | /** |
189 | * Returns notifications node list. | 199 | * Returns notifications node list. |
190 | * | 200 | * | ... | ... |
... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
17 | package org.onosproject.yangutils.translator.tojava.utils; | 17 | package org.onosproject.yangutils.translator.tojava.utils; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.YangAugment; | 19 | import org.onosproject.yangutils.datamodel.YangAugment; |
20 | +import org.onosproject.yangutils.datamodel.YangCase; | ||
20 | import org.onosproject.yangutils.datamodel.YangIdentity; | 21 | import org.onosproject.yangutils.datamodel.YangIdentity; |
21 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
22 | import org.onosproject.yangutils.datamodel.YangNotification; | 23 | import org.onosproject.yangutils.datamodel.YangNotification; |
... | @@ -45,7 +46,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | ... | @@ -45,7 +46,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
45 | import static org.onosproject.yangutils.utils.UtilConstants.CLASS; | 46 | import static org.onosproject.yangutils.utils.UtilConstants.CLASS; |
46 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | 47 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
47 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | 48 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; |
48 | -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; | ||
49 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; | 49 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; |
50 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; | 50 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; |
51 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; | 51 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; |
... | @@ -61,12 +61,14 @@ import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; | ... | @@ -61,12 +61,14 @@ import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; |
61 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; | 61 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; |
62 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 62 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
63 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; | 63 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; |
64 | +import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; | ||
64 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 65 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
65 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; | 66 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; |
66 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE; | 67 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE; |
67 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; | 68 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
68 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 69 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
69 | import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT; | 70 | import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT; |
71 | +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO; | ||
70 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 72 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
71 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 73 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
72 | 74 | ||
... | @@ -82,8 +84,7 @@ public final class ClassDefinitionGenerator { | ... | @@ -82,8 +84,7 @@ public final class ClassDefinitionGenerator { |
82 | } | 84 | } |
83 | 85 | ||
84 | /** | 86 | /** |
85 | - * Based on the file type and the YANG name of the file, generate the class | 87 | + * Based on the file type and the YANG name of the file, generate the class / interface definition start. |
86 | - * / interface definition start. | ||
87 | * | 88 | * |
88 | * @param genFileTypes generated file type | 89 | * @param genFileTypes generated file type |
89 | * @param yangName class name | 90 | * @param yangName class name |
... | @@ -107,8 +108,7 @@ public final class ClassDefinitionGenerator { | ... | @@ -107,8 +108,7 @@ public final class ClassDefinitionGenerator { |
107 | } | 108 | } |
108 | 109 | ||
109 | /** | 110 | /** |
110 | - * Based on the file type and the YANG name of the file, generate the class | 111 | + * Based on the file type and the YANG name of the file, generate the class / interface definition start. |
111 | - * / interface definition start. | ||
112 | * | 112 | * |
113 | * @param genFileTypes generated file type | 113 | * @param genFileTypes generated file type |
114 | * @param yangName class name | 114 | * @param yangName class name |
... | @@ -131,7 +131,7 @@ public final class ClassDefinitionGenerator { | ... | @@ -131,7 +131,7 @@ public final class ClassDefinitionGenerator { |
131 | case IMPL_CLASS_MASK: | 131 | case IMPL_CLASS_MASK: |
132 | return getImplClassDefinition(yangName, curNode); | 132 | return getImplClassDefinition(yangName, curNode); |
133 | case OPERATION_CLASS_MASK: | 133 | case OPERATION_CLASS_MASK: |
134 | - return getOperClassDefinition(yangName, curNode); | 134 | + return getOpPramImplClassDefinition(yangName, curNode); |
135 | case BUILDER_INTERFACE_MASK: | 135 | case BUILDER_INTERFACE_MASK: |
136 | return getBuilderInterfaceDefinition(yangName, curNode); | 136 | return getBuilderInterfaceDefinition(yangName, curNode); |
137 | case GENERATE_SERVICE_AND_MANAGER: | 137 | case GENERATE_SERVICE_AND_MANAGER: |
... | @@ -178,14 +178,12 @@ public final class ClassDefinitionGenerator { | ... | @@ -178,14 +178,12 @@ public final class ClassDefinitionGenerator { |
178 | /** | 178 | /** |
179 | * Returns builder interface file class definition. | 179 | * Returns builder interface file class definition. |
180 | * | 180 | * |
181 | - * @param yangName java class name, corresponding to which the builder class | 181 | + * @param yangName java class name, corresponding to which the builder class is being generated |
182 | - * is being generated | ||
183 | * @return definition | 182 | * @return definition |
184 | */ | 183 | */ |
185 | private static String getBuilderInterfaceDefinition(String yangName, YangNode curNode) { | 184 | private static String getBuilderInterfaceDefinition(String yangName, YangNode curNode) { |
186 | - String clsDef = ""; | 185 | + if (!(curNode instanceof YangCase)) { |
187 | - if (curNode instanceof YangAugment) { | 186 | + String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, BUILDER_INTERFACE_MASK); |
188 | - clsDef = getClassDefinitionForWhenExtended(curNode, yangName, BUILDER_INTERFACE_MASK); | ||
189 | if (clsDef != null) { | 187 | if (clsDef != null) { |
190 | return clsDef; | 188 | return clsDef; |
191 | } | 189 | } |
... | @@ -200,9 +198,8 @@ public final class ClassDefinitionGenerator { | ... | @@ -200,9 +198,8 @@ public final class ClassDefinitionGenerator { |
200 | * @return definition | 198 | * @return definition |
201 | */ | 199 | */ |
202 | private static String getBuilderClassDefinition(String yangName, YangNode curNode) { | 200 | private static String getBuilderClassDefinition(String yangName, YangNode curNode) { |
203 | - String clsDef = ""; | 201 | + if (!(curNode instanceof YangCase)) { |
204 | - if (curNode instanceof YangAugment) { | 202 | + String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, BUILDER_CLASS_MASK); |
205 | - clsDef = getClassDefinitionForWhenExtended(curNode, yangName, BUILDER_CLASS_MASK); | ||
206 | if (clsDef != null) { | 203 | if (clsDef != null) { |
207 | return clsDef; | 204 | return clsDef; |
208 | } | 205 | } |
... | @@ -215,15 +212,14 @@ public final class ClassDefinitionGenerator { | ... | @@ -215,15 +212,14 @@ public final class ClassDefinitionGenerator { |
215 | * Returns operation param builder file class definition. | 212 | * Returns operation param builder file class definition. |
216 | * | 213 | * |
217 | * @param yangName class name | 214 | * @param yangName class name |
218 | - * @param curNode YANG node | 215 | + * @param curNode YANG node |
219 | * @return definition returns operation param builder file class definition | 216 | * @return definition returns operation param builder file class definition |
220 | */ | 217 | */ |
221 | private static String getOpParamBuilderClassDefinition(String yangName, YangNode curNode) { | 218 | private static String getOpParamBuilderClassDefinition(String yangName, YangNode curNode) { |
222 | - String clsDef = ""; | 219 | + if (!(curNode instanceof YangCase)) { |
223 | - if (curNode instanceof YangAugment) { | 220 | + String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, OPERATION_BUILDER_CLASS_MASK); |
224 | - clsDef = getClassDefinitionForWhenExtended(curNode, yangName, OPERATION_BUILDER_CLASS_MASK); | ||
225 | if (clsDef != null) { | 221 | if (clsDef != null) { |
226 | - return clsDef; | 222 | + return clsDef + OPEN_CURLY_BRACKET + NEW_LINE; |
227 | } | 223 | } |
228 | } | 224 | } |
229 | return PUBLIC + SPACE + CLASS + SPACE + yangName + OPERATION + BUILDER + SPACE + EXTEND + | 225 | return PUBLIC + SPACE + CLASS + SPACE + yangName + OPERATION + BUILDER + SPACE + EXTEND + |
... | @@ -238,9 +234,8 @@ public final class ClassDefinitionGenerator { | ... | @@ -238,9 +234,8 @@ public final class ClassDefinitionGenerator { |
238 | * @return definition | 234 | * @return definition |
239 | */ | 235 | */ |
240 | private static String getImplClassDefinition(String yangName, YangNode curNode) { | 236 | private static String getImplClassDefinition(String yangName, YangNode curNode) { |
241 | - String clsDef = ""; | 237 | + if (!(curNode instanceof YangCase)) { |
242 | - if (curNode instanceof YangAugment) { | 238 | + String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, IMPL_CLASS_MASK); |
243 | - clsDef = getClassDefinitionForWhenExtended(curNode, yangName, IMPL_CLASS_MASK); | ||
244 | if (clsDef != null) { | 239 | if (clsDef != null) { |
245 | return clsDef; | 240 | return clsDef; |
246 | } | 241 | } |
... | @@ -253,20 +248,26 @@ public final class ClassDefinitionGenerator { | ... | @@ -253,20 +248,26 @@ public final class ClassDefinitionGenerator { |
253 | * Returns operation param file class definition. | 248 | * Returns operation param file class definition. |
254 | * | 249 | * |
255 | * @param yangName class name | 250 | * @param yangName class name |
256 | - * @param curNode YANG node | 251 | + * @param curNode YANG node |
257 | * @return definition returns operation param file class definition | 252 | * @return definition returns operation param file class definition |
258 | */ | 253 | */ |
259 | - private static String getOperClassDefinition(String yangName, YangNode curNode) { | 254 | + private static String getOpPramImplClassDefinition(String yangName, YangNode curNode) { |
260 | String clsDef = ""; | 255 | String clsDef = ""; |
261 | - if (curNode instanceof YangAugment) { | 256 | + if (!(curNode instanceof YangCase)) { |
262 | clsDef = getClassDefinitionForWhenExtended(curNode, yangName, OPERATION_CLASS_MASK); | 257 | clsDef = getClassDefinitionForWhenExtended(curNode, yangName, OPERATION_CLASS_MASK); |
263 | - if (clsDef != null) { | ||
264 | - return clsDef; | ||
265 | - } | ||
266 | } | 258 | } |
267 | 259 | ||
268 | - return PUBLIC + SPACE + CLASS + SPACE + yangName + OPERATION + SPACE + EXTEND + SPACE | 260 | + if (clsDef.equals("")) { |
269 | - + getCapitalCase(DEFAULT) + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 261 | + clsDef = PUBLIC + SPACE + CLASS + SPACE + yangName + OPERATION + SPACE + EXTEND + SPACE |
262 | + + getCapitalCase(DEFAULT) + yangName + SPACE; | ||
263 | + } | ||
264 | + if (curNode instanceof YangAugment) { | ||
265 | + clsDef = clsDef + IMPLEMENTS + SPACE + YANG_AUGMENTED_OP_PARAM_INFO + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | ||
266 | + } else { | ||
267 | + clsDef = clsDef + OPEN_CURLY_BRACKET + NEW_LINE; | ||
268 | + } | ||
269 | + | ||
270 | + return clsDef; | ||
270 | } | 271 | } |
271 | 272 | ||
272 | /** | 273 | /** |
... | @@ -407,72 +408,28 @@ public final class ClassDefinitionGenerator { | ... | @@ -407,72 +408,28 @@ public final class ClassDefinitionGenerator { |
407 | switch (genFileTypes) { | 408 | switch (genFileTypes) { |
408 | case INTERFACE_MASK: | 409 | case INTERFACE_MASK: |
409 | def = def + INTERFACE + SPACE + yangName + SPACE + EXTEND + SPACE; | 410 | def = def + INTERFACE + SPACE + yangName + SPACE + EXTEND + SPACE; |
410 | - for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | 411 | + def = getDefinitionString(def, holder); |
411 | - if (curNode instanceof YangAugment) { | ||
412 | - if (!info.getClassInfo().contains(BUILDER) && !info.getClassInfo().contains( | ||
413 | - getCapitalCase(DEFAULT))) { | ||
414 | - def = getDefinitionString(def, info, holder); | ||
415 | - } | ||
416 | - } else { | ||
417 | - def = getDefinitionString(def, info, holder); | ||
418 | - } | ||
419 | - } | ||
420 | - def = trimAtLast(def, COMMA); | ||
421 | - | ||
422 | return def + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 412 | return def + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
423 | case BUILDER_INTERFACE_MASK: | 413 | case BUILDER_INTERFACE_MASK: |
424 | String builderDef = INTERFACE + SPACE + yangName + BUILDER + SPACE + EXTEND + SPACE; | 414 | String builderDef = INTERFACE + SPACE + yangName + BUILDER + SPACE + EXTEND + SPACE; |
425 | - for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | 415 | + builderDef = getDefinitionString(builderDef, holder); |
426 | - if (info.getClassInfo().contains(BUILDER) && !info.getClassInfo().contains( | ||
427 | - getCapitalCase(DEFAULT))) { | ||
428 | - builderDef = getDefinitionString(builderDef, info, holder); | ||
429 | - } | ||
430 | - } | ||
431 | - | ||
432 | - builderDef = trimAtLast(builderDef, COMMA); | ||
433 | - | ||
434 | return builderDef + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 416 | return builderDef + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
435 | case BUILDER_CLASS_MASK: | 417 | case BUILDER_CLASS_MASK: |
436 | def = def + CLASS + SPACE + yangName + BUILDER + SPACE + EXTEND + SPACE; | 418 | def = def + CLASS + SPACE + yangName + BUILDER + SPACE + EXTEND + SPACE; |
437 | - for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | 419 | + def = getDefinitionString(def, holder); |
438 | - if (info.getClassInfo().contains(BUILDER) | ||
439 | - && info.getClassInfo().contains(getCapitalCase(DEFAULT))) { | ||
440 | - def = getDefinitionString(def, info, holder); | ||
441 | - } | ||
442 | - } | ||
443 | - | ||
444 | - def = trimAtLast(def, COMMA); | ||
445 | - | ||
446 | return def + SPACE + IMPLEMENTS + SPACE + yangName + PERIOD | 420 | return def + SPACE + IMPLEMENTS + SPACE + yangName + PERIOD |
447 | + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 421 | + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
448 | 422 | ||
449 | case IMPL_CLASS_MASK: | 423 | case IMPL_CLASS_MASK: |
450 | def = def + SPACE + CLASS + SPACE + getCapitalCase(DEFAULT) + yangName + SPACE + EXTEND + SPACE; | 424 | def = def + SPACE + CLASS + SPACE + getCapitalCase(DEFAULT) + yangName + SPACE + EXTEND + SPACE; |
451 | - for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | 425 | + def = getDefinitionString(def, holder); |
452 | - if (!info.getClassInfo().contains(BUILDER) | ||
453 | - && info.getClassInfo().contains(getCapitalCase(DEFAULT))) { | ||
454 | - def = getDefinitionString(def, info, holder); | ||
455 | - } | ||
456 | - } | ||
457 | - | ||
458 | - def = trimAtLast(def, COMMA); | ||
459 | - | ||
460 | return def + SPACE + IMPLEMENTS + SPACE | 426 | return def + SPACE + IMPLEMENTS + SPACE |
461 | + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 427 | + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
462 | 428 | ||
463 | case OPERATION_CLASS_MASK: | 429 | case OPERATION_CLASS_MASK: |
464 | - def = def + SPACE + CLASS + SPACE + yangName + OPERATION + SPACE; | 430 | + def = def + CLASS + SPACE + yangName + OPERATION + SPACE + EXTEND + SPACE; |
465 | - for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | 431 | + def = getDefinitionString(def, holder); |
466 | - if (!info.getClassInfo().contains(BUILDER) | 432 | + return def + SPACE; |
467 | - && info.getClassInfo().contains(OPERATION)) { | ||
468 | - def = getDefinitionString(def, info, holder); | ||
469 | - } | ||
470 | - } | ||
471 | - | ||
472 | - def = trimAtLast(def, COMMA); | ||
473 | - | ||
474 | - return def + SPACE + EXTEND + SPACE | ||
475 | - + getCapitalCase(DEFAULT) + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | ||
476 | default: | 433 | default: |
477 | return null; | 434 | return null; |
478 | } | 435 | } |
... | @@ -484,17 +441,18 @@ public final class ClassDefinitionGenerator { | ... | @@ -484,17 +441,18 @@ public final class ClassDefinitionGenerator { |
484 | * Returns updated class definition. | 441 | * Returns updated class definition. |
485 | * | 442 | * |
486 | * @param def current definition | 443 | * @param def current definition |
487 | - * @param info java qualified info | ||
488 | * @param holder extend list holder | 444 | * @param holder extend list holder |
489 | * @return updated class definition | 445 | * @return updated class definition |
490 | */ | 446 | */ |
491 | - private static String getDefinitionString(String def, JavaQualifiedTypeInfo info, JavaExtendsListHolder holder) { | 447 | + private static String getDefinitionString(String def, JavaExtendsListHolder holder) { |
492 | - if (!holder.getExtendedClassStore().get(info)) { | 448 | + for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { |
493 | - def = def + info.getClassInfo() + COMMA + SPACE; | 449 | + if (!holder.getExtendedClassStore().get(info)) { |
494 | - } else { | 450 | + def = def + info.getClassInfo() + COMMA + SPACE; |
495 | - def = def + info.getPkgInfo() + PERIOD + info.getClassInfo() + COMMA + SPACE; | 451 | + } else { |
452 | + def = def + info.getPkgInfo() + PERIOD + info.getClassInfo() + COMMA + SPACE; | ||
453 | + } | ||
496 | } | 454 | } |
497 | - return def; | 455 | + return trimAtLast(def, COMMA); |
498 | } | 456 | } |
499 | 457 | ||
500 | } | 458 | } | ... | ... |
... | @@ -95,8 +95,7 @@ public final class JavaCodeSnippetGen { | ... | @@ -95,8 +95,7 @@ public final class JavaCodeSnippetGen { |
95 | * Returns the textual java code information corresponding to the import list. | 95 | * Returns the textual java code information corresponding to the import list. |
96 | * | 96 | * |
97 | * @param importInfo import info | 97 | * @param importInfo import info |
98 | - * @return the textual java code information corresponding to the import | 98 | + * @return the textual java code information corresponding to the import list |
99 | - * list | ||
100 | */ | 99 | */ |
101 | public static String getImportText(JavaQualifiedTypeInfo importInfo) { | 100 | public static String getImportText(JavaQualifiedTypeInfo importInfo) { |
102 | return IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN + NEW_LINE; | 101 | return IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN + NEW_LINE; |
... | @@ -147,8 +146,7 @@ public final class JavaCodeSnippetGen { | ... | @@ -147,8 +146,7 @@ public final class JavaCodeSnippetGen { |
147 | } | 146 | } |
148 | 147 | ||
149 | /** | 148 | /** |
150 | - * Returns based on the file type and the YANG name of the file, generate the class | 149 | + * Returns based on the file type and the YANG name of the file, generate the class / interface definition close. |
151 | - * / interface definition close. | ||
152 | * | 150 | * |
153 | * @return corresponding textual java code information | 151 | * @return corresponding textual java code information |
154 | */ | 152 | */ | ... | ... |
... | @@ -31,8 +31,8 @@ import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; | ... | @@ -31,8 +31,8 @@ import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; |
31 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 31 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | - * Represent the extends list for generated java classes. It holds the class details which needs | 34 | + * Represent the extends list for generated java classes. It holds the class details which needs to be extended by the |
35 | - * to be extended by the generated java code. | 35 | + * generated java code. |
36 | */ | 36 | */ |
37 | public class JavaExtendsListHolder { | 37 | public class JavaExtendsListHolder { |
38 | 38 | ... | ... |
... | @@ -26,9 +26,10 @@ import org.onosproject.yangutils.datamodel.YangAugmentableNode; | ... | @@ -26,9 +26,10 @@ import org.onosproject.yangutils.datamodel.YangAugmentableNode; |
26 | import org.onosproject.yangutils.datamodel.YangLeaf; | 26 | import org.onosproject.yangutils.datamodel.YangLeaf; |
27 | import org.onosproject.yangutils.datamodel.YangLeafList; | 27 | import org.onosproject.yangutils.datamodel.YangLeafList; |
28 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 28 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
29 | +import org.onosproject.yangutils.datamodel.YangModule; | ||
29 | import org.onosproject.yangutils.datamodel.YangNode; | 30 | import org.onosproject.yangutils.datamodel.YangNode; |
30 | -import org.onosproject.yangutils.datamodel.YangTypeDef; | ||
31 | import org.onosproject.yangutils.datamodel.YangType; | 31 | import org.onosproject.yangutils.datamodel.YangType; |
32 | +import org.onosproject.yangutils.datamodel.YangTypeDef; | ||
32 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | 33 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; |
33 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; | 34 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; |
34 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | 35 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; |
... | @@ -37,7 +38,9 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ... | @@ -37,7 +38,9 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
37 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 38 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
38 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 39 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
39 | import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; | 40 | import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; |
41 | +import org.onosproject.yangutils.translator.tojava.TempJavaEventFragmentFiles; | ||
40 | import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; | 42 | import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; |
43 | +import org.onosproject.yangutils.translator.tojava.YangJavaModelUtils; | ||
41 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 44 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
42 | 45 | ||
43 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; | 46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
... | @@ -54,7 +57,6 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -54,7 +57,6 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
54 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK; | 57 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK; |
55 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_CLASS_MASK; | 58 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_CLASS_MASK; |
56 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; | 59 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; |
57 | -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.AUGMENTE_CLASS_CONSTRUCTOR_MASK; | ||
58 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; | 60 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; |
59 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; | 61 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; |
60 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; | 62 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; |
... | @@ -86,9 +88,10 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator | ... | @@ -86,9 +88,10 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator |
86 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod; | 88 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod; |
87 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl; | 89 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl; |
88 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentInfoImpl; | 90 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentInfoImpl; |
89 | -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedNodesConstructorStart; | 91 | +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentInfoMapImpl; |
90 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForManager; | 92 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForManager; |
91 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForService; | 93 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForService; |
94 | +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBaseClassMethodImpl; | ||
92 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart; | 95 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart; |
93 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstructor; | 96 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstructor; |
94 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfMethod; | 97 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfMethod; |
... | @@ -101,6 +104,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator | ... | @@ -101,6 +104,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator |
101 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString; | 104 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString; |
102 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose; | 105 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose; |
103 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen; | 106 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen; |
107 | +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilterContentMatch; | ||
104 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString; | 108 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString; |
105 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOpParamConstructorStart; | 109 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOpParamConstructorStart; |
106 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOperationTypeSetter; | 110 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOperationTypeSetter; |
... | @@ -116,65 +120,61 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator | ... | @@ -116,65 +120,61 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator |
116 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen; | 120 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen; |
117 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafListgetter; | 121 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafListgetter; |
118 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafgetter; | 122 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafgetter; |
119 | -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getisFilterContentMatch; | ||
120 | import static org.onosproject.yangutils.utils.UtilConstants.BASE64; | 123 | import static org.onosproject.yangutils.utils.UtilConstants.BASE64; |
121 | -import static org.onosproject.yangutils.utils.UtilConstants.BINARY_STRING; | 124 | +import static org.onosproject.yangutils.utils.UtilConstants.BITSET; |
122 | -import static org.onosproject.yangutils.utils.UtilConstants.BITS_STRING; | ||
123 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | 125 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
124 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | 126 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
125 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | 127 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
126 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | 128 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
129 | +import static org.onosproject.yangutils.utils.UtilConstants.CREATE; | ||
127 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | 130 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; |
131 | +import static org.onosproject.yangutils.utils.UtilConstants.DELETE; | ||
128 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; | 132 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; |
129 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 133 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
134 | +import static org.onosproject.yangutils.utils.UtilConstants.ENCODE_TO_STRING; | ||
135 | +import static org.onosproject.yangutils.utils.UtilConstants.ENUM; | ||
136 | +import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | ||
130 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING; | 137 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING; |
131 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; | 138 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; |
132 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_SUBJECT_NAME_SUFFIX; | 139 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_SUBJECT_NAME_SUFFIX; |
140 | +import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF; | ||
141 | +import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF_LIST; | ||
133 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 142 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
134 | import static org.onosproject.yangutils.utils.UtilConstants.GET_ENCODER; | 143 | import static org.onosproject.yangutils.utils.UtilConstants.GET_ENCODER; |
135 | -import static org.onosproject.yangutils.utils.UtilConstants.ENCODE_TO_STRING; | 144 | +import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF; |
136 | -import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_PKG; | 145 | +import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF_LIST; |
137 | -import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_IMPORT_BASE64_CLASS; | ||
138 | import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; | 146 | import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; |
139 | import static org.onosproject.yangutils.utils.UtilConstants.INT; | 147 | import static org.onosproject.yangutils.utils.UtilConstants.INT; |
148 | +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_IMPORT_BASE64_CLASS; | ||
149 | +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_PKG; | ||
140 | import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_STATEMENT; | 150 | import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_STATEMENT; |
141 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; | 151 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; |
152 | +import static org.onosproject.yangutils.utils.UtilConstants.MERGE; | ||
153 | +import static org.onosproject.yangutils.utils.UtilConstants.NEW; | ||
142 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 154 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
143 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; | 155 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; |
156 | +import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; | ||
144 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; | 157 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; |
158 | +import static org.onosproject.yangutils.utils.UtilConstants.OPERATION_ENUM; | ||
159 | +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_TYPE; | ||
160 | +import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | ||
145 | import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; | 161 | import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; |
146 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; | 162 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; |
147 | -import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 163 | +import static org.onosproject.yangutils.utils.UtilConstants.REMOVE; |
148 | -import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_METHOD_STRING; | 164 | +import static org.onosproject.yangutils.utils.UtilConstants.REPLACE; |
149 | -import static org.onosproject.yangutils.utils.UtilConstants.SUPER; | 165 | +import static org.onosproject.yangutils.utils.UtilConstants.RETURN; |
150 | -import static org.onosproject.yangutils.utils.UtilConstants.BITSET; | ||
151 | -import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF; | ||
152 | -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF; | ||
153 | import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF; | 166 | import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF; |
154 | -import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF_LIST; | ||
155 | -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF_LIST; | ||
156 | import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF_LIST; | 167 | import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF_LIST; |
157 | -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION_ENUM; | 168 | +import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
158 | -import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_TYPE; | 169 | +import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_METHOD_STRING; |
159 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 170 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
160 | -import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | ||
161 | -import static org.onosproject.yangutils.utils.UtilConstants.NEW; | ||
162 | import static org.onosproject.yangutils.utils.UtilConstants.STATIC; | 171 | import static org.onosproject.yangutils.utils.UtilConstants.STATIC; |
163 | -import static org.onosproject.yangutils.utils.UtilConstants.ENUM; | ||
164 | -import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; | ||
165 | -import static org.onosproject.yangutils.utils.UtilConstants.MERGE; | ||
166 | -import static org.onosproject.yangutils.utils.UtilConstants.REPLACE; | ||
167 | -import static org.onosproject.yangutils.utils.UtilConstants.RETURN; | ||
168 | -import static org.onosproject.yangutils.utils.UtilConstants.CREATE; | ||
169 | -import static org.onosproject.yangutils.utils.UtilConstants.REMOVE; | ||
170 | -import static org.onosproject.yangutils.utils.UtilConstants.DELETE; | ||
171 | -import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | ||
172 | import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; | 172 | import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; |
173 | +import static org.onosproject.yangutils.utils.UtilConstants.SUPER; | ||
173 | import static org.onosproject.yangutils.utils.UtilConstants.TO; | 174 | import static org.onosproject.yangutils.utils.UtilConstants.TO; |
174 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; | 175 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
175 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; | 176 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; |
176 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | 177 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
177 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
178 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 178 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
179 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; | 179 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
180 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 180 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
... | @@ -203,7 +203,13 @@ public final class JavaFileGenerator { | ... | @@ -203,7 +203,13 @@ public final class JavaFileGenerator { |
203 | throws IOException { | 203 | throws IOException { |
204 | 204 | ||
205 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | 205 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
206 | - String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 206 | + |
207 | + String path; | ||
208 | + if (curNode instanceof YangModule) { | ||
209 | + path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); | ||
210 | + } else { | ||
211 | + path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | ||
212 | + } | ||
207 | 213 | ||
208 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 214 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
209 | 215 | ||
... | @@ -244,7 +250,12 @@ public final class JavaFileGenerator { | ... | @@ -244,7 +250,12 @@ public final class JavaFileGenerator { |
244 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); | 250 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); |
245 | 251 | ||
246 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 252 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
247 | - String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 253 | + String path; |
254 | + if (curNode instanceof YangModule) { | ||
255 | + path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); | ||
256 | + } else { | ||
257 | + path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | ||
258 | + } | ||
248 | 259 | ||
249 | initiateJavaFileGeneration(file, BUILDER_INTERFACE_MASK, null, curNode, className); | 260 | initiateJavaFileGeneration(file, BUILDER_INTERFACE_MASK, null, curNode, className); |
250 | List<String> methods = new ArrayList<>(); | 261 | List<String> methods = new ArrayList<>(); |
... | @@ -302,14 +313,16 @@ public final class JavaFileGenerator { | ... | @@ -302,14 +313,16 @@ public final class JavaFileGenerator { |
302 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); | 313 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); |
303 | 314 | ||
304 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 315 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
305 | - String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 316 | + |
317 | + String path; | ||
318 | + if (curNode instanceof YangModule) { | ||
319 | + path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); | ||
320 | + } else { | ||
321 | + path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | ||
322 | + } | ||
306 | 323 | ||
307 | initiateJavaFileGeneration(file, BUILDER_CLASS_MASK, null, curNode, className); | 324 | initiateJavaFileGeneration(file, BUILDER_CLASS_MASK, null, curNode, className); |
308 | List<String> methods = new ArrayList<>(); | 325 | List<String> methods = new ArrayList<>(); |
309 | - boolean isAugmentNode = false; | ||
310 | - if (curNode instanceof YangAugment) { | ||
311 | - isAugmentNode = true; | ||
312 | - } | ||
313 | 326 | ||
314 | if (isAttrPresent) { | 327 | if (isAttrPresent) { |
315 | /** | 328 | /** |
... | @@ -339,21 +352,6 @@ public final class JavaFileGenerator { | ... | @@ -339,21 +352,6 @@ public final class JavaFileGenerator { |
339 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 352 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
340 | .getBeanTempFiles(), path)); | 353 | .getBeanTempFiles(), path)); |
341 | 354 | ||
342 | - if (isAugmentNode) { | ||
343 | - YangAugment augment = (YangAugment) curNode; | ||
344 | - String augmentNode = getCapitalCase( | ||
345 | - getCamelCase(augment.getAugmentedNode().getName(), pluginConfig.getConflictResolver())); | ||
346 | - /** | ||
347 | - * Constructor. | ||
348 | - */ | ||
349 | - String constructor = getAugmentedNodesConstructorStart(className, augmentNode) | ||
350 | - + getDataFromTempFileHandle(AUGMENTE_CLASS_CONSTRUCTOR_MASK, | ||
351 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | ||
352 | - .getBeanTempFiles(), path); | ||
353 | - | ||
354 | - methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + | ||
355 | - NEW_LINE + NEW_LINE); | ||
356 | - } | ||
357 | insertDataIntoJavaFile(file, NEW_LINE); | 355 | insertDataIntoJavaFile(file, NEW_LINE); |
358 | } catch (IOException e) { | 356 | } catch (IOException e) { |
359 | throw new IOException("No data found in temporary java code fragment files for " + className | 357 | throw new IOException("No data found in temporary java code fragment files for " + className |
... | @@ -382,14 +380,15 @@ public final class JavaFileGenerator { | ... | @@ -382,14 +380,15 @@ public final class JavaFileGenerator { |
382 | 380 | ||
383 | /** | 381 | /** |
384 | * Returns generated op param builder class file for current node. | 382 | * Returns generated op param builder class file for current node. |
385 | - * @param file file handle | 383 | + * |
386 | - * @param curNode current YANG node | 384 | + * @param file file handle |
385 | + * @param curNode current YANG node | ||
387 | * @param isAttrPresent if any attribute is present or not | 386 | * @param isAttrPresent if any attribute is present or not |
388 | * @return builder class file | 387 | * @return builder class file |
389 | * @throws IOException when fails to write in file | 388 | * @throws IOException when fails to write in file |
390 | */ | 389 | */ |
391 | public static File generateOpParamBuilderClassFile(File file, YangNode curNode, | 390 | public static File generateOpParamBuilderClassFile(File file, YangNode curNode, |
392 | - boolean isAttrPresent) throws IOException { | 391 | + boolean isAttrPresent) throws IOException { |
393 | 392 | ||
394 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | 393 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
395 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); | 394 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); |
... | @@ -409,7 +408,7 @@ public final class JavaFileGenerator { | ... | @@ -409,7 +408,7 @@ public final class JavaFileGenerator { |
409 | 408 | ||
410 | } catch (IOException e) { | 409 | } catch (IOException e) { |
411 | throw new IOException("No data found in temporary java code fragment files for " + className | 410 | throw new IOException("No data found in temporary java code fragment files for " + className |
412 | - + " while impl class file generation"); | 411 | + + " while impl class file generation"); |
413 | } | 412 | } |
414 | 413 | ||
415 | try { | 414 | try { |
... | @@ -445,7 +444,7 @@ public final class JavaFileGenerator { | ... | @@ -445,7 +444,7 @@ public final class JavaFileGenerator { |
445 | 444 | ||
446 | } catch (IOException e) { | 445 | } catch (IOException e) { |
447 | throw new IOException("No data found in temporary java code fragment files for " + className | 446 | throw new IOException("No data found in temporary java code fragment files for " + className |
448 | - + " while impl class file generation"); | 447 | + + " while impl class file generation"); |
449 | } | 448 | } |
450 | 449 | ||
451 | try { | 450 | try { |
... | @@ -476,7 +475,7 @@ public final class JavaFileGenerator { | ... | @@ -476,7 +475,7 @@ public final class JavaFileGenerator { |
476 | insertDataIntoJavaFile(file, NEW_LINE); | 475 | insertDataIntoJavaFile(file, NEW_LINE); |
477 | } catch (IOException e) { | 476 | } catch (IOException e) { |
478 | throw new IOException("No data found in temporary java code fragment files for " + className | 477 | throw new IOException("No data found in temporary java code fragment files for " + className |
479 | - + " while builder class file generation"); | 478 | + + " while builder class file generation"); |
480 | } | 479 | } |
481 | } else { | 480 | } else { |
482 | insertDataIntoJavaFile(file, NEW_LINE); | 481 | insertDataIntoJavaFile(file, NEW_LINE); |
... | @@ -579,15 +578,16 @@ public final class JavaFileGenerator { | ... | @@ -579,15 +578,16 @@ public final class JavaFileGenerator { |
579 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); | 578 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); |
580 | 579 | ||
581 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 580 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
582 | - String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 581 | + String path; |
582 | + if (curNode instanceof YangModule) { | ||
583 | + path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); | ||
584 | + } else { | ||
585 | + path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | ||
586 | + } | ||
583 | 587 | ||
584 | initiateJavaFileGeneration(file, IMPL_CLASS_MASK, imports, curNode, className); | 588 | initiateJavaFileGeneration(file, IMPL_CLASS_MASK, imports, curNode, className); |
585 | 589 | ||
586 | List<String> methods = new ArrayList<>(); | 590 | List<String> methods = new ArrayList<>(); |
587 | - boolean isAugmentNode = false; | ||
588 | - if (curNode instanceof YangAugment) { | ||
589 | - isAugmentNode = true; | ||
590 | - } | ||
591 | if (curNode instanceof YangAugmentableNode) { | 591 | if (curNode instanceof YangAugmentableNode) { |
592 | insertDataIntoJavaFile(file, addAugmentationAttribute()); | 592 | insertDataIntoJavaFile(file, addAugmentationAttribute()); |
593 | } | 593 | } |
... | @@ -648,11 +648,6 @@ public final class JavaFileGenerator { | ... | @@ -648,11 +648,6 @@ public final class JavaFileGenerator { |
648 | * Constructor. | 648 | * Constructor. |
649 | */ | 649 | */ |
650 | String constructor = getConstructorStart(className, pluginConfig); | 650 | String constructor = getConstructorStart(className, pluginConfig); |
651 | - if (isAugmentNode) { | ||
652 | - constructor = constructor + EIGHT_SPACE_INDENTATION + SUPER + OPEN_PARENTHESIS | ||
653 | - + BUILDER.toLowerCase() + OBJECT | ||
654 | - + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; | ||
655 | - } | ||
656 | constructor = constructor + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK, | 651 | constructor = constructor + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK, |
657 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 652 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
658 | .getBeanTempFiles(), path); | 653 | .getBeanTempFiles(), path); |
... | @@ -666,6 +661,7 @@ public final class JavaFileGenerator { | ... | @@ -666,6 +661,7 @@ public final class JavaFileGenerator { |
666 | if (curNode instanceof YangAugmentableNode) { | 661 | if (curNode instanceof YangAugmentableNode) { |
667 | methods.add(getAddAugmentInfoMethodImpl()); | 662 | methods.add(getAddAugmentInfoMethodImpl()); |
668 | methods.add(getAugmentInfoImpl()); | 663 | methods.add(getAugmentInfoImpl()); |
664 | + methods.add(getAugmentInfoMapImpl(javaFileInfo.getPluginConfig())); | ||
669 | } | 665 | } |
670 | 666 | ||
671 | /** | 667 | /** |
... | @@ -681,11 +677,11 @@ public final class JavaFileGenerator { | ... | @@ -681,11 +677,11 @@ public final class JavaFileGenerator { |
681 | /** | 677 | /** |
682 | * Returns generated op param class file for current node. | 678 | * Returns generated op param class file for current node. |
683 | * | 679 | * |
684 | - * @param file file handle | 680 | + * @param file file handle |
685 | - * @param curNode current YANG node | 681 | + * @param curNode current YANG node |
686 | - * @param isAttrPresent if any attribute is present or not | 682 | + * @param isAttrPresent if any attribute is present or not |
687 | - * @param imports import list | 683 | + * @param imports import list |
688 | - * @return returns generated op param class file for current node | 684 | + * @return returns generated op param class file for current node |
689 | * @throws IOException when fails to write in file | 685 | * @throws IOException when fails to write in file |
690 | */ | 686 | */ |
691 | public static File generateOpParamImplClassFile(File file, YangNode curNode, | 687 | public static File generateOpParamImplClassFile(File file, YangNode curNode, |
... | @@ -696,7 +692,6 @@ public final class JavaFileGenerator { | ... | @@ -696,7 +692,6 @@ public final class JavaFileGenerator { |
696 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); | 692 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); |
697 | 693 | ||
698 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 694 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
699 | - String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | ||
700 | 695 | ||
701 | initiateJavaFileGeneration(file, OPERATION_CLASS_MASK, imports, curNode, className); | 696 | initiateJavaFileGeneration(file, OPERATION_CLASS_MASK, imports, curNode, className); |
702 | 697 | ||
... | @@ -718,7 +713,7 @@ public final class JavaFileGenerator { | ... | @@ -718,7 +713,7 @@ public final class JavaFileGenerator { |
718 | 713 | ||
719 | } catch (IOException e) { | 714 | } catch (IOException e) { |
720 | throw new IOException("No data found in temporary java code fragment files for " + className | 715 | throw new IOException("No data found in temporary java code fragment files for " + className |
721 | - + " while impl class file generation"); | 716 | + + " while impl class file generation"); |
722 | } | 717 | } |
723 | 718 | ||
724 | /** | 719 | /** |
... | @@ -730,7 +725,7 @@ public final class JavaFileGenerator { | ... | @@ -730,7 +725,7 @@ public final class JavaFileGenerator { |
730 | 725 | ||
731 | } catch (IOException e) { | 726 | } catch (IOException e) { |
732 | throw new IOException("No data found in temporary java code fragment files for " + className | 727 | throw new IOException("No data found in temporary java code fragment files for " + className |
733 | - + " while impl class file generation"); | 728 | + + " while impl class file generation"); |
734 | } | 729 | } |
735 | 730 | ||
736 | try { | 731 | try { |
... | @@ -766,7 +761,7 @@ public final class JavaFileGenerator { | ... | @@ -766,7 +761,7 @@ public final class JavaFileGenerator { |
766 | 761 | ||
767 | } catch (IOException e) { | 762 | } catch (IOException e) { |
768 | throw new IOException("No data found in temporary java code fragment files for " + className | 763 | throw new IOException("No data found in temporary java code fragment files for " + className |
769 | - + " while impl class file generation"); | 764 | + + " while impl class file generation"); |
770 | } | 765 | } |
771 | 766 | ||
772 | if (curNode instanceof YangLeavesHolder) { | 767 | if (curNode instanceof YangLeavesHolder) { |
... | @@ -786,7 +781,7 @@ public final class JavaFileGenerator { | ... | @@ -786,7 +781,7 @@ public final class JavaFileGenerator { |
786 | } | 781 | } |
787 | 782 | ||
788 | methods.add(getOperationTypegetter()); | 783 | methods.add(getOperationTypegetter()); |
789 | - methods.add(getisFilterContentMatch(className, curNode, pluginConfig)); | 784 | + methods.add(getIsFilterContentMatch(className, curNode, pluginConfig)); |
790 | 785 | ||
791 | } else { | 786 | } else { |
792 | insertDataIntoJavaFile(file, NEW_LINE); | 787 | insertDataIntoJavaFile(file, NEW_LINE); |
... | @@ -821,6 +816,12 @@ public final class JavaFileGenerator { | ... | @@ -821,6 +816,12 @@ public final class JavaFileGenerator { |
821 | 816 | ||
822 | methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET); | 817 | methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET); |
823 | 818 | ||
819 | + if (curNode instanceof YangAugment) { | ||
820 | + String clsName = getCapitalCase(DEFAULT) + | ||
821 | + getCapitalCase(YangJavaModelUtils.getAugmentClassName((YangAugment) curNode, pluginConfig)); | ||
822 | + methods.add(getBaseClassMethodImpl(clsName)); | ||
823 | + } | ||
824 | + | ||
824 | /** | 825 | /** |
825 | * Add methods in impl class. | 826 | * Add methods in impl class. |
826 | */ | 827 | */ |
... | @@ -925,9 +926,9 @@ public final class JavaFileGenerator { | ... | @@ -925,9 +926,9 @@ public final class JavaFileGenerator { |
925 | */ | 926 | */ |
926 | if (type.getDataType().equals(YangDataTypes.BINARY)) { | 927 | if (type.getDataType().equals(YangDataTypes.BINARY)) { |
927 | JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, | 928 | JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, |
928 | - getCapitalCase(BINARY_STRING)); | 929 | + getCapitalCase("binary")); |
929 | 930 | ||
930 | - JavaAttributeInfo attr = getAttributeInfoForTheData(qualifiedTypeInfo, BINARY_STRING, null, false, | 931 | + JavaAttributeInfo attr = getAttributeInfoForTheData(qualifiedTypeInfo, "binary", null, false, |
931 | false); | 932 | false); |
932 | String attributeName = attr.getAttributeName(); | 933 | String attributeName = attr.getAttributeName(); |
933 | String bitsToStringMethod = MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC | 934 | String bitsToStringMethod = MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC |
... | @@ -939,10 +940,9 @@ public final class JavaFileGenerator { | ... | @@ -939,10 +940,9 @@ public final class JavaFileGenerator { |
939 | methods.add(bitsToStringMethod); | 940 | methods.add(bitsToStringMethod); |
940 | } else if (type.getDataType().equals(YangDataTypes.BITS)) { | 941 | } else if (type.getDataType().equals(YangDataTypes.BITS)) { |
941 | JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, | 942 | JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, |
942 | - getCapitalCase(BITS_STRING)); | 943 | + getCapitalCase("bits")); |
943 | 944 | ||
944 | - JavaAttributeInfo attr = getAttributeInfoForTheData(qualifiedTypeInfo, BITS_STRING, | 945 | + JavaAttributeInfo attr = getAttributeInfoForTheData(qualifiedTypeInfo, "bits", null, false, false); |
945 | - null, false, false); | ||
946 | String attributeName = attr.getAttributeName(); | 946 | String attributeName = attr.getAttributeName(); |
947 | String bitsToStringMethod = MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC | 947 | String bitsToStringMethod = MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC |
948 | + SPACE + STRING_DATA_TYPE + SPACE + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS | 948 | + SPACE + STRING_DATA_TYPE + SPACE + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS |
... | @@ -1238,8 +1238,8 @@ public final class JavaFileGenerator { | ... | @@ -1238,8 +1238,8 @@ public final class JavaFileGenerator { |
1238 | String className = getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()) | 1238 | String className = getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()) |
1239 | + EVENT_STRING; | 1239 | + EVENT_STRING; |
1240 | 1240 | ||
1241 | - TempJavaServiceFragmentFiles tempFiles = ((TempJavaCodeFragmentFilesContainer) curNode) | 1241 | + TempJavaEventFragmentFiles tempFiles = ((TempJavaCodeFragmentFilesContainer) curNode) |
1242 | - .getTempJavaCodeFragmentFiles().getServiceTempFiles(); | 1242 | + .getTempJavaCodeFragmentFiles().getEventFragmentFiles(); |
1243 | 1243 | ||
1244 | String path = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getBaseCodeGenPath() | 1244 | String path = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getBaseCodeGenPath() |
1245 | + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackageFilePath(); | 1245 | + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackageFilePath(); |
... | @@ -1296,8 +1296,9 @@ public final class JavaFileGenerator { | ... | @@ -1296,8 +1296,9 @@ public final class JavaFileGenerator { |
1296 | 1296 | ||
1297 | String path = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getBaseCodeGenPath() | 1297 | String path = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getBaseCodeGenPath() |
1298 | + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackageFilePath(); | 1298 | + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackageFilePath(); |
1299 | - TempJavaServiceFragmentFiles tempFiles = ((TempJavaCodeFragmentFilesContainer) curNode) | 1299 | + |
1300 | - .getTempJavaCodeFragmentFiles().getServiceTempFiles(); | 1300 | + TempJavaEventFragmentFiles tempFiles = ((TempJavaCodeFragmentFilesContainer) curNode) |
1301 | + .getTempJavaCodeFragmentFiles().getEventFragmentFiles(); | ||
1301 | 1302 | ||
1302 | insertDataIntoJavaFile(file, NEW_LINE); | 1303 | insertDataIntoJavaFile(file, NEW_LINE); |
1303 | try { | 1304 | try { | ... | ... |
... | @@ -19,9 +19,7 @@ package org.onosproject.yangutils.translator.tojava.utils; | ... | @@ -19,9 +19,7 @@ package org.onosproject.yangutils.translator.tojava.utils; |
19 | import java.io.File; | 19 | 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.HashMap; | ||
23 | import java.util.List; | 22 | import java.util.List; |
24 | -import java.util.Map; | ||
25 | 23 | ||
26 | import org.onosproject.yangutils.datamodel.YangAtomicPath; | 24 | import org.onosproject.yangutils.datamodel.YangAtomicPath; |
27 | import org.onosproject.yangutils.datamodel.YangAugment; | 25 | import org.onosproject.yangutils.datamodel.YangAugment; |
... | @@ -36,6 +34,7 @@ import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | ... | @@ -36,6 +34,7 @@ import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
36 | import org.onosproject.yangutils.translator.tojava.TempJavaBeanFragmentFiles; | 34 | import org.onosproject.yangutils.translator.tojava.TempJavaBeanFragmentFiles; |
37 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 35 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
38 | import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; | 36 | import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; |
37 | +import org.onosproject.yangutils.translator.tojava.TempJavaEventFragmentFiles; | ||
39 | import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; | 38 | import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; |
40 | import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; | 39 | import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; |
41 | import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles; | 40 | import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles; |
... | @@ -81,9 +80,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. | ... | @@ -81,9 +80,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. |
81 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; | 80 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; |
82 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getAugmentedNodesPackage; | 81 | import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getAugmentedNodesPackage; |
83 | import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; | 82 | import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; |
84 | -import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | ||
85 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | 83 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
86 | -import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | ||
87 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 84 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
88 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE; | 85 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE; |
89 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 86 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
... | @@ -97,9 +94,9 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENU | ... | @@ -97,9 +94,9 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENU |
97 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVENT; | 94 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVENT; |
98 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVENT_LISTENER; | 95 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVENT_LISTENER; |
99 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVENT_SUBJECT_CLASS; | 96 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.EVENT_SUBJECT_CLASS; |
100 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OPERATION_CLASS; | ||
101 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.IMPL_CLASS; | 97 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.IMPL_CLASS; |
102 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INTERFACE; | 98 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INTERFACE; |
99 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OPERATION_CLASS; | ||
103 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_INTERFACE; | 100 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_INTERFACE; |
104 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_MANAGER; | 101 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_MANAGER; |
105 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | 102 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
... | @@ -123,15 +120,15 @@ public final class JavaFileGeneratorUtils { | ... | @@ -123,15 +120,15 @@ public final class JavaFileGeneratorUtils { |
123 | /** | 120 | /** |
124 | * Returns a file object for generated file. | 121 | * Returns a file object for generated file. |
125 | * | 122 | * |
126 | - * @param fileName file name | ||
127 | * @param filePath file package path | 123 | * @param filePath file package path |
124 | + * @param fileName file name | ||
128 | * @param extension file extension | 125 | * @param extension file extension |
129 | - * @param handle cached file handle | 126 | + * @param baseCodePath cached file handle |
130 | * @return file object | 127 | * @return file object |
131 | */ | 128 | */ |
132 | - public static File getFileObject(String filePath, String fileName, String extension, JavaFileInfo handle) { | 129 | + public static File getFileObject(String filePath, String fileName, String extension, String baseCodePath) { |
133 | 130 | ||
134 | - return new File(handle.getBaseCodeGenPath() + filePath + SLASH + fileName + extension); | 131 | + return new File(baseCodePath + filePath + SLASH + fileName + extension); |
135 | } | 132 | } |
136 | 133 | ||
137 | /** | 134 | /** |
... | @@ -143,8 +140,8 @@ public final class JavaFileGeneratorUtils { | ... | @@ -143,8 +140,8 @@ public final class JavaFileGeneratorUtils { |
143 | * @return data stored in temporary files | 140 | * @return data stored in temporary files |
144 | * @throws IOException when failed to get the data from temporary file handle | 141 | * @throws IOException when failed to get the data from temporary file handle |
145 | */ | 142 | */ |
146 | - public static String getDataFromTempFileHandle(int generatedTempFiles, | 143 | + static String getDataFromTempFileHandle(int generatedTempFiles, |
147 | - TempJavaFragmentFiles tempJavaFragmentFiles, String absolutePath) | 144 | + TempJavaFragmentFiles tempJavaFragmentFiles, String absolutePath) |
148 | throws IOException { | 145 | throws IOException { |
149 | 146 | ||
150 | TempJavaTypeFragmentFiles typeFragmentFiles = null; | 147 | TempJavaTypeFragmentFiles typeFragmentFiles = null; |
... | @@ -164,6 +161,11 @@ public final class JavaFileGeneratorUtils { | ... | @@ -164,6 +161,11 @@ public final class JavaFileGeneratorUtils { |
164 | serviceFragmentFiles = (TempJavaServiceFragmentFiles) tempJavaFragmentFiles; | 161 | serviceFragmentFiles = (TempJavaServiceFragmentFiles) tempJavaFragmentFiles; |
165 | } | 162 | } |
166 | 163 | ||
164 | + TempJavaEventFragmentFiles eventFragmentFiles = null; | ||
165 | + if (tempJavaFragmentFiles instanceof TempJavaEventFragmentFiles) { | ||
166 | + eventFragmentFiles = (TempJavaEventFragmentFiles) tempJavaFragmentFiles; | ||
167 | + } | ||
168 | + | ||
167 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { | 169 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { |
168 | return tempJavaFragmentFiles | 170 | return tempJavaFragmentFiles |
169 | .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAttributesTempFileHandle(), | 171 | .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAttributesTempFileHandle(), |
... | @@ -247,39 +249,39 @@ public final class JavaFileGeneratorUtils { | ... | @@ -247,39 +249,39 @@ public final class JavaFileGeneratorUtils { |
247 | .getTemporaryDataFromFileHandle(serviceFragmentFiles.getRpcImplTempFileHandle(), | 249 | .getTemporaryDataFromFileHandle(serviceFragmentFiles.getRpcImplTempFileHandle(), |
248 | absolutePath); | 250 | absolutePath); |
249 | } else if ((generatedTempFiles & EVENT_ENUM_MASK) != 0) { | 251 | } else if ((generatedTempFiles & EVENT_ENUM_MASK) != 0) { |
250 | - if (serviceFragmentFiles == null) { | 252 | + if (eventFragmentFiles == null) { |
251 | - throw new TranslatorException("Required rpc implementation info is missing."); | 253 | + throw new TranslatorException("Required event enum implementation info is missing."); |
252 | } | 254 | } |
253 | - return serviceFragmentFiles | 255 | + return eventFragmentFiles |
254 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventEnumTempFileHandle(), | 256 | + .getTemporaryDataFromFileHandle(eventFragmentFiles.getEventEnumTempFileHandle(), |
255 | absolutePath); | 257 | absolutePath); |
256 | } else if ((generatedTempFiles & EVENT_METHOD_MASK) != 0) { | 258 | } else if ((generatedTempFiles & EVENT_METHOD_MASK) != 0) { |
257 | - if (serviceFragmentFiles == null) { | 259 | + if (eventFragmentFiles == null) { |
258 | - throw new TranslatorException("Required rpc implementation info is missing."); | 260 | + throw new TranslatorException("Required event method implementation info is missing."); |
259 | } | 261 | } |
260 | - return serviceFragmentFiles | 262 | + return eventFragmentFiles |
261 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventMethodTempFileHandle(), | 263 | + .getTemporaryDataFromFileHandle(eventFragmentFiles.getEventMethodTempFileHandle(), |
262 | absolutePath); | 264 | absolutePath); |
263 | } else if ((generatedTempFiles & EVENT_SUBJECT_GETTER_MASK) != 0) { | 265 | } else if ((generatedTempFiles & EVENT_SUBJECT_GETTER_MASK) != 0) { |
264 | - if (serviceFragmentFiles == null) { | 266 | + if (eventFragmentFiles == null) { |
265 | - throw new TranslatorException("Required rpc implementation info is missing."); | 267 | + throw new TranslatorException("Required event subject getter implementation info is missing."); |
266 | } | 268 | } |
267 | - return serviceFragmentFiles | 269 | + return eventFragmentFiles |
268 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectGetterTempFileHandle(), | 270 | + .getTemporaryDataFromFileHandle(eventFragmentFiles.getEventSubjectGetterTempFileHandle(), |
269 | absolutePath); | 271 | absolutePath); |
270 | } else if ((generatedTempFiles & EVENT_SUBJECT_SETTER_MASK) != 0) { | 272 | } else if ((generatedTempFiles & EVENT_SUBJECT_SETTER_MASK) != 0) { |
271 | - if (serviceFragmentFiles == null) { | 273 | + if (eventFragmentFiles == null) { |
272 | - throw new TranslatorException("Required rpc implementation info is missing."); | 274 | + throw new TranslatorException("Required event subject setter implementation info is missing."); |
273 | } | 275 | } |
274 | - return serviceFragmentFiles | 276 | + return eventFragmentFiles |
275 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectSetterTempFileHandle(), | 277 | + .getTemporaryDataFromFileHandle(eventFragmentFiles.getEventSubjectSetterTempFileHandle(), |
276 | absolutePath); | 278 | absolutePath); |
277 | } else if ((generatedTempFiles & EVENT_SUBJECT_ATTRIBUTE_MASK) != 0) { | 279 | } else if ((generatedTempFiles & EVENT_SUBJECT_ATTRIBUTE_MASK) != 0) { |
278 | - if (serviceFragmentFiles == null) { | 280 | + if (eventFragmentFiles == null) { |
279 | - throw new TranslatorException("Required rpc implementation info is missing."); | 281 | + throw new TranslatorException("Required event subject attribute implementation info is missing."); |
280 | } | 282 | } |
281 | - return serviceFragmentFiles | 283 | + return eventFragmentFiles |
282 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectAttributeTempFileHandle(), | 284 | + .getTemporaryDataFromFileHandle(eventFragmentFiles.getEventSubjectAttributeTempFileHandle(), |
283 | absolutePath); | 285 | absolutePath); |
284 | } | 286 | } |
285 | return null; | 287 | return null; |
... | @@ -300,11 +302,15 @@ public final class JavaFileGeneratorUtils { | ... | @@ -300,11 +302,15 @@ public final class JavaFileGeneratorUtils { |
300 | String pkg, YangPluginConfig pluginConfig) | 302 | String pkg, YangPluginConfig pluginConfig) |
301 | throws IOException { | 303 | throws IOException { |
302 | 304 | ||
305 | + boolean isFileCreated; | ||
303 | try { | 306 | try { |
304 | - file.createNewFile(); | 307 | + isFileCreated = file.createNewFile(); |
308 | + if (!isFileCreated) { | ||
309 | + throw new IOException("Failed to create " + file.getName() + " class file."); | ||
310 | + } | ||
305 | appendContents(file, className, genType, imports, pkg, pluginConfig); | 311 | appendContents(file, className, genType, imports, pkg, pluginConfig); |
306 | } catch (IOException e) { | 312 | } catch (IOException e) { |
307 | - throw new IOException("Failed to create " + file.getName() + " class file."); | 313 | + throw new IOException("Failed to append contents in " + file.getName() + " class file."); |
308 | } | 314 | } |
309 | } | 315 | } |
310 | 316 | ||
... | @@ -322,11 +328,15 @@ public final class JavaFileGeneratorUtils { | ... | @@ -322,11 +328,15 @@ public final class JavaFileGeneratorUtils { |
322 | YangNode curNode, String className) | 328 | YangNode curNode, String className) |
323 | throws IOException { | 329 | throws IOException { |
324 | 330 | ||
331 | + boolean isFileCreated; | ||
325 | try { | 332 | try { |
326 | - file.createNewFile(); | 333 | + isFileCreated = file.createNewFile(); |
334 | + if (!isFileCreated) { | ||
335 | + throw new IOException("Failed to create " + file.getName() + " class file."); | ||
336 | + } | ||
327 | appendContents(file, genType, imports, curNode, className); | 337 | appendContents(file, genType, imports, curNode, className); |
328 | } catch (IOException e) { | 338 | } catch (IOException e) { |
329 | - throw new IOException("Failed to create " + file.getName() + " class file."); | 339 | + throw new IOException("Failed to append contents in " + file.getName() + " class file."); |
330 | } | 340 | } |
331 | } | 341 | } |
332 | 342 | ||
... | @@ -349,11 +359,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -349,11 +359,7 @@ public final class JavaFileGeneratorUtils { |
349 | String name = javaFileInfo.getJavaName(); | 359 | String name = javaFileInfo.getJavaName(); |
350 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 360 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); |
351 | 361 | ||
352 | - YangNode augmentedNode = null; | 362 | + String pkgString; |
353 | - if (curNode instanceof YangAugment) { | ||
354 | - augmentedNode = ((YangAugment) curNode).getAugmentedNode(); | ||
355 | - } | ||
356 | - String pkgString = null; | ||
357 | if (genType == GENERATE_EVENT_CLASS | 363 | if (genType == GENERATE_EVENT_CLASS |
358 | || genType == GENERATE_EVENT_LISTENER_INTERFACE | 364 | || genType == GENERATE_EVENT_LISTENER_INTERFACE |
359 | || genType == GENERATE_EVENT_SUBJECT_CLASS) { | 365 | || genType == GENERATE_EVENT_SUBJECT_CLASS) { |
... | @@ -363,11 +369,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -363,11 +369,7 @@ public final class JavaFileGeneratorUtils { |
363 | } | 369 | } |
364 | switch (genType) { | 370 | switch (genType) { |
365 | case INTERFACE_MASK: | 371 | case INTERFACE_MASK: |
366 | - if (augmentedNode != null) { | 372 | + appendHeaderContents(file, pkgString, importsList); |
367 | - appendHeaderContents(file, pkgString, importsList, augmentedNode); | ||
368 | - } else { | ||
369 | - appendHeaderContents(file, pkgString, importsList); | ||
370 | - } | ||
371 | write(file, genType, INTERFACE, curNode, className); | 373 | write(file, genType, INTERFACE, curNode, className); |
372 | break; | 374 | break; |
373 | case IMPL_CLASS_MASK: | 375 | case IMPL_CLASS_MASK: |
... | @@ -470,8 +472,8 @@ public final class JavaFileGeneratorUtils { | ... | @@ -470,8 +472,8 @@ public final class JavaFileGeneratorUtils { |
470 | } | 472 | } |
471 | 473 | ||
472 | /** | 474 | /** |
473 | - * Appends other contents to interface, impl and typedef classes. | 475 | + * Appends other contents to interface, impl and typedef classes. for example : ONOS copyright, imports and |
474 | - * for example : ONOS copyright, imports and package. | 476 | + * package. |
475 | * | 477 | * |
476 | * @param file generated file | 478 | * @param file generated file |
477 | * @param pkg generated package | 479 | * @param pkg generated package |
... | @@ -485,7 +487,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -485,7 +487,7 @@ public final class JavaFileGeneratorUtils { |
485 | insertDataIntoJavaFile(file, pkg); | 487 | insertDataIntoJavaFile(file, pkg); |
486 | 488 | ||
487 | /* | 489 | /* |
488 | - * TODO: add the file header using | 490 | + * TODO: add the file header using comments for snippet of yang file. |
489 | * JavaCodeSnippetGen.getFileHeaderComment | 491 | * JavaCodeSnippetGen.getFileHeaderComment |
490 | */ | 492 | */ |
491 | 493 | ||
... | @@ -498,39 +500,6 @@ public final class JavaFileGeneratorUtils { | ... | @@ -498,39 +500,6 @@ public final class JavaFileGeneratorUtils { |
498 | } | 500 | } |
499 | 501 | ||
500 | /** | 502 | /** |
501 | - * Appends other contents to interface and impl classes when augmented node is not null. | ||
502 | - * for example : ONOS copyright, imports and package. | ||
503 | - * | ||
504 | - * @param file generated file | ||
505 | - * @param pkg generated package | ||
506 | - * @param augmentedNode augmented node | ||
507 | - * @param importsList list of imports | ||
508 | - * @throws IOException when fails to append contents | ||
509 | - */ | ||
510 | - private static void appendHeaderContents(File file, String pkg, List<String> importsList, YangNode augmentedNode) | ||
511 | - throws IOException { | ||
512 | - | ||
513 | - insertDataIntoJavaFile(file, CopyrightHeader.getCopyrightHeader()); | ||
514 | - insertDataIntoJavaFile(file, pkg); | ||
515 | - | ||
516 | - /* | ||
517 | - * TODO: add the file header using | ||
518 | - * JavaCodeSnippetGen.getFileHeaderComment | ||
519 | - */ | ||
520 | - | ||
521 | - if (importsList != null) { | ||
522 | - insertDataIntoJavaFile(file, NEW_LINE); | ||
523 | - for (String imports : importsList) { | ||
524 | - if (!imports.contains(getCapitalCase(DEFAULT) + getCapitalCase(getCamelCase(augmentedNode.getName(), | ||
525 | - null))) | ||
526 | - && !imports.contains(getCapitalCase(getCamelCase(augmentedNode.getName(), null)) + BUILDER)) { | ||
527 | - insertDataIntoJavaFile(file, imports); | ||
528 | - } | ||
529 | - } | ||
530 | - } | ||
531 | - } | ||
532 | - | ||
533 | - /** | ||
534 | * Writes data to the specific generated file. | 503 | * Writes data to the specific generated file. |
535 | * | 504 | * |
536 | * @param file generated file | 505 | * @param file generated file |
... | @@ -575,32 +544,12 @@ public final class JavaFileGeneratorUtils { | ... | @@ -575,32 +544,12 @@ public final class JavaFileGeneratorUtils { |
575 | } | 544 | } |
576 | 545 | ||
577 | /** | 546 | /** |
578 | - * Returns resolved augments for manager classes. | ||
579 | - * | ||
580 | - * @param parent parent node | ||
581 | - * @return resolved augments for manager classes | ||
582 | - */ | ||
583 | - public static Map<YangAtomicPath, YangAugment> getResolvedAugmentsForManager(YangNode parent) { | ||
584 | - Map<YangAtomicPath, YangAugment> resolvedAugmentsForManager = new HashMap<>(); | ||
585 | - YangNodeIdentifier nodeId; | ||
586 | - List<YangAtomicPath> targets = new ArrayList<>(); | ||
587 | - for (YangAugment augment : getListOfAugments(parent)) { | ||
588 | - nodeId = augment.getTargetNode().get(0).getNodeIdentifier(); | ||
589 | - if (validateNodeIdentifierInSet(nodeId, targets)) { | ||
590 | - targets.add(augment.getTargetNode().get(0)); | ||
591 | - resolvedAugmentsForManager.put(augment.getTargetNode().get(0), augment); | ||
592 | - } | ||
593 | - } | ||
594 | - return resolvedAugmentsForManager; | ||
595 | - } | ||
596 | - | ||
597 | - /** | ||
598 | * Returns set of node identifiers. | 547 | * Returns set of node identifiers. |
599 | * | 548 | * |
600 | * @param parent parent node | 549 | * @param parent parent node |
601 | * @return set of node identifiers | 550 | * @return set of node identifiers |
602 | */ | 551 | */ |
603 | - public static List<YangAtomicPath> getSetOfNodeIdentifiers(YangNode parent) { | 552 | + static List<YangAtomicPath> getSetOfNodeIdentifiers(YangNode parent) { |
604 | 553 | ||
605 | List<YangAtomicPath> targets = new ArrayList<>(); | 554 | List<YangAtomicPath> targets = new ArrayList<>(); |
606 | YangNodeIdentifier nodeId; | 555 | YangNodeIdentifier nodeId; |
... | @@ -649,7 +598,6 @@ public final class JavaFileGeneratorUtils { | ... | @@ -649,7 +598,6 @@ public final class JavaFileGeneratorUtils { |
649 | * @param parent parent node | 598 | * @param parent parent node |
650 | */ | 599 | */ |
651 | public static void addResolvedAugmentedDataNodeImports(YangNode parent) { | 600 | public static void addResolvedAugmentedDataNodeImports(YangNode parent) { |
652 | - Map<YangAtomicPath, YangAugment> resolvedAugmentsForManager = getResolvedAugmentsForManager(parent); | ||
653 | List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent); | 601 | List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent); |
654 | TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = ((JavaCodeGeneratorInfo) parent) | 602 | TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = ((JavaCodeGeneratorInfo) parent) |
655 | .getTempJavaCodeFragmentFiles(); | 603 | .getTempJavaCodeFragmentFiles(); |
... | @@ -658,7 +606,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -658,7 +606,7 @@ public final class JavaFileGeneratorUtils { |
658 | String curNodeName; | 606 | String curNodeName; |
659 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo(); | 607 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo(); |
660 | for (YangAtomicPath nodeId : targets) { | 608 | for (YangAtomicPath nodeId : targets) { |
661 | - augmentedNode = resolvedAugmentsForManager.get(nodeId).getResolveNodeInPath().get(nodeId); | 609 | + augmentedNode = nodeId.getResolvedNode().getParent(); |
662 | if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) { | 610 | if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) { |
663 | curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName(); | 611 | curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName(); |
664 | } else { | 612 | } else { |
... | @@ -682,8 +630,8 @@ public final class JavaFileGeneratorUtils { | ... | @@ -682,8 +630,8 @@ public final class JavaFileGeneratorUtils { |
682 | * @param pluginConfig plugin configurations | 630 | * @param pluginConfig plugin configurations |
683 | * @return qualified type info of augmented node | 631 | * @return qualified type info of augmented node |
684 | */ | 632 | */ |
685 | - public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfAugmentedNode(YangNode augmentedNode, String curNodeName, | 633 | + private static JavaQualifiedTypeInfo getQualifiedTypeInfoOfAugmentedNode(YangNode augmentedNode, String curNodeName, |
686 | - YangPluginConfig pluginConfig) { | 634 | + YangPluginConfig pluginConfig) { |
687 | JavaQualifiedTypeInfo javaQualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(augmentedNode, | 635 | JavaQualifiedTypeInfo javaQualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(augmentedNode, |
688 | getCapitalCase(curNodeName)); | 636 | getCapitalCase(curNodeName)); |
689 | if (javaQualifiedTypeInfo.getPkgInfo() == null) { | 637 | if (javaQualifiedTypeInfo.getPkgInfo() == null) { |
... | @@ -719,7 +667,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -719,7 +667,7 @@ public final class JavaFileGeneratorUtils { |
719 | * @param parent parent node | 667 | * @param parent parent node |
720 | * @return augmented class name for data methods in manager and service | 668 | * @return augmented class name for data methods in manager and service |
721 | */ | 669 | */ |
722 | - public static String getAugmentedClassNameForDataMethods(YangNode augmentedNode, YangNode parent) { | 670 | + static String getAugmentedClassNameForDataMethods(YangNode augmentedNode, YangNode parent) { |
723 | String curNodeName; | 671 | String curNodeName; |
724 | JavaQualifiedTypeInfo javaQualifiedTypeInfo; | 672 | JavaQualifiedTypeInfo javaQualifiedTypeInfo; |
725 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo(); | 673 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo(); |
... | @@ -751,7 +699,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -751,7 +699,7 @@ public final class JavaFileGeneratorUtils { |
751 | * @param pluginConfig plugin configurations | 699 | * @param pluginConfig plugin configurations |
752 | * @return parent node name for data methods in manager and service | 700 | * @return parent node name for data methods in manager and service |
753 | */ | 701 | */ |
754 | - public static String getParentNodeNameForDataMethods(YangNode parent, YangPluginConfig pluginConfig) { | 702 | + static String getParentNodeNameForDataMethods(YangNode parent, YangPluginConfig pluginConfig) { |
755 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo(); | 703 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo(); |
756 | if (parentInfo.getJavaName() != null) { | 704 | if (parentInfo.getJavaName() != null) { |
757 | return getCapitalCase(parentInfo.getJavaName()); | 705 | return getCapitalCase(parentInfo.getJavaName()); | ... | ... |
... | @@ -19,49 +19,54 @@ package org.onosproject.yangutils.translator.tojava.utils; | ... | @@ -19,49 +19,54 @@ package org.onosproject.yangutils.translator.tojava.utils; |
19 | import java.util.List; | 19 | import java.util.List; |
20 | import java.util.Map; | 20 | import java.util.Map; |
21 | 21 | ||
22 | +import org.onosproject.yangutils.datamodel.YangAtomicPath; | ||
23 | +import org.onosproject.yangutils.datamodel.YangAugmentableNode; | ||
22 | import org.onosproject.yangutils.datamodel.YangLeaf; | 24 | import org.onosproject.yangutils.datamodel.YangLeaf; |
23 | import org.onosproject.yangutils.datamodel.YangLeafList; | 25 | import org.onosproject.yangutils.datamodel.YangLeafList; |
24 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 26 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
25 | -import org.onosproject.yangutils.datamodel.YangAtomicPath; | ||
26 | -import org.onosproject.yangutils.datamodel.YangAugment; | ||
27 | import org.onosproject.yangutils.datamodel.YangNode; | 27 | import org.onosproject.yangutils.datamodel.YangNode; |
28 | import org.onosproject.yangutils.datamodel.YangType; | 28 | import org.onosproject.yangutils.datamodel.YangType; |
29 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | 29 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; |
30 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 30 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
31 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; | 31 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; |
32 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ||
33 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | 32 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; |
33 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ||
34 | import org.onosproject.yangutils.translator.tojava.TempJavaBeanFragmentFiles; | 34 | import org.onosproject.yangutils.translator.tojava.TempJavaBeanFragmentFiles; |
35 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen; | 35 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen; |
36 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 36 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
37 | 37 | ||
38 | +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BINARY; | ||
39 | +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BITS; | ||
40 | +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BOOLEAN; | ||
38 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DECIMAL64; | 41 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DECIMAL64; |
39 | -import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT8; | 42 | +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.EMPTY; |
40 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT16; | 43 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT16; |
41 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32; | 44 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32; |
42 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT64; | 45 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT64; |
43 | -import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT8; | 46 | +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT8; |
44 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT16; | 47 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT16; |
45 | -import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BOOLEAN; | ||
46 | -import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT64; | ||
47 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT32; | 48 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT32; |
49 | +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT64; | ||
50 | +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT8; | ||
48 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 51 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
49 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 52 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
53 | +import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getJavaAttributeOfLeaf; | ||
54 | +import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getJavaAttributeOfLeafList; | ||
50 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentedClassNameForDataMethods; | 55 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentedClassNameForDataMethods; |
51 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods; | 56 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods; |
52 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getResolvedAugmentsForManager; | ||
53 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers; | 57 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers; |
54 | -import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getJavaAttributeOfLeaf; | ||
55 | -import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getJavaAttributeOfLeafList; | ||
56 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; | 58 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; |
57 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION; | 59 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION; |
58 | import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; | 60 | import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; |
59 | import static org.onosproject.yangutils.utils.UtilConstants.AND; | 61 | import static org.onosproject.yangutils.utils.UtilConstants.AND; |
60 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION; | 62 | +import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE; |
61 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED; | 63 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED; |
64 | +import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; | ||
62 | import static org.onosproject.yangutils.utils.UtilConstants.BASE64; | 65 | import static org.onosproject.yangutils.utils.UtilConstants.BASE64; |
66 | +import static org.onosproject.yangutils.utils.UtilConstants.BASE_CLASS; | ||
63 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL; | 67 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL; |
64 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; | 68 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; |
69 | +import static org.onosproject.yangutils.utils.UtilConstants.BITSET; | ||
65 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; | 70 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; |
66 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER; | 71 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER; |
67 | import static org.onosproject.yangutils.utils.UtilConstants.BUILD; | 72 | import static org.onosproject.yangutils.utils.UtilConstants.BUILD; |
... | @@ -75,6 +80,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.CLASS; | ... | @@ -75,6 +80,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.CLASS; |
75 | import static org.onosproject.yangutils.utils.UtilConstants.CLASS_STRING; | 80 | import static org.onosproject.yangutils.utils.UtilConstants.CLASS_STRING; |
76 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | 81 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
77 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | 82 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
83 | +import static org.onosproject.yangutils.utils.UtilConstants.COLAN; | ||
78 | import static org.onosproject.yangutils.utils.UtilConstants.COLON; | 84 | import static org.onosproject.yangutils.utils.UtilConstants.COLON; |
79 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | 85 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
80 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; | 86 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; |
... | @@ -91,17 +97,27 @@ import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING; | ... | @@ -91,17 +97,27 @@ import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING; |
91 | import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION; | 97 | import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION; |
92 | import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION_VAR; | 98 | import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION_VAR; |
93 | import static org.onosproject.yangutils.utils.UtilConstants.FALSE; | 99 | import static org.onosproject.yangutils.utils.UtilConstants.FALSE; |
100 | +import static org.onosproject.yangutils.utils.UtilConstants.FILTER_CONTENT_MATCH; | ||
101 | +import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF; | ||
102 | +import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF_LIST; | ||
94 | import static org.onosproject.yangutils.utils.UtilConstants.FOR; | 103 | import static org.onosproject.yangutils.utils.UtilConstants.FOR; |
95 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 104 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
96 | import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME; | 105 | import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME; |
97 | import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME; | 106 | import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME; |
98 | import static org.onosproject.yangutils.utils.UtilConstants.GET; | 107 | import static org.onosproject.yangutils.utils.UtilConstants.GET; |
99 | import static org.onosproject.yangutils.utils.UtilConstants.GET_DECODER; | 108 | import static org.onosproject.yangutils.utils.UtilConstants.GET_DECODER; |
109 | +import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF; | ||
110 | +import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF_LIST; | ||
100 | import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX; | 111 | import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX; |
112 | +import static org.onosproject.yangutils.utils.UtilConstants.GET_OPERATION_TYPE; | ||
113 | +import static org.onosproject.yangutils.utils.UtilConstants.GET_SELECT_LEAF; | ||
114 | +import static org.onosproject.yangutils.utils.UtilConstants.GET_SELECT_LEAF_LIST; | ||
101 | import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING; | 115 | import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING; |
102 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; | 116 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; |
103 | import static org.onosproject.yangutils.utils.UtilConstants.HASH_CODE_STRING; | 117 | import static org.onosproject.yangutils.utils.UtilConstants.HASH_CODE_STRING; |
104 | import static org.onosproject.yangutils.utils.UtilConstants.IF; | 118 | import static org.onosproject.yangutils.utils.UtilConstants.IF; |
119 | +import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ARGUMENT_EXCEPTION; | ||
120 | +import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ARGUMENT_EXCEPTION_MSG; | ||
105 | import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; | 121 | import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; |
106 | import static org.onosproject.yangutils.utils.UtilConstants.INT; | 122 | import static org.onosproject.yangutils.utils.UtilConstants.INT; |
107 | import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; | 123 | import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; |
... | @@ -111,6 +127,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER; | ... | @@ -111,6 +127,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER; |
111 | import static org.onosproject.yangutils.utils.UtilConstants.MAP; | 127 | import static org.onosproject.yangutils.utils.UtilConstants.MAP; |
112 | import static org.onosproject.yangutils.utils.UtilConstants.NEW; | 128 | import static org.onosproject.yangutils.utils.UtilConstants.NEW; |
113 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 129 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
130 | +import static org.onosproject.yangutils.utils.UtilConstants.NOT; | ||
114 | import static org.onosproject.yangutils.utils.UtilConstants.NULL; | 131 | import static org.onosproject.yangutils.utils.UtilConstants.NULL; |
115 | import static org.onosproject.yangutils.utils.UtilConstants.OBJ; | 132 | import static org.onosproject.yangutils.utils.UtilConstants.OBJ; |
116 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; | 133 | import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; |
... | @@ -119,6 +136,10 @@ import static org.onosproject.yangutils.utils.UtilConstants.OF; | ... | @@ -119,6 +136,10 @@ import static org.onosproject.yangutils.utils.UtilConstants.OF; |
119 | import static org.onosproject.yangutils.utils.UtilConstants.OMIT_NULL_VALUE_STRING; | 136 | import static org.onosproject.yangutils.utils.UtilConstants.OMIT_NULL_VALUE_STRING; |
120 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; | 137 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; |
121 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; | 138 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; |
139 | +import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; | ||
140 | +import static org.onosproject.yangutils.utils.UtilConstants.OPERATION_ENUM; | ||
141 | +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_TYPE; | ||
142 | +import static org.onosproject.yangutils.utils.UtilConstants.OR_OPERATION; | ||
122 | import static org.onosproject.yangutils.utils.UtilConstants.OTHER; | 143 | import static org.onosproject.yangutils.utils.UtilConstants.OTHER; |
123 | import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE; | 144 | import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE; |
124 | import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BOOLEAN; | 145 | import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BOOLEAN; |
... | @@ -129,15 +150,24 @@ import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT; | ... | @@ -129,15 +150,24 @@ import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT; |
129 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 150 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
130 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; | 151 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; |
131 | import static org.onosproject.yangutils.utils.UtilConstants.PUT; | 152 | import static org.onosproject.yangutils.utils.UtilConstants.PUT; |
153 | +import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK; | ||
132 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; | 154 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; |
155 | +import static org.onosproject.yangutils.utils.UtilConstants.RECEIVED_OBJECT; | ||
156 | +import static org.onosproject.yangutils.utils.UtilConstants.REPLACE_STRING; | ||
133 | import static org.onosproject.yangutils.utils.UtilConstants.RETURN; | 157 | import static org.onosproject.yangutils.utils.UtilConstants.RETURN; |
134 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; | 158 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; |
159 | +import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF; | ||
160 | +import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF_LIST; | ||
135 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 161 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
136 | import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX; | 162 | import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX; |
163 | +import static org.onosproject.yangutils.utils.UtilConstants.SET_OPERATION_TYPE; | ||
137 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT; | 164 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT; |
138 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER; | 165 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER; |
166 | +import static org.onosproject.yangutils.utils.UtilConstants.SINGLE_QUOTE; | ||
139 | import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION; | 167 | import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION; |
140 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 168 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
169 | +import static org.onosproject.yangutils.utils.UtilConstants.SPLIT_STRING; | ||
170 | +import static org.onosproject.yangutils.utils.UtilConstants.SQUARE_BRACKETS; | ||
141 | import static org.onosproject.yangutils.utils.UtilConstants.STARTED_LOG_INFO; | 171 | import static org.onosproject.yangutils.utils.UtilConstants.STARTED_LOG_INFO; |
142 | import static org.onosproject.yangutils.utils.UtilConstants.STATIC; | 172 | import static org.onosproject.yangutils.utils.UtilConstants.STATIC; |
143 | import static org.onosproject.yangutils.utils.UtilConstants.STOPPED_LOG_INFO; | 173 | import static org.onosproject.yangutils.utils.UtilConstants.STOPPED_LOG_INFO; |
... | @@ -145,39 +175,18 @@ import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; | ... | @@ -145,39 +175,18 @@ import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; |
145 | import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S; | 175 | import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S; |
146 | import static org.onosproject.yangutils.utils.UtilConstants.SWITCH; | 176 | import static org.onosproject.yangutils.utils.UtilConstants.SWITCH; |
147 | import static org.onosproject.yangutils.utils.UtilConstants.THIS; | 177 | import static org.onosproject.yangutils.utils.UtilConstants.THIS; |
178 | +import static org.onosproject.yangutils.utils.UtilConstants.THROW; | ||
148 | import static org.onosproject.yangutils.utils.UtilConstants.TMP_VAL; | 179 | import static org.onosproject.yangutils.utils.UtilConstants.TMP_VAL; |
149 | import static org.onosproject.yangutils.utils.UtilConstants.TO; | 180 | import static org.onosproject.yangutils.utils.UtilConstants.TO; |
181 | +import static org.onosproject.yangutils.utils.UtilConstants.TRIM_STRING; | ||
150 | import static org.onosproject.yangutils.utils.UtilConstants.TRUE; | 182 | import static org.onosproject.yangutils.utils.UtilConstants.TRUE; |
151 | import static org.onosproject.yangutils.utils.UtilConstants.TRY; | 183 | import static org.onosproject.yangutils.utils.UtilConstants.TRY; |
152 | import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; | 184 | import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; |
153 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; | 185 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; |
154 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; | 186 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
155 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; | 187 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; |
188 | +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO; | ||
156 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO; | 189 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO; |
157 | -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION; | ||
158 | -import static org.onosproject.yangutils.utils.UtilConstants.BITSET; | ||
159 | -import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF; | ||
160 | -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF; | ||
161 | -import static org.onosproject.yangutils.utils.UtilConstants.GET_SELECT_LEAF; | ||
162 | -import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF; | ||
163 | -import static org.onosproject.yangutils.utils.UtilConstants.GET_FILTER_LEAF_LIST; | ||
164 | -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_LEAF_LIST; | ||
165 | -import static org.onosproject.yangutils.utils.UtilConstants.GET_SELECT_LEAF_LIST; | ||
166 | -import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF_LIST; | ||
167 | -import static org.onosproject.yangutils.utils.UtilConstants.OPERATION_ENUM; | ||
168 | -import static org.onosproject.yangutils.utils.UtilConstants.GET_OPERATION_TYPE; | ||
169 | -import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM_TYPE; | ||
170 | -import static org.onosproject.yangutils.utils.UtilConstants.SET_OPERATION_TYPE; | ||
171 | -import static org.onosproject.yangutils.utils.UtilConstants.RECEIVED_OBJECT; | ||
172 | -import static org.onosproject.yangutils.utils.UtilConstants.FILTER_CONTENT_MATCH; | ||
173 | -import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE; | ||
174 | -import static org.onosproject.yangutils.utils.UtilConstants.NOT; | ||
175 | -import static org.onosproject.yangutils.utils.UtilConstants.OR_OPERATION; | ||
176 | -import static org.onosproject.yangutils.utils.UtilConstants.REPLACE_STRING; | ||
177 | -import static org.onosproject.yangutils.utils.UtilConstants.SINGLE_QUOTE; | ||
178 | -import static org.onosproject.yangutils.utils.UtilConstants.SPLIT_STRING; | ||
179 | -import static org.onosproject.yangutils.utils.UtilConstants.SQUARE_BRACKETS; | ||
180 | -import static org.onosproject.yangutils.utils.UtilConstants.TRIM_STRING; | ||
181 | import static org.onosproject.yangutils.utils.UtilConstants.ZERO; | 190 | import static org.onosproject.yangutils.utils.UtilConstants.ZERO; |
182 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD; | 191 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD; |
183 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR; | 192 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR; |
... | @@ -190,14 +199,11 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SET | ... | @@ -190,14 +199,11 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SET |
190 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; | 199 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; |
191 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForAddAugmentation; | 200 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForAddAugmentation; |
192 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForGetAugmentation; | 201 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForGetAugmentation; |
193 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForTypeConstructor; | ||
194 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | 202 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
195 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | 203 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
196 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 204 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
197 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | 205 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
198 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 206 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
199 | -import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BINARY; | ||
200 | -import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BITS; | ||
201 | 207 | ||
202 | /** | 208 | /** |
203 | * Represents generator for methods of generated files based on the file type. | 209 | * Represents generator for methods of generated files based on the file type. |
... | @@ -205,7 +211,6 @@ import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangData | ... | @@ -205,7 +211,6 @@ import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangData |
205 | public final class MethodsGenerator { | 211 | public final class MethodsGenerator { |
206 | private static final String BITS_STRING_ARRAY_VAR = "bitsTemp"; | 212 | private static final String BITS_STRING_ARRAY_VAR = "bitsTemp"; |
207 | private static final String BIT_TEMP_VAR = "bitTemp"; | 213 | private static final String BIT_TEMP_VAR = "bitTemp"; |
208 | - private static final String FOR_TYPE = " for type "; | ||
209 | 214 | ||
210 | /** | 215 | /** |
211 | * Creates an instance of method generator. | 216 | * Creates an instance of method generator. |
... | @@ -588,9 +593,9 @@ public final class MethodsGenerator { | ... | @@ -588,9 +593,9 @@ public final class MethodsGenerator { |
588 | /** | 593 | /** |
589 | * Returns constructor string for op param class. | 594 | * Returns constructor string for op param class. |
590 | * | 595 | * |
591 | - * @param yangName class name | 596 | + * @param yangName class name |
592 | - * @param pluginConfig plugin configurations | 597 | + * @param pluginConfig plugin configurations |
593 | - * @return constructor string | 598 | + * @return constructor string |
594 | */ | 599 | */ |
595 | public static String getOpParamConstructorStart(String yangName, YangPluginConfig pluginConfig) { | 600 | public static String getOpParamConstructorStart(String yangName, YangPluginConfig pluginConfig) { |
596 | 601 | ||
... | @@ -600,6 +605,7 @@ public final class MethodsGenerator { | ... | @@ -600,6 +605,7 @@ public final class MethodsGenerator { |
600 | + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 605 | + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
601 | return javadoc + constructor; | 606 | return javadoc + constructor; |
602 | } | 607 | } |
608 | + | ||
603 | /** | 609 | /** |
604 | * Returns the constructor strings for class file. | 610 | * Returns the constructor strings for class file. |
605 | * | 611 | * |
... | @@ -718,11 +724,11 @@ public final class MethodsGenerator { | ... | @@ -718,11 +724,11 @@ public final class MethodsGenerator { |
718 | /** | 724 | /** |
719 | * Returns to string leaf for get method. | 725 | * Returns to string leaf for get method. |
720 | * | 726 | * |
721 | - * @return string leaf for get method | 727 | + * @return string leaf for get method |
722 | */ | 728 | */ |
723 | public static String getToStringLeafgetter() { | 729 | public static String getToStringLeafgetter() { |
724 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_FILTER_LEAF | 730 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_FILTER_LEAF |
725 | - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE | 731 | + + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
726 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + FILTER_LEAF + SEMI_COLAN + NEW_LINE | 732 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + FILTER_LEAF + SEMI_COLAN + NEW_LINE |
727 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | 733 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
728 | } | 734 | } |
... | @@ -734,7 +740,7 @@ public final class MethodsGenerator { | ... | @@ -734,7 +740,7 @@ public final class MethodsGenerator { |
734 | */ | 740 | */ |
735 | public static String getToStringSelectLeafgetter() { | 741 | public static String getToStringSelectLeafgetter() { |
736 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_SELECT_LEAF | 742 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_SELECT_LEAF |
737 | - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE | 743 | + + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
738 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + SELECT_LEAF + SEMI_COLAN + NEW_LINE | 744 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + SELECT_LEAF + SEMI_COLAN + NEW_LINE |
739 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | 745 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
740 | } | 746 | } |
... | @@ -742,11 +748,11 @@ public final class MethodsGenerator { | ... | @@ -742,11 +748,11 @@ public final class MethodsGenerator { |
742 | /** | 748 | /** |
743 | * Returns to string leaf list for get method. | 749 | * Returns to string leaf list for get method. |
744 | * | 750 | * |
745 | - * @return string leaf list for get method | 751 | + * @return string leaf list for get method |
746 | */ | 752 | */ |
747 | public static String getToStringLeafListgetter() { | 753 | public static String getToStringLeafListgetter() { |
748 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_FILTER_LEAF_LIST | 754 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_FILTER_LEAF_LIST |
749 | - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE | 755 | + + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
750 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + FILTER_LEAF_LIST + SEMI_COLAN + NEW_LINE | 756 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + FILTER_LEAF_LIST + SEMI_COLAN + NEW_LINE |
751 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | 757 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
752 | } | 758 | } |
... | @@ -758,7 +764,7 @@ public final class MethodsGenerator { | ... | @@ -758,7 +764,7 @@ public final class MethodsGenerator { |
758 | */ | 764 | */ |
759 | public static String getToStringSelectLeafListgetter() { | 765 | public static String getToStringSelectLeafListgetter() { |
760 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_SELECT_LEAF_LIST | 766 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BITSET + SPACE + GET_SELECT_LEAF_LIST |
761 | - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE | 767 | + + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE |
762 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + SELECT_LEAF_LIST + SEMI_COLAN + NEW_LINE | 768 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + SELECT_LEAF_LIST + SEMI_COLAN + NEW_LINE |
763 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | 769 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
764 | } | 770 | } |
... | @@ -770,7 +776,7 @@ public final class MethodsGenerator { | ... | @@ -770,7 +776,7 @@ public final class MethodsGenerator { |
770 | */ | 776 | */ |
771 | public static String getOperationTypegetter() { | 777 | public static String getOperationTypegetter() { |
772 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + OPERATION_ENUM | 778 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + OPERATION_ENUM |
773 | - + SPACE + GET_OPERATION_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE | 779 | + + SPACE + GET_OPERATION_TYPE + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE |
774 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE | 780 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE |
775 | + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | 781 | + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
776 | } | 782 | } |
... | @@ -782,7 +788,7 @@ public final class MethodsGenerator { | ... | @@ -782,7 +788,7 @@ public final class MethodsGenerator { |
782 | */ | 788 | */ |
783 | public static String getOperationTypeSetter() { | 789 | public static String getOperationTypeSetter() { |
784 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_OPERATION_TYPE | 790 | return NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_OPERATION_TYPE |
785 | - + OPEN_PARENTHESIS + OPERATION_ENUM + SPACE + getSmallCase(OPERATION_ENUM) + CLOSE_PARENTHESIS | 791 | + + OPEN_PARENTHESIS + OPERATION_ENUM + SPACE + getSmallCase(OPERATION_ENUM) + CLOSE_PARENTHESIS |
786 | + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + THIS + PERIOD | 792 | + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + THIS + PERIOD |
787 | + OP_PARAM_TYPE + SPACE + EQUAL + SPACE + getSmallCase(OPERATION_ENUM) + SEMI_COLAN + NEW_LINE | 793 | + OP_PARAM_TYPE + SPACE + EQUAL + SPACE + getSmallCase(OPERATION_ENUM) + SEMI_COLAN + NEW_LINE |
788 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; | 794 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; |
... | @@ -791,10 +797,10 @@ public final class MethodsGenerator { | ... | @@ -791,10 +797,10 @@ public final class MethodsGenerator { |
791 | /** | 797 | /** |
792 | * Returns string for leaf set method. | 798 | * Returns string for leaf set method. |
793 | * | 799 | * |
794 | - * @param className class name | 800 | + * @param className class name |
795 | - * @param curnode current YANG node | 801 | + * @param curnode current YANG node |
796 | * @param pluginConfig plugin configurations | 802 | * @param pluginConfig plugin configurations |
797 | - * @return string for leaf set method | 803 | + * @return string for leaf set method |
798 | */ | 804 | */ |
799 | public static String getSetterForLeaf(String className, YangNode curnode, YangPluginConfig pluginConfig) { | 805 | public static String getSetterForLeaf(String className, YangNode curnode, YangPluginConfig pluginConfig) { |
800 | 806 | ||
... | @@ -831,9 +837,9 @@ public final class MethodsGenerator { | ... | @@ -831,9 +837,9 @@ public final class MethodsGenerator { |
831 | /** | 837 | /** |
832 | * Returns string for leaf list set method. | 838 | * Returns string for leaf list set method. |
833 | * | 839 | * |
834 | - * @param className class name | 840 | + * @param className class name |
835 | - * @param curnode current YANG node | 841 | + * @param curnode current YANG node |
836 | - * @param pluginConfig plugin configurations | 842 | + * @param pluginConfig plugin configurations |
837 | * @return string for leaf list set method | 843 | * @return string for leaf list set method |
838 | */ | 844 | */ |
839 | public static String getSetterForLeafList(String className, YangNode curnode, YangPluginConfig pluginConfig) { | 845 | public static String getSetterForLeafList(String className, YangNode curnode, YangPluginConfig pluginConfig) { |
... | @@ -849,7 +855,7 @@ public final class MethodsGenerator { | ... | @@ -849,7 +855,7 @@ public final class MethodsGenerator { |
849 | if (listOfLeafList != null && !listOfLeafList.isEmpty()) { | 855 | if (listOfLeafList != null && !listOfLeafList.isEmpty()) { |
850 | for (YangLeafList leafList : listOfLeafList) { | 856 | for (YangLeafList leafList : listOfLeafList) { |
851 | JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList, | 857 | JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList, |
852 | - pluginConfig); | 858 | + pluginConfig); |
853 | String attributeName = javaAttributeInfo.getAttributeName(); | 859 | String attributeName = javaAttributeInfo.getAttributeName(); |
854 | String attrQuaifiedType = getReturnType(javaAttributeInfo); | 860 | String attrQuaifiedType = getReturnType(javaAttributeInfo); |
855 | if (javaAttributeInfo.isListAttr()) { | 861 | if (javaAttributeInfo.isListAttr()) { |
... | @@ -888,38 +894,44 @@ public final class MethodsGenerator { | ... | @@ -888,38 +894,44 @@ public final class MethodsGenerator { |
888 | || dataType == UINT32 | 894 | || dataType == UINT32 |
889 | || dataType == UINT64 | 895 | || dataType == UINT64 |
890 | || dataType == DECIMAL64 | 896 | || dataType == DECIMAL64 |
891 | - || dataType == BOOLEAN; | 897 | + || dataType == BOOLEAN |
898 | + || dataType == EMPTY; | ||
892 | } | 899 | } |
893 | 900 | ||
894 | /** | 901 | /** |
895 | * Returns string for is filter content match method. | 902 | * Returns string for is filter content match method. |
896 | * | 903 | * |
897 | - * @param className class name | 904 | + * @param className class name |
898 | - * @param curnode current YANG node | 905 | + * @param curNode current YANG node |
899 | - * @param pluginConfig plugin configurations | 906 | + * @param pluginConfig plugin configurations |
900 | - * @return string for is filter content match method | 907 | + * @return string for is filter content match method |
901 | */ | 908 | */ |
902 | - public static String getisFilterContentMatch(String className, YangNode curnode, YangPluginConfig pluginConfig) { | 909 | + public static String getIsFilterContentMatch(String className, YangNode curNode, YangPluginConfig pluginConfig) { |
903 | 910 | ||
904 | int numleaf = 1; | 911 | int numleaf = 1; |
905 | - String filterMethod = ""; | 912 | + String filterMethod = NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE |
906 | - TempJavaBeanFragmentFiles tempFragmentFiles = ((JavaCodeGeneratorInfo) curnode) | 913 | + + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + getCapitalCase(OBJECT) |
914 | + + SPACE + OBJ + | ||
915 | + CLOSE_PARENTHESIS + SPACE | ||
916 | + + OPEN_CURLY_BRACKET + NEW_LINE; | ||
917 | + TempJavaBeanFragmentFiles tempFragmentFiles = ((JavaCodeGeneratorInfo) curNode) | ||
907 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); | 918 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); |
919 | + filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + getCapitalCase(DEFAULT) | ||
920 | + + getCapitalCase(className) + SPACE + APP_INSTANCE + SPACE + EQUAL + SPACE + OPEN_PARENTHESIS + | ||
921 | + getCapitalCase(DEFAULT) + getCapitalCase(className) + CLOSE_PARENTHESIS + OBJ + | ||
922 | + SEMI_COLAN + NEW_LINE; | ||
923 | + if (curNode instanceof YangAugmentableNode) { | ||
924 | + filterMethod = filterMethod + getAugmentableOpParamSyntax(); | ||
925 | + } | ||
908 | 926 | ||
909 | - if (curnode instanceof YangLeavesHolder) { | 927 | + if (curNode instanceof YangLeavesHolder) { |
910 | - YangLeavesHolder leavesHolder = (YangLeavesHolder) curnode; | 928 | + YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode; |
911 | List<YangLeaf> leaves = leavesHolder.getListOfLeaf(); | 929 | List<YangLeaf> leaves = leavesHolder.getListOfLeaf(); |
912 | List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList(); | 930 | List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList(); |
913 | - if (leaves != null || listOfLeafList != null) { | 931 | + if (leaves != null) { |
914 | - filterMethod = NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE | ||
915 | - + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + getCapitalCase(DEFAULT) | ||
916 | - + getCapitalCase(className) + SPACE + APP_INSTANCE + CLOSE_PARENTHESIS + SPACE | ||
917 | - + OPEN_CURLY_BRACKET + NEW_LINE; | ||
918 | - } | ||
919 | - if (leaves != null) { | ||
920 | for (YangLeaf leaf : leaves) { | 932 | for (YangLeaf leaf : leaves) { |
921 | JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeaf(tempFragmentFiles, leaf, | 933 | JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeaf(tempFragmentFiles, leaf, |
922 | - pluginConfig); | 934 | + pluginConfig); |
923 | String attributeName = javaAttributeInfo.getAttributeName(); | 935 | String attributeName = javaAttributeInfo.getAttributeName(); |
924 | 936 | ||
925 | String attrQuaifiedType = ""; | 937 | String attrQuaifiedType = ""; |
... | @@ -929,10 +941,10 @@ public final class MethodsGenerator { | ... | @@ -929,10 +941,10 @@ public final class MethodsGenerator { |
929 | + CLOSE_PARENTHESIS; | 941 | + CLOSE_PARENTHESIS; |
930 | } else { | 942 | } else { |
931 | attrQuaifiedType = APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS | 943 | attrQuaifiedType = APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS |
932 | - + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION + SPACE + OPEN_PARENTHESIS | 944 | + + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION + SPACE |
933 | + NOT + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS | 945 | + NOT + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS |
934 | + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD | 946 | + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD |
935 | - + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS | 947 | + + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS |
936 | + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS; | 948 | + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS; |
937 | } | 949 | } |
938 | 950 | ||
... | @@ -948,11 +960,11 @@ public final class MethodsGenerator { | ... | @@ -948,11 +960,11 @@ public final class MethodsGenerator { |
948 | } | 960 | } |
949 | } | 961 | } |
950 | 962 | ||
951 | - if (listOfLeafList != null) { | 963 | + if (listOfLeafList != null) { |
952 | numleaf = 1; | 964 | numleaf = 1; |
953 | for (YangLeafList leafList : listOfLeafList) { | 965 | for (YangLeafList leafList : listOfLeafList) { |
954 | JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList, | 966 | JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList, |
955 | - pluginConfig); | 967 | + pluginConfig); |
956 | String attributeName = javaAttributeInfo.getAttributeName(); | 968 | String attributeName = javaAttributeInfo.getAttributeName(); |
957 | String attrQuaifiedType = ""; | 969 | String attrQuaifiedType = ""; |
958 | if (isPrimitiveDataType(leafList.getDataType().getDataType())) { | 970 | if (isPrimitiveDataType(leafList.getDataType().getDataType())) { |
... | @@ -964,7 +976,8 @@ public final class MethodsGenerator { | ... | @@ -964,7 +976,8 @@ public final class MethodsGenerator { |
964 | + SPACE + EQUAL + EQUAL + SPACE + NULL + OR_OPERATION + OPEN_PARENTHESIS + NOT | 976 | + SPACE + EQUAL + EQUAL + SPACE + NULL + OR_OPERATION + OPEN_PARENTHESIS + NOT |
965 | + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS | 977 | + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS |
966 | + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD | 978 | + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD |
967 | - + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS; | 979 | + + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS |
980 | + + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS; | ||
968 | } | 981 | } |
969 | 982 | ||
970 | filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS | 983 | filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS |
... | @@ -987,8 +1000,53 @@ public final class MethodsGenerator { | ... | @@ -987,8 +1000,53 @@ public final class MethodsGenerator { |
987 | return filterMethod; | 1000 | return filterMethod; |
988 | } | 1001 | } |
989 | 1002 | ||
990 | - /** | 1003 | + /*Returns method string for op parms augmented syntax*/ |
991 | - * Returns omit null value string. | 1004 | + private static String getAugmentableOpParamSyntax() { |
1005 | + return EIGHT_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + YANG_AUGMENTED_INFO + SPACE + | ||
1006 | + getSmallCase(YANG_AUGMENTED_INFO) + SPACE + COLAN + SPACE + APP_INSTANCE + | ||
1007 | + PERIOD + GET_METHOD_PREFIX + YANG_AUGMENTED_INFO + MAP + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD | ||
1008 | + + VALUE + "s" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + | ||
1009 | + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + NOT + OPEN_PARENTHESIS + | ||
1010 | + getSmallCase(YANG_AUGMENTED_INFO) + SPACE + INSTANCE_OF + SPACE + YANG_AUGMENTED_OP_PARAM_INFO + | ||
1011 | + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + | ||
1012 | + SIXTEEN_SPACE_INDENTATION + THROW + SPACE + NEW + SPACE + ILLEGAL_ARGUMENT_EXCEPTION + | ||
1013 | + OPEN_PARENTHESIS + | ||
1014 | + ILLEGAL_ARGUMENT_EXCEPTION_MSG + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + | ||
1015 | + CLOSE_CURLY_BRACKET + NEW_LINE + NEW_LINE + TWELVE_SPACE_INDENTATION + YANG_AUGMENTED_INFO + SPACE + | ||
1016 | + getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO) + SPACE + EQUAL + SPACE + APP_INSTANCE + PERIOD + | ||
1017 | + GET_METHOD_PREFIX + AUGMENTED_INFO + OPEN_PARENTHESIS + OPEN_PARENTHESIS + OPEN_PARENTHESIS + | ||
1018 | + YANG_AUGMENTED_OP_PARAM_INFO + CLOSE_PARENTHESIS + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + | ||
1019 | + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX + BASE_CLASS + CLOSE_PARENTHESIS + SEMI_COLAN + | ||
1020 | + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + OPEN_PARENTHESIS + NOT + | ||
1021 | + OPEN_PARENTHESIS + OPEN_PARENTHESIS + YANG_AUGMENTED_OP_PARAM_INFO + CLOSE_PARENTHESIS + SPACE + | ||
1022 | + getSmallCase(YANG_AUGMENTED_INFO) + CLOSE_PARENTHESIS | ||
1023 | + + PERIOD + "isFilterContentMatch" + OPEN_PARENTHESIS + | ||
1024 | + getSmallCase(YANG_AUGMENTED_OP_PARAM_INFO) + CLOSE_PARENTHESIS + | ||
1025 | + CLOSE_PARENTHESIS + | ||
1026 | + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE + | ||
1027 | + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION | ||
1028 | + + CLOSE_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; | ||
1029 | + } | ||
1030 | + | ||
1031 | + /** | ||
1032 | + * Returns implementation of get base class method for op param files. | ||
1033 | + * | ||
1034 | + * @param baseClassName base class name | ||
1035 | + * @return implementation of get base class method for op param files | ||
1036 | + */ | ||
1037 | + public static String getBaseClassMethodImpl(String baseClassName) { | ||
1038 | + return NEW_LINE + getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_STRING + | ||
1039 | + DIAMOND_OPEN_BRACKET + | ||
1040 | + QUESTION_MARK + | ||
1041 | + DIAMOND_CLOSE_BRACKET + SPACE + GET_METHOD_PREFIX + BASE_CLASS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + | ||
1042 | + EIGHT_SPACE_INDENTATION + RETURN + SPACE + baseClassName + PERIOD + CLASS + SEMI_COLAN + NEW_LINE + | ||
1043 | + FOUR_SPACE_INDENTATION + | ||
1044 | + CLOSE_CURLY_BRACKET; | ||
1045 | + | ||
1046 | + } | ||
1047 | + | ||
1048 | + /* | ||
1049 | + * Retruns omit null value string. | ||
992 | * | 1050 | * |
993 | * @return omit null value string | 1051 | * @return omit null value string |
994 | */ | 1052 | */ |
... | @@ -1047,8 +1105,7 @@ public final class MethodsGenerator { | ... | @@ -1047,8 +1105,7 @@ public final class MethodsGenerator { |
1047 | * Return from string method's body string. | 1105 | * Return from string method's body string. |
1048 | * | 1106 | * |
1049 | * @param attr attribute info | 1107 | * @param attr attribute info |
1050 | - * @param fromStringAttributeInfo attribute info for the from string | 1108 | + * @param fromStringAttributeInfo attribute info for the from string wrapper type |
1051 | - * wrapper type | ||
1052 | * @return from string method's body string | 1109 | * @return from string method's body string |
1053 | */ | 1110 | */ |
1054 | public static String getFromStringMethod(JavaAttributeInfo attr, | 1111 | public static String getFromStringMethod(JavaAttributeInfo attr, |
... | @@ -1128,7 +1185,7 @@ public final class MethodsGenerator { | ... | @@ -1128,7 +1185,7 @@ public final class MethodsGenerator { |
1128 | + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SEMI_COLAN; | 1185 | + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SEMI_COLAN; |
1129 | } else { | 1186 | } else { |
1130 | String parseFromStringMethod = getParseFromStringMethod(targetDataType, | 1187 | String parseFromStringMethod = getParseFromStringMethod(targetDataType, |
1131 | - fromStringAttributeInfo.getAttributeType()); | 1188 | + fromStringAttributeInfo.getAttributeType()); |
1132 | return targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + parseFromStringMethod | 1189 | return targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + parseFromStringMethod |
1133 | + OPEN_PARENTHESIS + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SEMI_COLAN; | 1190 | + OPEN_PARENTHESIS + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SEMI_COLAN; |
1134 | } | 1191 | } |
... | @@ -1324,13 +1381,12 @@ public final class MethodsGenerator { | ... | @@ -1324,13 +1381,12 @@ public final class MethodsGenerator { |
1324 | * | 1381 | * |
1325 | * @return implementation of add augmentation | 1382 | * @return implementation of add augmentation |
1326 | */ | 1383 | */ |
1327 | - public static String getAddAugmentInfoMethodImpl() { | 1384 | + static String getAddAugmentInfoMethodImpl() { |
1328 | - return NEW_LINE + generateForAddAugmentation() + FOUR_SPACE_INDENTATION + | 1385 | + return NEW_LINE + generateForAddAugmentation() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + |
1329 | - PUBLIC + SPACE + VOID + SPACE + ADD_STRING | 1386 | + ADD_STRING + AUGMENTED_INFO + OPEN_PARENTHESIS + YANG_AUGMENTED_INFO + SPACE + VALUE + COMMA + |
1330 | - + AUGMENTATION + OPEN_PARENTHESIS + YANG_AUGMENTED_INFO + SPACE + VALUE + COMMA + SPACE + CLASS_STRING + | 1387 | + SPACE + CLASS_STRING + SPACE + CLASS + OBJECT_STRING + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + |
1331 | - SPACE + CLASS + OBJECT_STRING + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + | 1388 | + NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + PUT + |
1332 | - EIGHT_SPACE_INDENTATION + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + PUT + OPEN_PARENTHESIS + | 1389 | + OPEN_PARENTHESIS + CLASS + OBJECT_STRING + COMMA + SPACE + VALUE + |
1333 | - CLASS + OBJECT_STRING + COMMA + SPACE + VALUE + | ||
1334 | CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + | 1390 | CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + |
1335 | CLOSE_CURLY_BRACKET + NEW_LINE; | 1391 | CLOSE_CURLY_BRACKET + NEW_LINE; |
1336 | } | 1392 | } |
... | @@ -1340,11 +1396,11 @@ public final class MethodsGenerator { | ... | @@ -1340,11 +1396,11 @@ public final class MethodsGenerator { |
1340 | * | 1396 | * |
1341 | * @return implementation of get augment info | 1397 | * @return implementation of get augment info |
1342 | */ | 1398 | */ |
1343 | - public static String getAugmentInfoImpl() { | 1399 | + static String getAugmentInfoImpl() { |
1344 | 1400 | ||
1345 | return generateForGetAugmentation() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + | 1401 | return generateForGetAugmentation() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + |
1346 | YANG_AUGMENTED_INFO + SPACE + GET_METHOD_PREFIX + | 1402 | YANG_AUGMENTED_INFO + SPACE + GET_METHOD_PREFIX + |
1347 | - YANG_AUGMENTED_INFO + OPEN_PARENTHESIS + CLASS_STRING + SPACE + CLASS + OBJECT_STRING + | 1403 | + AUGMENTED_INFO + OPEN_PARENTHESIS + CLASS_STRING + SPACE + CLASS + OBJECT_STRING + |
1348 | CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + | 1404 | CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + |
1349 | RETURN + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + GET + OPEN_PARENTHESIS + CLASS + | 1405 | RETURN + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + GET + OPEN_PARENTHESIS + CLASS + |
1350 | OBJECT_STRING + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + | 1406 | OBJECT_STRING + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + |
... | @@ -1352,6 +1408,23 @@ public final class MethodsGenerator { | ... | @@ -1352,6 +1408,23 @@ public final class MethodsGenerator { |
1352 | } | 1408 | } |
1353 | 1409 | ||
1354 | /** | 1410 | /** |
1411 | + * Returns implementation of get augment info. | ||
1412 | + * | ||
1413 | + * @return implementation of get augment info | ||
1414 | + */ | ||
1415 | + static String getAugmentInfoMapImpl(YangPluginConfig pluginConfig) { | ||
1416 | + | ||
1417 | + return getJavaDoc(GETTER_METHOD, getSmallCase(YANG_AUGMENTED_INFO) + MAP, false, pluginConfig) | ||
1418 | + + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + | ||
1419 | + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING + DIAMOND_OPEN_BRACKET + QUESTION_MARK + | ||
1420 | + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + YANG_AUGMENTED_INFO + DIAMOND_CLOSE_BRACKET + SPACE + | ||
1421 | + GET_METHOD_PREFIX + YANG_AUGMENTED_INFO + MAP + OPEN_PARENTHESIS + | ||
1422 | + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + | ||
1423 | + RETURN + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SEMI_COLAN + NEW_LINE | ||
1424 | + + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; | ||
1425 | + } | ||
1426 | + | ||
1427 | + /** | ||
1355 | * Returns enum's constructor. | 1428 | * Returns enum's constructor. |
1356 | * | 1429 | * |
1357 | * @param className enum's class name | 1430 | * @param className enum's class name |
... | @@ -1396,7 +1469,7 @@ public final class MethodsGenerator { | ... | @@ -1396,7 +1469,7 @@ public final class MethodsGenerator { |
1396 | + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET | 1469 | + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET |
1397 | + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | 1470 | + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
1398 | 1471 | ||
1399 | - return getJavaDoc(OF_METHOD, getCapitalCase(className) + FOR_TYPE + attrName, false, pluginConfig) | 1472 | + return getJavaDoc(OF_METHOD, getCapitalCase(className) + " for type" + attrName, false, pluginConfig) |
1400 | + method; | 1473 | + method; |
1401 | } | 1474 | } |
1402 | 1475 | ||
... | @@ -1475,24 +1548,6 @@ public final class MethodsGenerator { | ... | @@ -1475,24 +1548,6 @@ public final class MethodsGenerator { |
1475 | } | 1548 | } |
1476 | 1549 | ||
1477 | /** | 1550 | /** |
1478 | - * Returns copy constructor for augmented class. | ||
1479 | - * | ||
1480 | - * @param yangName augmente class name | ||
1481 | - * @param augmentName augmented class name | ||
1482 | - * @return copy constructor for augmented class | ||
1483 | - */ | ||
1484 | - public static String getAugmentedNodesConstructorStart(String yangName, | ||
1485 | - String augmentName) { | ||
1486 | - | ||
1487 | - String javadoc = generateForTypeConstructor(yangName); | ||
1488 | - String constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + BUILDER + OPEN_PARENTHESIS | ||
1489 | - + augmentName + PERIOD + augmentName + BUILDER + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE | ||
1490 | - + OPEN_CURLY_BRACKET + NEW_LINE; | ||
1491 | - return javadoc + constructor; | ||
1492 | - | ||
1493 | - } | ||
1494 | - | ||
1495 | - /** | ||
1496 | * Returns the constructor strings for class file. | 1551 | * Returns the constructor strings for class file. |
1497 | * | 1552 | * |
1498 | * @param attr attribute info | 1553 | * @param attr attribute info |
... | @@ -1514,8 +1569,7 @@ public final class MethodsGenerator { | ... | @@ -1514,8 +1569,7 @@ public final class MethodsGenerator { |
1514 | * @param parent parent node | 1569 | * @param parent parent node |
1515 | * @return augmented data getter and setter methods for service class | 1570 | * @return augmented data getter and setter methods for service class |
1516 | */ | 1571 | */ |
1517 | - public static String getAugmentsDataMethodForService(YangNode parent) { | 1572 | + static String getAugmentsDataMethodForService(YangNode parent) { |
1518 | - Map<YangAtomicPath, YangAugment> resolvedAugmentsForManager = getResolvedAugmentsForManager(parent); | ||
1519 | List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent); | 1573 | List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent); |
1520 | YangNode augmentedNode; | 1574 | YangNode augmentedNode; |
1521 | String curNodeName; | 1575 | String curNodeName; |
... | @@ -1525,7 +1579,7 @@ public final class MethodsGenerator { | ... | @@ -1525,7 +1579,7 @@ public final class MethodsGenerator { |
1525 | String returnType; | 1579 | String returnType; |
1526 | YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig(); | 1580 | YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig(); |
1527 | for (YangAtomicPath nodeId : targets) { | 1581 | for (YangAtomicPath nodeId : targets) { |
1528 | - augmentedNode = resolvedAugmentsForManager.get(nodeId).getResolveNodeInPath().get(nodeId); | 1582 | + augmentedNode = nodeId.getResolvedNode().getParent(); |
1529 | if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) { | 1583 | if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) { |
1530 | curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName(); | 1584 | curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName(); |
1531 | } else { | 1585 | } else { |
... | @@ -1533,7 +1587,7 @@ public final class MethodsGenerator { | ... | @@ -1533,7 +1587,7 @@ public final class MethodsGenerator { |
1533 | .getConflictResolver())); | 1587 | .getConflictResolver())); |
1534 | } | 1588 | } |
1535 | returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent); | 1589 | returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent); |
1536 | - parentName = getParentNodeNameForDataMethods(augmentedNode.getParent(), pluginConfig); | 1590 | + parentName = getParentNodeNameForDataMethods(augmentedNode, pluginConfig); |
1537 | method = getJavaDoc(GETTER_METHOD, getSmallCase(AUGMENTED + parentName + curNodeName), false, | 1591 | method = getJavaDoc(GETTER_METHOD, getSmallCase(AUGMENTED + parentName + curNodeName), false, |
1538 | pluginConfig) + getGetterForInterface(AUGMENTED + parentName | 1592 | pluginConfig) + getGetterForInterface(AUGMENTED + parentName |
1539 | + getCapitalCase(curNodeName), | 1593 | + getCapitalCase(curNodeName), |
... | @@ -1558,8 +1612,7 @@ public final class MethodsGenerator { | ... | @@ -1558,8 +1612,7 @@ public final class MethodsGenerator { |
1558 | * @param parent parent node | 1612 | * @param parent parent node |
1559 | * @return augmented data getter and setter methods for manager class | 1613 | * @return augmented data getter and setter methods for manager class |
1560 | */ | 1614 | */ |
1561 | - public static String getAugmentsDataMethodForManager(YangNode parent) { | 1615 | + static String getAugmentsDataMethodForManager(YangNode parent) { |
1562 | - Map<YangAtomicPath, YangAugment> resolvedAugmentsForManager = getResolvedAugmentsForManager(parent); | ||
1563 | List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent); | 1616 | List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent); |
1564 | YangNode augmentedNode; | 1617 | YangNode augmentedNode; |
1565 | String curNodeName; | 1618 | String curNodeName; |
... | @@ -1569,7 +1622,7 @@ public final class MethodsGenerator { | ... | @@ -1569,7 +1622,7 @@ public final class MethodsGenerator { |
1569 | String parentName; | 1622 | String parentName; |
1570 | YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig(); | 1623 | YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig(); |
1571 | for (YangAtomicPath nodeId : targets) { | 1624 | for (YangAtomicPath nodeId : targets) { |
1572 | - augmentedNode = resolvedAugmentsForManager.get(nodeId).getResolveNodeInPath().get(nodeId); | 1625 | + augmentedNode = nodeId.getResolvedNode().getParent(); |
1573 | if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) { | 1626 | if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) { |
1574 | curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName(); | 1627 | curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName(); |
1575 | } else { | 1628 | } else { |
... | @@ -1577,7 +1630,7 @@ public final class MethodsGenerator { | ... | @@ -1577,7 +1630,7 @@ public final class MethodsGenerator { |
1577 | .getConflictResolver())); | 1630 | .getConflictResolver())); |
1578 | } | 1631 | } |
1579 | returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent); | 1632 | returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent); |
1580 | - parentName = getParentNodeNameForDataMethods(augmentedNode.getParent(), pluginConfig); | 1633 | + parentName = getParentNodeNameForDataMethods(augmentedNode, pluginConfig); |
1581 | method = getOverRideString() + getGetter(returnType, AUGMENTED | 1634 | method = getOverRideString() + getGetter(returnType, AUGMENTED |
1582 | + parentName + getCapitalCase(curNodeName), | 1635 | + parentName + getCapitalCase(curNodeName), |
1583 | GENERATE_SERVICE_AND_MANAGER) + NEW_LINE; | 1636 | GENERATE_SERVICE_AND_MANAGER) + NEW_LINE; | ... | ... |
... | @@ -517,11 +517,6 @@ public final class UtilConstants { | ... | @@ -517,11 +517,6 @@ public final class UtilConstants { |
517 | public static final String IF = "if"; | 517 | public static final String IF = "if"; |
518 | 518 | ||
519 | /** | 519 | /** |
520 | - * Static attribute for "for" syntax. | ||
521 | - */ | ||
522 | - public static final String FOR = "for"; | ||
523 | - | ||
524 | - /** | ||
525 | * Static attribute for of. | 520 | * Static attribute for of. |
526 | */ | 521 | */ |
527 | public static final String OF = "of"; | 522 | public static final String OF = "of"; |
... | @@ -1185,7 +1180,7 @@ public final class UtilConstants { | ... | @@ -1185,7 +1180,7 @@ public final class UtilConstants { |
1185 | /** | 1180 | /** |
1186 | * Static attribute for augmentation class. | 1181 | * Static attribute for augmentation class. |
1187 | */ | 1182 | */ |
1188 | - public static final String AUGMENTATION = "Augmentation"; | 1183 | + public static final String AUGMENTED_INFO = "AugmentedInfo"; |
1189 | 1184 | ||
1190 | /** | 1185 | /** |
1191 | * Static attribute for AugmentedInfo class. | 1186 | * Static attribute for AugmentedInfo class. |
... | @@ -1383,6 +1378,43 @@ public final class UtilConstants { | ... | @@ -1383,6 +1378,43 @@ public final class UtilConstants { |
1383 | public static final String JAR = "jar"; | 1378 | public static final String JAR = "jar"; |
1384 | 1379 | ||
1385 | /** | 1380 | /** |
1381 | + * Static attribute for for. | ||
1382 | + */ | ||
1383 | + public static final String FOR = "for"; | ||
1384 | + | ||
1385 | + /** | ||
1386 | + * Static attribute for YangAugmentedOpParamInfo. | ||
1387 | + */ | ||
1388 | + public static final String YANG_AUGMENTED_OP_PARAM_INFO = "YangAugmentedOpParamInfo"; | ||
1389 | + | ||
1390 | + /** | ||
1391 | + * Static attribute for YangAugmentedOpParamInfo. | ||
1392 | + */ | ||
1393 | + public static final String YANG_AUGMENTED_OP_PARAM_INFO_CLASS = "YangAugmentedOpParamInfo;\n"; | ||
1394 | + | ||
1395 | + /** | ||
1396 | + * Static attribute for IllegalArgumentException. | ||
1397 | + */ | ||
1398 | + public static final String ILLEGAL_ARGUMENT_EXCEPTION = "IllegalArgumentException"; | ||
1399 | + | ||
1400 | + /** | ||
1401 | + * Static attribute for IllegalArgumentException. | ||
1402 | + */ | ||
1403 | + public static final String ILLEGAL_ARGUMENT_EXCEPTION_MSG = "\"provided augmented info is invalid for content " + | ||
1404 | + "match.\""; | ||
1405 | + | ||
1406 | + /** | ||
1407 | + * Static attribute for throw. | ||
1408 | + */ | ||
1409 | + public static final String THROW = "throw"; | ||
1410 | + | ||
1411 | + /** | ||
1412 | + * Static attribute for baseClass(). | ||
1413 | + */ | ||
1414 | + public static final String BASE_CLASS = "BaseClass()"; | ||
1415 | + | ||
1416 | + | ||
1417 | + /** | ||
1386 | * Creates an instance of util constants. | 1418 | * Creates an instance of util constants. |
1387 | */ | 1419 | */ |
1388 | private UtilConstants() { | 1420 | private UtilConstants() { | ... | ... |
... | @@ -56,7 +56,7 @@ public class IetfYangFileTest { | ... | @@ -56,7 +56,7 @@ public class IetfYangFileTest { |
56 | yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/"); | 56 | yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/"); |
57 | yangPluginConfig.setManagerCodeGenDir("target/ietfyang/l3vpnservice/"); | 57 | yangPluginConfig.setManagerCodeGenDir("target/ietfyang/l3vpnservice/"); |
58 | 58 | ||
59 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 59 | + utilManager.translateToJava(yangPluginConfig); |
60 | 60 | ||
61 | deleteDirectory(userDir + "/target/ietfyang/"); | 61 | deleteDirectory(userDir + "/target/ietfyang/"); |
62 | } | 62 | } | ... | ... |
... | @@ -50,7 +50,7 @@ public class AugmentTranslatorTest { | ... | @@ -50,7 +50,7 @@ public class AugmentTranslatorTest { |
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/"); | 52 | yangPluginConfig.setManagerCodeGenDir("target/augmentTranslator/"); |
53 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 53 | + utilManager.translateToJava(yangPluginConfig); |
54 | 54 | ||
55 | deleteDirectory("target/augmentTranslator/"); | 55 | deleteDirectory("target/augmentTranslator/"); |
56 | } | 56 | } | ... | ... |
... | @@ -638,7 +638,7 @@ public class InterFileLinkingTest { | ... | @@ -638,7 +638,7 @@ public class InterFileLinkingTest { |
638 | yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/"); | 638 | yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/"); |
639 | yangPluginConfig.setManagerCodeGenDir("target/interfilewithusesreferringtype/"); | 639 | yangPluginConfig.setManagerCodeGenDir("target/interfilewithusesreferringtype/"); |
640 | 640 | ||
641 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 641 | + utilManager.translateToJava(yangPluginConfig); |
642 | 642 | ||
643 | deleteDirectory("target/interfilewithusesreferringtype/"); | 643 | deleteDirectory("target/interfilewithusesreferringtype/"); |
644 | 644 | ||
... | @@ -660,7 +660,7 @@ public class InterFileLinkingTest { | ... | @@ -660,7 +660,7 @@ public class InterFileLinkingTest { |
660 | yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); | 660 | yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); |
661 | yangPluginConfig.setManagerCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); | 661 | yangPluginConfig.setManagerCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); |
662 | 662 | ||
663 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 663 | + utilManager.translateToJava(yangPluginConfig); |
664 | 664 | ||
665 | deleteDirectory("target/file1UsesFile2TypeDefFile3Type/"); | 665 | deleteDirectory("target/file1UsesFile2TypeDefFile3Type/"); |
666 | 666 | ||
... | @@ -682,7 +682,7 @@ public class InterFileLinkingTest { | ... | @@ -682,7 +682,7 @@ public class InterFileLinkingTest { |
682 | yangPluginConfig.setCodeGenDir("target/interfileietf/"); | 682 | yangPluginConfig.setCodeGenDir("target/interfileietf/"); |
683 | yangPluginConfig.setManagerCodeGenDir("target/interfileietf/"); | 683 | yangPluginConfig.setManagerCodeGenDir("target/interfileietf/"); |
684 | 684 | ||
685 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 685 | + utilManager.translateToJava(yangPluginConfig); |
686 | 686 | ||
687 | deleteDirectory("target/interfileietf/"); | 687 | deleteDirectory("target/interfileietf/"); |
688 | 688 | ||
... | @@ -704,7 +704,7 @@ public class InterFileLinkingTest { | ... | @@ -704,7 +704,7 @@ public class InterFileLinkingTest { |
704 | yangPluginConfig.setCodeGenDir("target/usesInContainer/"); | 704 | yangPluginConfig.setCodeGenDir("target/usesInContainer/"); |
705 | yangPluginConfig.setManagerCodeGenDir("target/usesInContainer/"); | 705 | yangPluginConfig.setManagerCodeGenDir("target/usesInContainer/"); |
706 | 706 | ||
707 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 707 | + utilManager.translateToJava(yangPluginConfig); |
708 | 708 | ||
709 | deleteDirectory("target/usesInContainer/"); | 709 | deleteDirectory("target/usesInContainer/"); |
710 | 710 | ||
... | @@ -726,7 +726,7 @@ public class InterFileLinkingTest { | ... | @@ -726,7 +726,7 @@ public class InterFileLinkingTest { |
726 | yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/"); | 726 | yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/"); |
727 | yangPluginConfig.setManagerCodeGenDir("target/groupingNodeSameAsModule/"); | 727 | yangPluginConfig.setManagerCodeGenDir("target/groupingNodeSameAsModule/"); |
728 | 728 | ||
729 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 729 | + utilManager.translateToJava(yangPluginConfig); |
730 | 730 | ||
731 | deleteDirectory("target/groupingNodeSameAsModule/"); | 731 | deleteDirectory("target/groupingNodeSameAsModule/"); |
732 | 732 | ... | ... |
... | @@ -191,7 +191,7 @@ public class InterJarLinkerTest { | ... | @@ -191,7 +191,7 @@ public class InterJarLinkerTest { |
191 | yangPluginConfig.setCodeGenDir(TARGET); | 191 | yangPluginConfig.setCodeGenDir(TARGET); |
192 | yangPluginConfig.setManagerCodeGenDir(TARGET); | 192 | yangPluginConfig.setManagerCodeGenDir(TARGET); |
193 | 193 | ||
194 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 194 | + utilManager.translateToJava(yangPluginConfig); |
195 | 195 | ||
196 | testIfFlowClassifierFilesExists(); | 196 | testIfFlowClassifierFilesExists(); |
197 | testIfPortPairFileDoesNotExist(); | 197 | testIfPortPairFileDoesNotExist(); |
... | @@ -308,6 +308,7 @@ public class InterJarLinkerTest { | ... | @@ -308,6 +308,7 @@ public class InterJarLinkerTest { |
308 | 308 | ||
309 | for (YangNode node : interJarResolvedNodes) { | 309 | for (YangNode node : interJarResolvedNodes) { |
310 | YangFileInfo dependentFileInfo = new YangFileInfo(); | 310 | YangFileInfo dependentFileInfo = new YangFileInfo(); |
311 | + node.setToTranslate(false); | ||
311 | dependentFileInfo.setRootNode(node); | 312 | dependentFileInfo.setRootNode(node); |
312 | dependentFileInfo.setForTranslator(false); | 313 | dependentFileInfo.setForTranslator(false); |
313 | dependentFileInfo.setYangFileName(node.getName()); | 314 | dependentFileInfo.setYangFileName(node.getName()); | ... | ... |
... | @@ -44,7 +44,7 @@ public class ManagerCodeGeneratorTest { | ... | @@ -44,7 +44,7 @@ public class ManagerCodeGeneratorTest { |
44 | @Test | 44 | @Test |
45 | public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException { | 45 | public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException { |
46 | 46 | ||
47 | - String searchDir = "src/test/resources/manager"; | 47 | + String searchDir = "src/test/resources/manager/singleChild"; |
48 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 48 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
49 | utilManager.parseYangFileInfoSet(); | 49 | utilManager.parseYangFileInfoSet(); |
50 | utilManager.createYangNodeSet(); | 50 | utilManager.createYangNodeSet(); |
... | @@ -54,7 +54,7 @@ public class ManagerCodeGeneratorTest { | ... | @@ -54,7 +54,7 @@ public class ManagerCodeGeneratorTest { |
54 | yangPluginConfig.setCodeGenDir("target/manager/"); | 54 | yangPluginConfig.setCodeGenDir("target/manager/"); |
55 | yangPluginConfig.setManagerCodeGenDir("target/manager/"); | 55 | yangPluginConfig.setManagerCodeGenDir("target/manager/"); |
56 | 56 | ||
57 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 57 | + utilManager.translateToJava(yangPluginConfig); |
58 | String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java"; | 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"; | 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"; | 60 | String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java"; |
... | @@ -79,7 +79,7 @@ public class ManagerCodeGeneratorTest { | ... | @@ -79,7 +79,7 @@ public class ManagerCodeGeneratorTest { |
79 | public void processManagerInDifferentPackageTranslator() throws IOException, ParserException, | 79 | public void processManagerInDifferentPackageTranslator() throws IOException, ParserException, |
80 | MojoExecutionException { | 80 | MojoExecutionException { |
81 | 81 | ||
82 | - String searchDir = "src/test/resources/manager"; | 82 | + String searchDir = "src/test/resources/manager/singleChild"; |
83 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 83 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
84 | utilManager.parseYangFileInfoSet(); | 84 | utilManager.parseYangFileInfoSet(); |
85 | utilManager.createYangNodeSet(); | 85 | utilManager.createYangNodeSet(); |
... | @@ -87,10 +87,10 @@ public class ManagerCodeGeneratorTest { | ... | @@ -87,10 +87,10 @@ public class ManagerCodeGeneratorTest { |
87 | 87 | ||
88 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 88 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
89 | yangPluginConfig.setCodeGenDir("target/manager/"); | 89 | yangPluginConfig.setCodeGenDir("target/manager/"); |
90 | - yangPluginConfig.setManagerCodeGenDir("target/manager1/"); | 90 | + yangPluginConfig.setManagerCodeGenDir("target/manager/"); |
91 | 91 | ||
92 | - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 92 | + utilManager.translateToJava(yangPluginConfig); |
93 | - String file3 = "target/manager1/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java"; | 93 | + String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java"; |
94 | 94 | ||
95 | File manager3 = new File(file3); | 95 | File manager3 = new File(file3); |
96 | assertThat(true, is(manager3.exists())); | 96 | assertThat(true, is(manager3.exists())); |
... | @@ -98,4 +98,48 @@ public class ManagerCodeGeneratorTest { | ... | @@ -98,4 +98,48 @@ public class ManagerCodeGeneratorTest { |
98 | deleteDirectory("target/manager/"); | 98 | deleteDirectory("target/manager/"); |
99 | deleteDirectory("target/manager1/"); | 99 | deleteDirectory("target/manager1/"); |
100 | } | 100 | } |
101 | + | ||
102 | + /** | ||
103 | + * Checks manager translation in different package should not result in any exception. | ||
104 | + * | ||
105 | + * @throws MojoExecutionException | ||
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/manager1/"); | ||
144 | + } | ||
101 | } | 145 | } | ... | ... |
1 | +submodule test6 { | ||
2 | + | ||
3 | + belongs-to "test5" { | ||
4 | + prefix "test"; | ||
5 | + } | ||
6 | + | ||
7 | + revision "2016-07-04" { | ||
8 | + description "Initial revision."; | ||
9 | + } | ||
10 | + grouping grouping1 { | ||
11 | + leaf leaf1 { | ||
12 | + type int32; | ||
13 | + } | ||
14 | + } | ||
15 | + grouping grouping2 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + } | ||
20 | + | ||
21 | + grouping grouping3 { | ||
22 | + leaf leaf1 { | ||
23 | + type int32; | ||
24 | + } | ||
25 | + } | ||
26 | +} |
1 | +module test8 { | ||
2 | + namespace "test8:test"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + revision "2016-07-04" { | ||
6 | + description "Initial revision."; | ||
7 | + } | ||
8 | + | ||
9 | + grouping grouping1 { | ||
10 | + leaf leaf1 { | ||
11 | + type int32; | ||
12 | + } | ||
13 | + } | ||
14 | + | ||
15 | + typedef typedef3 { | ||
16 | + type int32; | ||
17 | + } | ||
18 | + | ||
19 | + container container2 { | ||
20 | + } | ||
21 | + | ||
22 | +} |
... | @@ -7,7 +7,7 @@ submodule test6 { | ... | @@ -7,7 +7,7 @@ submodule test6 { |
7 | revision "2016-07-04" { | 7 | revision "2016-07-04" { |
8 | description "Initial revision."; | 8 | description "Initial revision."; |
9 | } | 9 | } |
10 | - grouping abc { | 10 | + grouping grouping1 { |
11 | leaf leaf1 { | 11 | leaf leaf1 { |
12 | type int32; | 12 | type int32; |
13 | } | 13 | } | ... | ... |
-
Please register or login to post a comment