Committed by
Patrick Liu
[ONOS-4799],[ONOS-4351] Augment inter file linker and Generated Code refactored.
Change-Id: Id1f3ac9c90a632373f51cc75d499c3110216be17
Showing
110 changed files
with
4405 additions
and
1041 deletions
... | @@ -49,5 +49,10 @@ public enum ResolvableType { | ... | @@ -49,5 +49,10 @@ public enum ResolvableType { |
49 | /** | 49 | /** |
50 | * Identifies the identityref. | 50 | * Identifies the identityref. |
51 | */ | 51 | */ |
52 | - YANG_IDENTITYREF | 52 | + YANG_IDENTITYREF, |
53 | + | ||
54 | + /** | ||
55 | + * Identifies the augment. | ||
56 | + */ | ||
57 | + YANG_AUGMENT | ||
53 | } | 58 | } | ... | ... |
... | @@ -20,6 +20,7 @@ import java.util.List; | ... | @@ -20,6 +20,7 @@ import java.util.List; |
20 | 20 | ||
21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
22 | import org.onosproject.yangutils.datamodel.utils.Parsable; | 22 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
23 | +import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | ||
23 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; | 24 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
24 | 25 | ||
25 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | 26 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
... | @@ -81,7 +82,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -81,7 +82,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
81 | */ | 82 | */ |
82 | public class YangAugment | 83 | public class YangAugment |
83 | extends YangNode | 84 | extends YangNode |
84 | - implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangWhenHolder, YangIfFeatureHolder { | 85 | + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentedInfo, Resolvable, |
86 | + YangXPathResolver, YangWhenHolder, YangIfFeatureHolder { | ||
85 | 87 | ||
86 | private static final long serialVersionUID = 806201602L; | 88 | private static final long serialVersionUID = 806201602L; |
87 | 89 | ||
... | @@ -108,7 +110,7 @@ public class YangAugment | ... | @@ -108,7 +110,7 @@ public class YangAugment |
108 | /** | 110 | /** |
109 | * List of node identifiers. | 111 | * List of node identifiers. |
110 | */ | 112 | */ |
111 | - private List<YangNodeIdentifier> targetNode; | 113 | + private List<YangAtomicPath> targetNode; |
112 | 114 | ||
113 | /** | 115 | /** |
114 | * Reference of the YANG augment. | 116 | * Reference of the YANG augment. |
... | @@ -121,6 +123,19 @@ public class YangAugment | ... | @@ -121,6 +123,19 @@ public class YangAugment |
121 | private YangStatusType status; | 123 | private YangStatusType status; |
122 | 124 | ||
123 | /** | 125 | /** |
126 | + * Resolved augmented node. | ||
127 | + */ | ||
128 | + private YangNode augmentedNode; | ||
129 | + | ||
130 | + /** | ||
131 | + * Status of resolution. If completely resolved enum value is "RESOLVED", | ||
132 | + * if not enum value is "UNRESOLVED", in case reference of grouping/typedef | ||
133 | + * is added to uses/type but it's not resolved value of enum should be | ||
134 | + * "INTRA_FILE_RESOLVED". | ||
135 | + */ | ||
136 | + private ResolvableStatus resolvableStatus; | ||
137 | + | ||
138 | + /** | ||
124 | * When data of the node. | 139 | * When data of the node. |
125 | */ | 140 | */ |
126 | private YangWhen when; | 141 | private YangWhen when; |
... | @@ -135,6 +150,7 @@ public class YangAugment | ... | @@ -135,6 +150,7 @@ public class YangAugment |
135 | */ | 150 | */ |
136 | public YangAugment() { | 151 | public YangAugment() { |
137 | super(YangNodeType.AUGMENT_NODE); | 152 | super(YangNodeType.AUGMENT_NODE); |
153 | + resolvableStatus = ResolvableStatus.UNRESOLVED; | ||
138 | } | 154 | } |
139 | 155 | ||
140 | /** | 156 | /** |
... | @@ -142,7 +158,7 @@ public class YangAugment | ... | @@ -142,7 +158,7 @@ public class YangAugment |
142 | * | 158 | * |
143 | * @return the augmented node | 159 | * @return the augmented node |
144 | */ | 160 | */ |
145 | - public List<YangNodeIdentifier> getTargetNode() { | 161 | + public List<YangAtomicPath> getTargetNode() { |
146 | return targetNode; | 162 | return targetNode; |
147 | } | 163 | } |
148 | 164 | ||
... | @@ -151,7 +167,7 @@ public class YangAugment | ... | @@ -151,7 +167,7 @@ public class YangAugment |
151 | * | 167 | * |
152 | * @param nodeIdentifiers the augmented node | 168 | * @param nodeIdentifiers the augmented node |
153 | */ | 169 | */ |
154 | - public void setTargetNode(List<YangNodeIdentifier> nodeIdentifiers) { | 170 | + public void setTargetNode(List<YangAtomicPath> nodeIdentifiers) { |
155 | targetNode = nodeIdentifiers; | 171 | targetNode = nodeIdentifiers; |
156 | } | 172 | } |
157 | 173 | ||
... | @@ -371,6 +387,24 @@ public class YangAugment | ... | @@ -371,6 +387,24 @@ public class YangAugment |
371 | this.name = name; | 387 | this.name = name; |
372 | } | 388 | } |
373 | 389 | ||
390 | + /** | ||
391 | + * Returns augmented node. | ||
392 | + * | ||
393 | + * @return augmented node | ||
394 | + */ | ||
395 | + public YangNode getAugmentedNode() { | ||
396 | + return augmentedNode; | ||
397 | + } | ||
398 | + | ||
399 | + /** | ||
400 | + * Sets augmented node. | ||
401 | + * | ||
402 | + * @param augmentedNode augmented node | ||
403 | + */ | ||
404 | + public void setAugmentedNode(YangNode augmentedNode) { | ||
405 | + this.augmentedNode = augmentedNode; | ||
406 | + } | ||
407 | + | ||
374 | @Override | 408 | @Override |
375 | public List<YangIfFeature> getIfFeatureList() { | 409 | public List<YangIfFeature> getIfFeatureList() { |
376 | return ifFeatureList; | 410 | return ifFeatureList; |
... | @@ -388,4 +422,20 @@ public class YangAugment | ... | @@ -388,4 +422,20 @@ public class YangAugment |
388 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { | 422 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { |
389 | this.ifFeatureList = ifFeatureList; | 423 | this.ifFeatureList = ifFeatureList; |
390 | } | 424 | } |
425 | + | ||
426 | + @Override | ||
427 | + public ResolvableStatus getResolvableStatus() { | ||
428 | + return resolvableStatus; | ||
429 | + } | ||
430 | + | ||
431 | + @Override | ||
432 | + public void setResolvableStatus(ResolvableStatus resolvableStatus) { | ||
433 | + this.resolvableStatus = resolvableStatus; | ||
434 | + | ||
435 | + } | ||
436 | + | ||
437 | + @Override | ||
438 | + public void resolve() throws DataModelException { | ||
439 | + // Resolving of target node is being done in XPathLinker. | ||
440 | + } | ||
391 | } | 441 | } | ... | ... |
... | @@ -14,31 +14,33 @@ | ... | @@ -14,31 +14,33 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.yangutils.utils; | 17 | +package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | import java.util.List; | 19 | import java.util.List; |
20 | 20 | ||
21 | /** | 21 | /** |
22 | - * Abstraction of an entity which represents augmentation of a YANG node. | 22 | + * Represents YANG constructs which can be augmented. |
23 | */ | 23 | */ |
24 | -public interface AugmentationHolder { | 24 | +public interface YangAugmentableNode { |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Adds augment info to the augment info list. | 27 | * Adds augment info to the augment info list. |
28 | * | 28 | * |
29 | * @param augmentInfo augment info of node | 29 | * @param augmentInfo augment info of node |
30 | */ | 30 | */ |
31 | - void addAugmentation(AugmentedInfo augmentInfo); | 31 | + void addAugmentation(YangAugmentedInfo augmentInfo); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Removes augment info from the node. | 34 | * Removes augment info from the node. |
35 | + * | ||
36 | + * @param augmentInfo augment info of node | ||
35 | */ | 37 | */ |
36 | - void removeAugmentation(); | 38 | + void removeAugmentation(YangAugmentedInfo augmentInfo); |
37 | 39 | ||
38 | /** | 40 | /** |
39 | * Returns list of augment info. | 41 | * Returns list of augment info. |
40 | * | 42 | * |
41 | * @return list of augment info | 43 | * @return list of augment info |
42 | */ | 44 | */ |
43 | - List<AugmentedInfo> getAugmentedInfoList(); | 45 | + List<YangAugmentedInfo> getAugmentedInfoList(); |
44 | } | 46 | } | ... | ... |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | /** | 19 | /** |
20 | - * Represents YANG constructs which can be augmented. | 20 | + * Abstraction of an entity which represents YANG augmented info. |
21 | */ | 21 | */ |
22 | -public interface YangAugmentationHolder { | 22 | +public interface YangAugmentedInfo { |
23 | } | 23 | } | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.datamodel; | 16 | package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | +import java.util.ArrayList; | ||
18 | import java.util.LinkedList; | 19 | import java.util.LinkedList; |
19 | import java.util.List; | 20 | import java.util.List; |
20 | 21 | ||
... | @@ -94,7 +95,7 @@ import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CASE_D | ... | @@ -94,7 +95,7 @@ import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CASE_D |
94 | */ | 95 | */ |
95 | public class YangCase | 96 | public class YangCase |
96 | extends YangNode | 97 | extends YangNode |
97 | - implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder, | 98 | + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentableNode, |
98 | YangWhenHolder, YangIfFeatureHolder { | 99 | YangWhenHolder, YangIfFeatureHolder { |
99 | 100 | ||
100 | private static final long serialVersionUID = 806201603L; | 101 | private static final long serialVersionUID = 806201603L; |
... | @@ -141,6 +142,8 @@ public class YangCase | ... | @@ -141,6 +142,8 @@ public class YangCase |
141 | */ | 142 | */ |
142 | private List<YangIfFeature> ifFeatureList; | 143 | private List<YangIfFeature> ifFeatureList; |
143 | 144 | ||
145 | + private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>(); | ||
146 | + | ||
144 | /** | 147 | /** |
145 | * Creates a choice node. | 148 | * Creates a choice node. |
146 | */ | 149 | */ |
... | @@ -392,4 +395,19 @@ public class YangCase | ... | @@ -392,4 +395,19 @@ public class YangCase |
392 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { | 395 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { |
393 | this.ifFeatureList = ifFeatureList; | 396 | this.ifFeatureList = ifFeatureList; |
394 | } | 397 | } |
398 | + | ||
399 | + @Override | ||
400 | + public void addAugmentation(YangAugmentedInfo augmentInfo) { | ||
401 | + yangAugmentedInfo.add(augmentInfo); | ||
402 | + } | ||
403 | + | ||
404 | + @Override | ||
405 | + public void removeAugmentation(YangAugmentedInfo augmentInfo) { | ||
406 | + yangAugmentedInfo.remove(augmentInfo); | ||
407 | + } | ||
408 | + | ||
409 | + @Override | ||
410 | + public List<YangAugmentedInfo> getAugmentedInfoList() { | ||
411 | + return yangAugmentedInfo; | ||
412 | + } | ||
395 | } | 413 | } | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.datamodel; | 16 | package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | +import java.util.ArrayList; | ||
18 | import java.util.LinkedList; | 19 | import java.util.LinkedList; |
19 | import java.util.List; | 20 | import java.util.List; |
20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
... | @@ -63,8 +64,8 @@ import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CHOICE | ... | @@ -63,8 +64,8 @@ import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CHOICE |
63 | * Represents data model node to maintain information defined in YANG choice. | 64 | * Represents data model node to maintain information defined in YANG choice. |
64 | */ | 65 | */ |
65 | public class YangChoice extends YangNode | 66 | public class YangChoice extends YangNode |
66 | - implements YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder, YangWhenHolder, | 67 | + implements YangCommonInfo, Parsable, CollisionDetector, YangAugmentableNode, |
67 | - YangIfFeatureHolder { | 68 | + YangWhenHolder, YangIfFeatureHolder { |
68 | 69 | ||
69 | private static final long serialVersionUID = 806201604L; | 70 | private static final long serialVersionUID = 806201604L; |
70 | 71 | ||
... | @@ -156,6 +157,8 @@ public class YangChoice extends YangNode | ... | @@ -156,6 +157,8 @@ public class YangChoice extends YangNode |
156 | */ | 157 | */ |
157 | private List<YangIfFeature> ifFeatureList; | 158 | private List<YangIfFeature> ifFeatureList; |
158 | 159 | ||
160 | + private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>(); | ||
161 | + | ||
159 | /** | 162 | /** |
160 | * Create a choice node. | 163 | * Create a choice node. |
161 | */ | 164 | */ |
... | @@ -418,4 +421,18 @@ public class YangChoice extends YangNode | ... | @@ -418,4 +421,18 @@ public class YangChoice extends YangNode |
418 | this.ifFeatureList = ifFeatureList; | 421 | this.ifFeatureList = ifFeatureList; |
419 | } | 422 | } |
420 | 423 | ||
424 | + @Override | ||
425 | + public void addAugmentation(YangAugmentedInfo augmentInfo) { | ||
426 | + yangAugmentedInfo.add(augmentInfo); | ||
427 | + } | ||
428 | + | ||
429 | + @Override | ||
430 | + public void removeAugmentation(YangAugmentedInfo augmentInfo) { | ||
431 | + yangAugmentedInfo.remove(augmentInfo); | ||
432 | + } | ||
433 | + | ||
434 | + @Override | ||
435 | + public List<YangAugmentedInfo> getAugmentedInfoList() { | ||
436 | + return yangAugmentedInfo; | ||
437 | + } | ||
421 | } | 438 | } | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | +import java.util.ArrayList; | ||
19 | import java.util.LinkedList; | 20 | import java.util.LinkedList; |
20 | import java.util.List; | 21 | import java.util.List; |
21 | 22 | ||
... | @@ -89,8 +90,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -89,8 +90,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
89 | */ | 90 | */ |
90 | public class YangContainer | 91 | public class YangContainer |
91 | extends YangNode | 92 | extends YangNode |
92 | - implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder, | 93 | + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, |
93 | - YangMustHolder, YangWhenHolder, YangIfFeatureHolder { | 94 | + YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder { |
94 | 95 | ||
95 | private static final long serialVersionUID = 806201605L; | 96 | private static final long serialVersionUID = 806201605L; |
96 | 97 | ||
... | @@ -130,6 +131,8 @@ public class YangContainer | ... | @@ -130,6 +131,8 @@ public class YangContainer |
130 | */ | 131 | */ |
131 | private String reference; | 132 | private String reference; |
132 | 133 | ||
134 | + private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>(); | ||
135 | + | ||
133 | /** | 136 | /** |
134 | * Status of the node. | 137 | * Status of the node. |
135 | */ | 138 | */ |
... | @@ -518,4 +521,18 @@ public class YangContainer | ... | @@ -518,4 +521,18 @@ public class YangContainer |
518 | getListOfMust().add(must); | 521 | getListOfMust().add(must); |
519 | } | 522 | } |
520 | 523 | ||
524 | + @Override | ||
525 | + public void addAugmentation(YangAugmentedInfo augmentInfo) { | ||
526 | + yangAugmentedInfo.add(augmentInfo); | ||
527 | + } | ||
528 | + | ||
529 | + @Override | ||
530 | + public void removeAugmentation(YangAugmentedInfo augmentInfo) { | ||
531 | + yangAugmentedInfo.remove(augmentInfo); | ||
532 | + } | ||
533 | + | ||
534 | + @Override | ||
535 | + public List<YangAugmentedInfo> getAugmentedInfoList() { | ||
536 | + return yangAugmentedInfo; | ||
537 | + } | ||
521 | } | 538 | } | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | +import java.util.ArrayList; | ||
19 | import java.util.LinkedList; | 20 | import java.util.LinkedList; |
20 | import java.util.List; | 21 | import java.util.List; |
21 | 22 | ||
... | @@ -70,7 +71,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -70,7 +71,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
70 | */ | 71 | */ |
71 | public class YangInput | 72 | public class YangInput |
72 | extends YangNode | 73 | extends YangNode |
73 | - implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentationHolder { | 74 | + implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode { |
74 | 75 | ||
75 | private static final long serialVersionUID = 806201608L; | 76 | private static final long serialVersionUID = 806201608L; |
76 | 77 | ||
... | @@ -89,6 +90,8 @@ public class YangInput | ... | @@ -89,6 +90,8 @@ public class YangInput |
89 | */ | 90 | */ |
90 | private List<YangLeafList> listOfLeafList; | 91 | private List<YangLeafList> listOfLeafList; |
91 | 92 | ||
93 | + private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>(); | ||
94 | + | ||
92 | /** | 95 | /** |
93 | * Create a rpc input node. | 96 | * Create a rpc input node. |
94 | */ | 97 | */ |
... | @@ -171,4 +174,19 @@ public class YangInput | ... | @@ -171,4 +174,19 @@ public class YangInput |
171 | public void setName(String name) { | 174 | public void setName(String name) { |
172 | this.name = name; | 175 | this.name = name; |
173 | } | 176 | } |
177 | + | ||
178 | + @Override | ||
179 | + public void addAugmentation(YangAugmentedInfo augmentInfo) { | ||
180 | + yangAugmentedInfo.add(augmentInfo); | ||
181 | + } | ||
182 | + | ||
183 | + @Override | ||
184 | + public void removeAugmentation(YangAugmentedInfo augmentInfo) { | ||
185 | + yangAugmentedInfo.remove(augmentInfo); | ||
186 | + } | ||
187 | + | ||
188 | + @Override | ||
189 | + public List<YangAugmentedInfo> getAugmentedInfoList() { | ||
190 | + return yangAugmentedInfo; | ||
191 | + } | ||
174 | } | 192 | } | ... | ... |
... | @@ -43,7 +43,8 @@ import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVE | ... | @@ -43,7 +43,8 @@ import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVE |
43 | * | 43 | * |
44 | * @param <T> YANG leafref info | 44 | * @param <T> YANG leafref info |
45 | */ | 45 | */ |
46 | -public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangIfFeatureHolder { | 46 | +public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangIfFeatureHolder, |
47 | + YangXPathResolver { | ||
47 | 48 | ||
48 | private static final long serialVersionUID = 286201644L; | 49 | private static final long serialVersionUID = 286201644L; |
49 | 50 | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | +import java.util.ArrayList; | ||
19 | import java.util.LinkedList; | 20 | import java.util.LinkedList; |
20 | import java.util.List; | 21 | import java.util.List; |
21 | 22 | ||
... | @@ -70,8 +71,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -70,8 +71,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
70 | */ | 71 | */ |
71 | public class YangList | 72 | public class YangList |
72 | extends YangNode | 73 | extends YangNode |
73 | - implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder, | 74 | + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, |
74 | - YangMustHolder, YangIfFeatureHolder, YangDataNode { | 75 | + YangAugmentableNode, YangMustHolder, YangIfFeatureHolder, YangDataNode { |
75 | 76 | ||
76 | private static final long serialVersionUID = 806201609L; | 77 | private static final long serialVersionUID = 806201609L; |
77 | 78 | ||
... | @@ -127,6 +128,8 @@ public class YangList | ... | @@ -127,6 +128,8 @@ public class YangList |
127 | */ | 128 | */ |
128 | private List<YangLeafList> listOfLeafList; | 129 | private List<YangLeafList> listOfLeafList; |
129 | 130 | ||
131 | + private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>(); | ||
132 | + | ||
130 | /** | 133 | /** |
131 | * Reference RFC 6020. | 134 | * Reference RFC 6020. |
132 | * | 135 | * |
... | @@ -570,8 +573,7 @@ public class YangList | ... | @@ -570,8 +573,7 @@ public class YangList |
570 | * @throws DataModelException a violation of data model rules | 573 | * @throws DataModelException a violation of data model rules |
571 | */ | 574 | */ |
572 | private void validateKey(List<YangLeaf> leaves, List<YangLeafList> leafLists, List<String> keys) | 575 | private void validateKey(List<YangLeaf> leaves, List<YangLeafList> leafLists, List<String> keys) |
573 | - throws | 576 | + throws DataModelException { |
574 | - DataModelException { | ||
575 | boolean leafFound = false; | 577 | boolean leafFound = false; |
576 | List<YangLeaf> keyLeaves = new LinkedList<>(); | 578 | List<YangLeaf> keyLeaves = new LinkedList<>(); |
577 | List<YangLeafList> keyLeafLists = new LinkedList<>(); | 579 | List<YangLeafList> keyLeafLists = new LinkedList<>(); |
... | @@ -713,4 +715,19 @@ public class YangList | ... | @@ -713,4 +715,19 @@ public class YangList |
713 | } | 715 | } |
714 | getListOfMust().add(must); | 716 | getListOfMust().add(must); |
715 | } | 717 | } |
718 | + | ||
719 | + @Override | ||
720 | + public void addAugmentation(YangAugmentedInfo augmentInfo) { | ||
721 | + yangAugmentedInfo.add(augmentInfo); | ||
722 | + } | ||
723 | + | ||
724 | + @Override | ||
725 | + public void removeAugmentation(YangAugmentedInfo augmentInfo) { | ||
726 | + yangAugmentedInfo.remove(augmentInfo); | ||
727 | + } | ||
728 | + | ||
729 | + @Override | ||
730 | + public List<YangAugmentedInfo> getAugmentedInfoList() { | ||
731 | + return yangAugmentedInfo; | ||
732 | + } | ||
716 | } | 733 | } | ... | ... |
... | @@ -201,30 +201,34 @@ public class YangModule | ... | @@ -201,30 +201,34 @@ public class YangModule |
201 | private List<YangResolutionInfo> derivedTypeResolutionList; | 201 | private List<YangResolutionInfo> derivedTypeResolutionList; |
202 | 202 | ||
203 | /** | 203 | /** |
204 | - * uses resolution list. | 204 | + * Uses resolution list. |
205 | */ | 205 | */ |
206 | private List<YangResolutionInfo> usesResolutionList; | 206 | private List<YangResolutionInfo> usesResolutionList; |
207 | 207 | ||
208 | /** | 208 | /** |
209 | - * if-feature resolution list. | 209 | + * If-feature resolution list. |
210 | */ | 210 | */ |
211 | private List<YangResolutionInfo> ifFeatureResolutionList; | 211 | private List<YangResolutionInfo> ifFeatureResolutionList; |
212 | 212 | ||
213 | /** | 213 | /** |
214 | - * leafref resolution list. | 214 | + * Leafref resolution list. |
215 | */ | 215 | */ |
216 | private List<YangResolutionInfo> leafrefResolutionList; | 216 | private List<YangResolutionInfo> leafrefResolutionList; |
217 | 217 | ||
218 | /** | 218 | /** |
219 | - * base resolution list. | 219 | + * Base resolution list. |
220 | */ | 220 | */ |
221 | private List<YangResolutionInfo> baseResolutionList; | 221 | private List<YangResolutionInfo> baseResolutionList; |
222 | 222 | ||
223 | /** | 223 | /** |
224 | - * identityref resolution list. | 224 | + * Identityref resolution list. |
225 | */ | 225 | */ |
226 | private List<YangResolutionInfo> identityrefResolutionList; | 226 | private List<YangResolutionInfo> identityrefResolutionList; |
227 | 227 | ||
228 | + /** | ||
229 | + * Augment resolution list. | ||
230 | + */ | ||
231 | + private List<YangResolutionInfo> augmentResolutionList; | ||
228 | 232 | ||
229 | /** | 233 | /** |
230 | * Creates a YANG node of module type. | 234 | * Creates a YANG node of module type. |
... | @@ -233,6 +237,7 @@ public class YangModule | ... | @@ -233,6 +237,7 @@ public class YangModule |
233 | 237 | ||
234 | super(YangNodeType.MODULE_NODE); | 238 | super(YangNodeType.MODULE_NODE); |
235 | derivedTypeResolutionList = new LinkedList<>(); | 239 | derivedTypeResolutionList = new LinkedList<>(); |
240 | + augmentResolutionList = new LinkedList<>(); | ||
236 | usesResolutionList = new LinkedList<>(); | 241 | usesResolutionList = new LinkedList<>(); |
237 | ifFeatureResolutionList = new LinkedList<>(); | 242 | ifFeatureResolutionList = new LinkedList<>(); |
238 | leafrefResolutionList = new LinkedList<>(); | 243 | leafrefResolutionList = new LinkedList<>(); |
... | @@ -608,6 +613,8 @@ public class YangModule | ... | @@ -608,6 +613,8 @@ public class YangModule |
608 | return derivedTypeResolutionList; | 613 | return derivedTypeResolutionList; |
609 | } else if (type == ResolvableType.YANG_USES) { | 614 | } else if (type == ResolvableType.YANG_USES) { |
610 | return usesResolutionList; | 615 | return usesResolutionList; |
616 | + } else if (type == ResolvableType.YANG_AUGMENT) { | ||
617 | + return augmentResolutionList; | ||
611 | } else if (type == ResolvableType.YANG_IF_FEATURE) { | 618 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
612 | return ifFeatureResolutionList; | 619 | return ifFeatureResolutionList; |
613 | } else if (type == ResolvableType.YANG_LEAFREF) { | 620 | } else if (type == ResolvableType.YANG_LEAFREF) { |
... | @@ -632,6 +639,8 @@ public class YangModule | ... | @@ -632,6 +639,8 @@ public class YangModule |
632 | leafrefResolutionList.add(resolutionInfo); | 639 | leafrefResolutionList.add(resolutionInfo); |
633 | } else if (type == ResolvableType.YANG_BASE) { | 640 | } else if (type == ResolvableType.YANG_BASE) { |
634 | baseResolutionList.add(resolutionInfo); | 641 | baseResolutionList.add(resolutionInfo); |
642 | + } else if (type == ResolvableType.YANG_AUGMENT) { | ||
643 | + augmentResolutionList.add(resolutionInfo); | ||
635 | } else if (type == ResolvableType.YANG_IDENTITYREF) { | 644 | } else if (type == ResolvableType.YANG_IDENTITYREF) { |
636 | identityrefResolutionList.add(resolutionInfo); | 645 | identityrefResolutionList.add(resolutionInfo); |
637 | } | 646 | } |
... | @@ -650,6 +659,8 @@ public class YangModule | ... | @@ -650,6 +659,8 @@ public class YangModule |
650 | leafrefResolutionList = resolutionList; | 659 | leafrefResolutionList = resolutionList; |
651 | } else if (type == ResolvableType.YANG_BASE) { | 660 | } else if (type == ResolvableType.YANG_BASE) { |
652 | baseResolutionList = resolutionList; | 661 | baseResolutionList = resolutionList; |
662 | + } else if (type == ResolvableType.YANG_AUGMENT) { | ||
663 | + augmentResolutionList = resolutionList; | ||
653 | } else if (type == ResolvableType.YANG_IDENTITYREF) { | 664 | } else if (type == ResolvableType.YANG_IDENTITYREF) { |
654 | identityrefResolutionList = resolutionList; | 665 | identityrefResolutionList = resolutionList; |
655 | } | 666 | } | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | +import java.util.ArrayList; | ||
19 | import java.util.LinkedList; | 20 | import java.util.LinkedList; |
20 | import java.util.List; | 21 | import java.util.List; |
21 | 22 | ||
... | @@ -76,8 +77,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -76,8 +77,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
76 | */ | 77 | */ |
77 | public class YangNotification | 78 | public class YangNotification |
78 | extends YangNode | 79 | extends YangNode |
79 | - implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder, | 80 | + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, |
80 | - YangIfFeatureHolder { | 81 | + YangAugmentableNode, YangIfFeatureHolder { |
81 | 82 | ||
82 | private static final long serialVersionUID = 806201611L; | 83 | private static final long serialVersionUID = 806201611L; |
83 | 84 | ||
... | @@ -116,6 +117,8 @@ public class YangNotification | ... | @@ -116,6 +117,8 @@ public class YangNotification |
116 | */ | 117 | */ |
117 | private List<YangIfFeature> ifFeatureList; | 118 | private List<YangIfFeature> ifFeatureList; |
118 | 119 | ||
120 | + private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>(); | ||
121 | + | ||
119 | /** | 122 | /** |
120 | * Create a notification node. | 123 | * Create a notification node. |
121 | */ | 124 | */ |
... | @@ -245,4 +248,19 @@ public class YangNotification | ... | @@ -245,4 +248,19 @@ public class YangNotification |
245 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { | 248 | public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { |
246 | this.ifFeatureList = ifFeatureList; | 249 | this.ifFeatureList = ifFeatureList; |
247 | } | 250 | } |
251 | + | ||
252 | + @Override | ||
253 | + public void addAugmentation(YangAugmentedInfo augmentInfo) { | ||
254 | + yangAugmentedInfo.add(augmentInfo); | ||
255 | + } | ||
256 | + | ||
257 | + @Override | ||
258 | + public void removeAugmentation(YangAugmentedInfo augmentInfo) { | ||
259 | + yangAugmentedInfo.remove(augmentInfo); | ||
260 | + } | ||
261 | + | ||
262 | + @Override | ||
263 | + public List<YangAugmentedInfo> getAugmentedInfoList() { | ||
264 | + return yangAugmentedInfo; | ||
265 | + } | ||
248 | } | 266 | } | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | +import java.util.ArrayList; | ||
19 | import java.util.LinkedList; | 20 | import java.util.LinkedList; |
20 | import java.util.List; | 21 | import java.util.List; |
21 | 22 | ||
... | @@ -69,7 +70,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -69,7 +70,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
69 | */ | 70 | */ |
70 | public class YangOutput | 71 | public class YangOutput |
71 | extends YangNode | 72 | extends YangNode |
72 | - implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentationHolder { | 73 | + implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode { |
73 | 74 | ||
74 | private static final long serialVersionUID = 806201612L; | 75 | private static final long serialVersionUID = 806201612L; |
75 | 76 | ||
... | @@ -88,6 +89,8 @@ public class YangOutput | ... | @@ -88,6 +89,8 @@ public class YangOutput |
88 | */ | 89 | */ |
89 | private List<YangLeafList> listOfLeafList; | 90 | private List<YangLeafList> listOfLeafList; |
90 | 91 | ||
92 | + private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>(); | ||
93 | + | ||
91 | /** | 94 | /** |
92 | * Create a rpc output node. | 95 | * Create a rpc output node. |
93 | */ | 96 | */ |
... | @@ -170,4 +173,19 @@ public class YangOutput | ... | @@ -170,4 +173,19 @@ public class YangOutput |
170 | public void setName(String name) { | 173 | public void setName(String name) { |
171 | this.name = name; | 174 | this.name = name; |
172 | } | 175 | } |
176 | + | ||
177 | + @Override | ||
178 | + public void addAugmentation(YangAugmentedInfo augmentInfo) { | ||
179 | + yangAugmentedInfo.add(augmentInfo); | ||
180 | + } | ||
181 | + | ||
182 | + @Override | ||
183 | + public void removeAugmentation(YangAugmentedInfo augmentInfo) { | ||
184 | + yangAugmentedInfo.remove(augmentInfo); | ||
185 | + } | ||
186 | + | ||
187 | + @Override | ||
188 | + public List<YangAugmentedInfo> getAugmentedInfoList() { | ||
189 | + return yangAugmentedInfo; | ||
190 | + } | ||
173 | } | 191 | } | ... | ... |
... | @@ -20,10 +20,13 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -20,10 +20,13 @@ package org.onosproject.yangutils.datamodel; |
20 | */ | 20 | */ |
21 | public enum YangPathArgType { | 21 | public enum YangPathArgType { |
22 | 22 | ||
23 | - // Absolute path. | 23 | + /** |
24 | + * Absolute path. | ||
25 | + */ | ||
24 | ABSOLUTE_PATH, | 26 | ABSOLUTE_PATH, |
25 | 27 | ||
26 | - // Relative path. | 28 | + /** |
29 | + * Relative path. | ||
30 | + */ | ||
27 | RELATIVE_PATH | 31 | RELATIVE_PATH |
28 | - | ||
29 | } | 32 | } | ... | ... |
... | @@ -20,6 +20,8 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -20,6 +20,8 @@ package org.onosproject.yangutils.datamodel; |
20 | */ | 20 | */ |
21 | public enum YangPathOperator { | 21 | public enum YangPathOperator { |
22 | 22 | ||
23 | - // Path expression contains equal to. | 23 | + /** |
24 | + * Path expression contains equal-to. | ||
25 | + */ | ||
24 | EQUALTO | 26 | EQUALTO |
25 | } | 27 | } | ... | ... |
... | @@ -199,36 +199,42 @@ public class YangSubModule | ... | @@ -199,36 +199,42 @@ public class YangSubModule |
199 | private List<YangResolutionInfo> derivedTypeResolutionList; | 199 | private List<YangResolutionInfo> derivedTypeResolutionList; |
200 | 200 | ||
201 | /** | 201 | /** |
202 | - * uses resolution list. | 202 | + * Uses resolution list. |
203 | */ | 203 | */ |
204 | private List<YangResolutionInfo> usesResolutionList; | 204 | private List<YangResolutionInfo> usesResolutionList; |
205 | 205 | ||
206 | /** | 206 | /** |
207 | - * if-feature resolution list. | 207 | + * If-feature resolution list. |
208 | */ | 208 | */ |
209 | private List<YangResolutionInfo> ifFeatureResolutionList; | 209 | private List<YangResolutionInfo> ifFeatureResolutionList; |
210 | 210 | ||
211 | /** | 211 | /** |
212 | - * leafref resolution list. | 212 | + * Leafref resolution list. |
213 | */ | 213 | */ |
214 | private List<YangResolutionInfo> leafrefResolutionList; | 214 | private List<YangResolutionInfo> leafrefResolutionList; |
215 | 215 | ||
216 | /** | 216 | /** |
217 | - * base resolution list. | 217 | + * Base resolution list. |
218 | */ | 218 | */ |
219 | private List<YangResolutionInfo> baseResolutionList; | 219 | private List<YangResolutionInfo> baseResolutionList; |
220 | 220 | ||
221 | /** | 221 | /** |
222 | - * identityref resolution list. | 222 | + * Identityref resolution list. |
223 | */ | 223 | */ |
224 | private List<YangResolutionInfo> identityrefResolutionList; | 224 | private List<YangResolutionInfo> identityrefResolutionList; |
225 | 225 | ||
226 | /** | 226 | /** |
227 | + * Augment resolution list. | ||
228 | + */ | ||
229 | + private List<YangResolutionInfo> augmentResolutionList; | ||
230 | + | ||
231 | + /** | ||
227 | * Creates a sub module node. | 232 | * Creates a sub module node. |
228 | */ | 233 | */ |
229 | public YangSubModule() { | 234 | public YangSubModule() { |
230 | super(YangNodeType.SUB_MODULE_NODE); | 235 | super(YangNodeType.SUB_MODULE_NODE); |
231 | derivedTypeResolutionList = new LinkedList<>(); | 236 | derivedTypeResolutionList = new LinkedList<>(); |
237 | + augmentResolutionList = new LinkedList<>(); | ||
232 | usesResolutionList = new LinkedList<>(); | 238 | usesResolutionList = new LinkedList<>(); |
233 | ifFeatureResolutionList = new LinkedList<>(); | 239 | ifFeatureResolutionList = new LinkedList<>(); |
234 | leafrefResolutionList = new LinkedList<>(); | 240 | leafrefResolutionList = new LinkedList<>(); |
... | @@ -569,6 +575,8 @@ public class YangSubModule | ... | @@ -569,6 +575,8 @@ public class YangSubModule |
569 | return derivedTypeResolutionList; | 575 | return derivedTypeResolutionList; |
570 | } else if (type == ResolvableType.YANG_USES) { | 576 | } else if (type == ResolvableType.YANG_USES) { |
571 | return usesResolutionList; | 577 | return usesResolutionList; |
578 | + } else if (type == ResolvableType.YANG_AUGMENT) { | ||
579 | + return augmentResolutionList; | ||
572 | } else if (type == ResolvableType.YANG_IF_FEATURE) { | 580 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
573 | return ifFeatureResolutionList; | 581 | return ifFeatureResolutionList; |
574 | } else if (type == ResolvableType.YANG_LEAFREF) { | 582 | } else if (type == ResolvableType.YANG_LEAFREF) { |
... | @@ -593,6 +601,8 @@ public class YangSubModule | ... | @@ -593,6 +601,8 @@ public class YangSubModule |
593 | leafrefResolutionList.add(resolutionInfo); | 601 | leafrefResolutionList.add(resolutionInfo); |
594 | } else if (type == ResolvableType.YANG_BASE) { | 602 | } else if (type == ResolvableType.YANG_BASE) { |
595 | baseResolutionList.add(resolutionInfo); | 603 | baseResolutionList.add(resolutionInfo); |
604 | + } else if (type == ResolvableType.YANG_AUGMENT) { | ||
605 | + augmentResolutionList.add(resolutionInfo); | ||
596 | } else if (type == ResolvableType.YANG_IDENTITYREF) { | 606 | } else if (type == ResolvableType.YANG_IDENTITYREF) { |
597 | identityrefResolutionList.add(resolutionInfo); | 607 | identityrefResolutionList.add(resolutionInfo); |
598 | } | 608 | } |
... | @@ -611,6 +621,8 @@ public class YangSubModule | ... | @@ -611,6 +621,8 @@ public class YangSubModule |
611 | leafrefResolutionList = resolutionList; | 621 | leafrefResolutionList = resolutionList; |
612 | } else if (type == ResolvableType.YANG_BASE) { | 622 | } else if (type == ResolvableType.YANG_BASE) { |
613 | baseResolutionList = resolutionList; | 623 | baseResolutionList = resolutionList; |
624 | + } else if (type == ResolvableType.YANG_AUGMENT) { | ||
625 | + augmentResolutionList = resolutionList; | ||
614 | } else if (type == ResolvableType.YANG_IDENTITYREF) { | 626 | } else if (type == ResolvableType.YANG_IDENTITYREF) { |
615 | identityrefResolutionList = resolutionList; | 627 | identityrefResolutionList = resolutionList; |
616 | } | 628 | } | ... | ... |
... | @@ -14,10 +14,10 @@ | ... | @@ -14,10 +14,10 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.yangutils.utils; | 17 | +package org.onosproject.yangutils.datamodel; |
18 | 18 | ||
19 | /** | 19 | /** |
20 | - * Abstraction of an entity which represents augmented info. | 20 | + * Abstraction of an entity which can be resolved with x-path linker. |
21 | */ | 21 | */ |
22 | -public interface AugmentedInfo { | 22 | +public interface YangXPathResolver { |
23 | } | 23 | } | ... | ... |
... | @@ -16,12 +16,17 @@ | ... | @@ -16,12 +16,17 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.datamodel.utils; | 17 | package org.onosproject.yangutils.datamodel.utils; |
18 | 18 | ||
19 | +import java.io.FileInputStream; | ||
20 | +import java.io.IOException; | ||
21 | +import java.io.ObjectInputStream; | ||
22 | +import java.util.ArrayList; | ||
19 | import java.util.List; | 23 | import java.util.List; |
20 | import java.util.Set; | 24 | import java.util.Set; |
21 | 25 | ||
22 | import org.onosproject.yangutils.datamodel.CollisionDetector; | 26 | import org.onosproject.yangutils.datamodel.CollisionDetector; |
23 | import org.onosproject.yangutils.datamodel.ResolvableType; | 27 | import org.onosproject.yangutils.datamodel.ResolvableType; |
24 | import org.onosproject.yangutils.datamodel.YangIfFeature; | 28 | import org.onosproject.yangutils.datamodel.YangIfFeature; |
29 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
25 | import org.onosproject.yangutils.datamodel.YangBase; | 30 | import org.onosproject.yangutils.datamodel.YangBase; |
26 | import org.onosproject.yangutils.datamodel.YangIdentityRef; | 31 | import org.onosproject.yangutils.datamodel.YangIdentityRef; |
27 | import org.onosproject.yangutils.datamodel.YangLeaf; | 32 | import org.onosproject.yangutils.datamodel.YangLeaf; |
... | @@ -171,6 +176,10 @@ public final class DataModelUtils { | ... | @@ -171,6 +176,10 @@ public final class DataModelUtils { |
171 | resolutionNode.addToResolutionList(resolutionInfo, | 176 | resolutionNode.addToResolutionList(resolutionInfo, |
172 | ResolvableType.YANG_USES); | 177 | ResolvableType.YANG_USES); |
173 | } else if (resolutionInfo.getEntityToResolveInfo() | 178 | } else if (resolutionInfo.getEntityToResolveInfo() |
179 | + .getEntityToResolve() instanceof YangAugment) { | ||
180 | + resolutionNode.addToResolutionList(resolutionInfo, | ||
181 | + ResolvableType.YANG_AUGMENT); | ||
182 | + } else if (resolutionInfo.getEntityToResolveInfo() | ||
174 | .getEntityToResolve() instanceof YangIfFeature) { | 183 | .getEntityToResolve() instanceof YangIfFeature) { |
175 | resolutionNode.addToResolutionList(resolutionInfo, | 184 | resolutionNode.addToResolutionList(resolutionInfo, |
176 | ResolvableType.YANG_IF_FEATURE); | 185 | ResolvableType.YANG_IF_FEATURE); |
... | @@ -272,4 +281,30 @@ public final class DataModelUtils { | ... | @@ -272,4 +281,30 @@ public final class DataModelUtils { |
272 | */ | 281 | */ |
273 | return currentNode.getParent(); | 282 | return currentNode.getParent(); |
274 | } | 283 | } |
284 | + | ||
285 | + /** | ||
286 | + * Returns de-serializes YANG data-model nodes. | ||
287 | + * | ||
288 | + * @param serializableInfoSet YANG file info set | ||
289 | + * @return de-serializes YANG data-model nodes | ||
290 | + * @throws IOException when fails do IO operations | ||
291 | + */ | ||
292 | + public static List<YangNode> deSerializeDataModel(List<String> serializableInfoSet) throws IOException { | ||
293 | + | ||
294 | + List<YangNode> nodes = new ArrayList<>(); | ||
295 | + for (String fileInfo : serializableInfoSet) { | ||
296 | + YangNode node = null; | ||
297 | + try { | ||
298 | + FileInputStream fileInputStream = new FileInputStream(fileInfo); | ||
299 | + ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); | ||
300 | + node = (YangNode) objectInputStream.readObject(); | ||
301 | + nodes.add(node); | ||
302 | + objectInputStream.close(); | ||
303 | + fileInputStream.close(); | ||
304 | + } catch (IOException | ClassNotFoundException e) { | ||
305 | + throw new IOException(fileInfo + " not found."); | ||
306 | + } | ||
307 | + } | ||
308 | + return nodes; | ||
309 | + } | ||
275 | } | 310 | } | ... | ... |
... | @@ -161,6 +161,8 @@ public class YangLinkerManager | ... | @@ -161,6 +161,8 @@ public class YangLinkerManager |
161 | ((YangReferenceResolver) yangNode) | 161 | ((YangReferenceResolver) yangNode) |
162 | .resolveInterFileLinking(ResolvableType.YANG_USES); | 162 | .resolveInterFileLinking(ResolvableType.YANG_USES); |
163 | ((YangReferenceResolver) yangNode) | 163 | ((YangReferenceResolver) yangNode) |
164 | + .resolveInterFileLinking(ResolvableType.YANG_AUGMENT); | ||
165 | + ((YangReferenceResolver) yangNode) | ||
164 | .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); | 166 | .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); |
165 | ((YangReferenceResolver) yangNode) | 167 | ((YangReferenceResolver) yangNode) |
166 | .resolveInterFileLinking(ResolvableType.YANG_LEAFREF); | 168 | .resolveInterFileLinking(ResolvableType.YANG_LEAFREF); | ... | ... |
utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerUtils.java
0 → 100644
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.linker.impl; | ||
18 | + | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
22 | +import org.onosproject.yangutils.datamodel.YangAugmentableNode; | ||
23 | +import org.onosproject.yangutils.datamodel.YangAugmentedInfo; | ||
24 | +import org.onosproject.yangutils.datamodel.YangLeaf; | ||
25 | +import org.onosproject.yangutils.datamodel.YangLeafList; | ||
26 | +import org.onosproject.yangutils.datamodel.YangLeavesHolder; | ||
27 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
28 | +import org.onosproject.yangutils.linker.exceptions.LinkerException; | ||
29 | + | ||
30 | +/** | ||
31 | + * Represent utilities for YANG linker. | ||
32 | + */ | ||
33 | +public final class YangLinkerUtils { | ||
34 | + | ||
35 | + private YangLinkerUtils() { | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * Detects collision between target nodes leaf/leaf-list or child node with | ||
40 | + * augmented leaf/leaf-list or child node. | ||
41 | + * | ||
42 | + * @param targetNode target node | ||
43 | + * @param augment augment node | ||
44 | + */ | ||
45 | + private static void detectCollision(YangNode targetNode, YangAugment augment) { | ||
46 | + YangNode targetNodesChild = targetNode.getChild(); | ||
47 | + YangNode augmentsChild = augment.getChild(); | ||
48 | + YangLeavesHolder augmentsLeavesHolder = augment; | ||
49 | + YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode; | ||
50 | + | ||
51 | + YangNode parent = targetNode; | ||
52 | + if (targetNode instanceof YangAugment) { | ||
53 | + parent = targetNode.getParent(); | ||
54 | + } else { | ||
55 | + while (parent.getParent() != null) { | ||
56 | + parent = parent.getParent(); | ||
57 | + } | ||
58 | + } | ||
59 | + if (augmentsLeavesHolder.getListOfLeaf() != null && augmentsLeavesHolder.getListOfLeaf().size() != 0 | ||
60 | + && targetNodesLeavesHolder.getListOfLeaf() != null) { | ||
61 | + for (YangLeaf leaf : augmentsLeavesHolder.getListOfLeaf()) { | ||
62 | + for (YangLeaf targetLeaf : targetNodesLeavesHolder.getListOfLeaf()) { | ||
63 | + if (targetLeaf.getName().equals(leaf.getName())) { | ||
64 | + throw new LinkerException("target node " + targetNode.getName() | ||
65 | + + " contains augmented leaf " + leaf.getName() + " in module " | ||
66 | + + parent.getName()); | ||
67 | + } | ||
68 | + } | ||
69 | + } | ||
70 | + } else if (augmentsLeavesHolder.getListOfLeafList() != null | ||
71 | + && augmentsLeavesHolder.getListOfLeafList().size() != 0 | ||
72 | + && targetNodesLeavesHolder.getListOfLeafList() != null) { | ||
73 | + for (YangLeafList leafList : augmentsLeavesHolder.getListOfLeafList()) { | ||
74 | + for (YangLeafList targetLeafList : targetNodesLeavesHolder.getListOfLeafList()) { | ||
75 | + if (targetLeafList.getName().equals(leafList.getName())) { | ||
76 | + throw new LinkerException("target node " + targetNode.getName() | ||
77 | + + " contains augmented leaf-list" + leafList.getName() + " in module " | ||
78 | + + parent.getName()); | ||
79 | + } | ||
80 | + } | ||
81 | + } | ||
82 | + } else { | ||
83 | + while (augmentsChild != null) { | ||
84 | + while (targetNodesChild != null) { | ||
85 | + if (targetNodesChild.getName().equals(augmentsChild.getName())) { | ||
86 | + throw new LinkerException("target node " + targetNode.getName() | ||
87 | + + " contains augmented child node" + augmentsChild.getName() + " in module " | ||
88 | + + parent.getName()); | ||
89 | + } | ||
90 | + targetNodesChild = targetNodesChild.getNextSibling(); | ||
91 | + } | ||
92 | + augmentsChild = augmentsChild.getNextSibling(); | ||
93 | + } | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * Detects collision between target nodes and its all leaf/leaf-list or child node with | ||
99 | + * augmented leaf/leaf-list or child node. | ||
100 | + * | ||
101 | + * @param targetNode target node | ||
102 | + * @param augment augment node | ||
103 | + */ | ||
104 | + public static void detectCollisionForAugmentedNode(YangNode targetNode, YangAugment augment) { | ||
105 | + // Detect collision for target node and augment node. | ||
106 | + detectCollision(targetNode, augment); | ||
107 | + List<YangAugmentedInfo> yangAugmentedInfo = ((YangAugmentableNode) targetNode).getAugmentedInfoList(); | ||
108 | + // Detect collision for target augment node and current augment node. | ||
109 | + for (YangAugmentedInfo info : yangAugmentedInfo) { | ||
110 | + detectCollision((YangAugment) info, augment); | ||
111 | + } | ||
112 | + } | ||
113 | +} |
... | @@ -24,6 +24,8 @@ import java.util.Stack; | ... | @@ -24,6 +24,8 @@ import java.util.Stack; |
24 | import org.onosproject.yangutils.datamodel.Resolvable; | 24 | import org.onosproject.yangutils.datamodel.Resolvable; |
25 | import org.onosproject.yangutils.datamodel.ResolvableType; | 25 | import org.onosproject.yangutils.datamodel.ResolvableType; |
26 | import org.onosproject.yangutils.datamodel.YangAtomicPath; | 26 | import org.onosproject.yangutils.datamodel.YangAtomicPath; |
27 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
28 | +import org.onosproject.yangutils.datamodel.YangAugmentableNode; | ||
27 | import org.onosproject.yangutils.datamodel.YangBase; | 29 | import org.onosproject.yangutils.datamodel.YangBase; |
28 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; | 30 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; |
29 | import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo; | 31 | import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo; |
... | @@ -55,10 +57,12 @@ import org.onosproject.yangutils.datamodel.YangSubModule; | ... | @@ -55,10 +57,12 @@ import org.onosproject.yangutils.datamodel.YangSubModule; |
55 | import org.onosproject.yangutils.datamodel.YangType; | 57 | import org.onosproject.yangutils.datamodel.YangType; |
56 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 58 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
57 | import org.onosproject.yangutils.datamodel.YangUses; | 59 | import org.onosproject.yangutils.datamodel.YangUses; |
60 | +import org.onosproject.yangutils.datamodel.YangXPathResolver; | ||
58 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 61 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
59 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | 62 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; |
60 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | 63 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; |
61 | import org.onosproject.yangutils.linker.YangLinkingPhase; | 64 | import org.onosproject.yangutils.linker.YangLinkingPhase; |
65 | +import org.onosproject.yangutils.linker.exceptions.LinkerException; | ||
62 | 66 | ||
63 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTER_FILE_LINKED; | 67 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTER_FILE_LINKED; |
64 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED; | 68 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED; |
... | @@ -68,6 +72,7 @@ import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNDEFIN | ... | @@ -68,6 +72,7 @@ import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNDEFIN |
68 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNRESOLVED; | 72 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNRESOLVED; |
69 | import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE; | 73 | import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE; |
70 | import static org.onosproject.yangutils.linker.YangLinkingPhase.INTRA_FILE; | 74 | import static org.onosproject.yangutils.linker.YangLinkingPhase.INTRA_FILE; |
75 | +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.detectCollisionForAugmentedNode; | ||
71 | import static org.onosproject.yangutils.utils.UtilConstants.FEATURE_LINKER_ERROR; | 76 | import static org.onosproject.yangutils.utils.UtilConstants.FEATURE_LINKER_ERROR; |
72 | import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR; | 77 | import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR; |
73 | import static org.onosproject.yangutils.utils.UtilConstants.INPUT; | 78 | import static org.onosproject.yangutils.utils.UtilConstants.INPUT; |
... | @@ -1438,15 +1443,74 @@ public class YangResolutionInfoImpl<T> | ... | @@ -1438,15 +1443,74 @@ public class YangResolutionInfoImpl<T> |
1438 | throw new DataModelException("Data Model Exception: Entity to resolved is not Resolvable"); | 1443 | throw new DataModelException("Data Model Exception: Entity to resolved is not Resolvable"); |
1439 | } | 1444 | } |
1440 | 1445 | ||
1446 | + if (entityToResolve instanceof YangXPathResolver) { | ||
1447 | + //Process x-path linking. | ||
1448 | + processXPathLinking(getEntityToResolveInfo(), dataModelRootNode); | ||
1449 | + | ||
1450 | + } else { | ||
1451 | + | ||
1441 | // Push the initial entity to resolve in stack. | 1452 | // Push the initial entity to resolve in stack. |
1442 | addInPartialResolvedStack(getEntityToResolveInfo()); | 1453 | addInPartialResolvedStack(getEntityToResolveInfo()); |
1443 | 1454 | ||
1444 | // Inter file linking and resolution. | 1455 | // Inter file linking and resolution. |
1445 | linkInterFileAndResolve(); | 1456 | linkInterFileAndResolve(); |
1446 | 1457 | ||
1447 | - // Resolve the derived types having leafref. | ||
1448 | addDerivedRefTypeToRefTypeResolutionList(); | 1458 | addDerivedRefTypeToRefTypeResolutionList(); |
1449 | } | 1459 | } |
1460 | + } | ||
1461 | + | ||
1462 | + /** | ||
1463 | + * Process x-path linking for augment and leaf-ref. | ||
1464 | + * | ||
1465 | + * @param entityToResolveInfo entity to resolve | ||
1466 | + * @param root root node | ||
1467 | + */ | ||
1468 | + private void processXPathLinking(YangEntityToResolveInfoImpl<T> entityToResolveInfo, | ||
1469 | + YangReferenceResolver root) { | ||
1470 | + YangXpathLinker<T> xPathLinker = new YangXpathLinker<T>(); | ||
1471 | + T entityToResolve = entityToResolveInfo.getEntityToResolve(); | ||
1472 | + if (entityToResolve instanceof YangAugment) { | ||
1473 | + YangNode targetNode = null; | ||
1474 | + YangAugment augment = (YangAugment) entityToResolve; | ||
1475 | + targetNode = xPathLinker.processAugmentXpathLinking(augment.getTargetNode(), | ||
1476 | + (YangNode) root); | ||
1477 | + if (targetNode != null) { | ||
1478 | + if (targetNode instanceof YangAugmentableNode) { | ||
1479 | + detectCollisionForAugmentedNode(targetNode, augment); | ||
1480 | + ((YangAugmentableNode) targetNode).addAugmentation(augment); | ||
1481 | + augment.setAugmentedNode(targetNode); | ||
1482 | + Resolvable resolvable = (Resolvable) entityToResolve; | ||
1483 | + resolvable.setResolvableStatus(RESOLVED); | ||
1484 | + } else { | ||
1485 | + throw new LinkerException("Invalid target node type " + targetNode.getNodeType() + " for " | ||
1486 | + + augment.getName()); | ||
1487 | + } | ||
1488 | + } else { | ||
1489 | + throw new LinkerException("Failed to link " + augment.getName()); | ||
1490 | + } | ||
1491 | + } else if (entityToResolve instanceof YangLeafRef) { | ||
1492 | + YangLeafRef leafRef = (YangLeafRef) entityToResolve; | ||
1493 | + Object target = xPathLinker.processLeafRefXpathLinking(leafRef.getAtomicPath(), | ||
1494 | + (YangNode) root); | ||
1495 | + if (target != null) { | ||
1496 | + YangLeaf leaf = null; | ||
1497 | + YangLeafList leafList = null; | ||
1498 | + leafRef.setReferredLeafOrLeafList(target); | ||
1499 | + if (target instanceof YangLeaf) { | ||
1500 | + leaf = (YangLeaf) target; | ||
1501 | + leafRef.setEffectiveDataType(leaf.getDataType()); | ||
1502 | + } else { | ||
1503 | + leafList = (YangLeafList) target; | ||
1504 | + leafRef.setEffectiveDataType(leafList.getDataType()); | ||
1505 | + } | ||
1506 | + leafRef.setResolvableStatus(RESOLVED); | ||
1507 | + //TODO: add logic for leaf-ref for path predicates. | ||
1508 | + } else { | ||
1509 | + throw new LinkerException("YANG file error: Unable to find base leaf/leaf-list for given leafref " | ||
1510 | + + leafRef.getPath()); | ||
1511 | + } | ||
1512 | + } | ||
1513 | + } | ||
1450 | 1514 | ||
1451 | /** | 1515 | /** |
1452 | * Returns the referenced prefix of entity under resolution. | 1516 | * Returns the referenced prefix of entity under resolution. | ... | ... |
utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangXpathLinker.java
0 → 100644
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.linker.impl; | ||
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; | ||
25 | + | ||
26 | +import org.onosproject.yangutils.datamodel.YangAtomicPath; | ||
27 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
28 | +import org.onosproject.yangutils.datamodel.YangImport; | ||
29 | +import org.onosproject.yangutils.datamodel.YangInclude; | ||
30 | +import org.onosproject.yangutils.datamodel.YangLeaf; | ||
31 | +import org.onosproject.yangutils.datamodel.YangLeafList; | ||
32 | +import org.onosproject.yangutils.datamodel.YangLeavesHolder; | ||
33 | +import org.onosproject.yangutils.datamodel.YangModule; | ||
34 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
35 | +import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
36 | +import org.onosproject.yangutils.datamodel.YangSubModule; | ||
37 | +import org.onosproject.yangutils.datamodel.YangUses; | ||
38 | +import org.onosproject.yangutils.linker.exceptions.LinkerException; | ||
39 | + | ||
40 | +/** | ||
41 | + * Represents x-path linking. | ||
42 | + * | ||
43 | + * @param <T> x-path linking can be done for target node or for target leaf/leaf-list | ||
44 | + */ | ||
45 | +public class YangXpathLinker<T> { | ||
46 | + | ||
47 | + /** | ||
48 | + * Enum for prefix resolver type when augment has come in path. | ||
49 | + */ | ||
50 | + private static enum PrefixResolverType { | ||
51 | + | ||
52 | + /** | ||
53 | + * When prefix changes from inter file to intra file. | ||
54 | + */ | ||
55 | + INTER_TO_INTRA, | ||
56 | + | ||
57 | + /** | ||
58 | + * When prefix changes from intra file to inter file. | ||
59 | + */ | ||
60 | + INTRA_TO_INTER, | ||
61 | + | ||
62 | + /** | ||
63 | + * When prefix changes from one inter file to other inter file. | ||
64 | + */ | ||
65 | + INTER_TO_INTER, | ||
66 | + | ||
67 | + /** | ||
68 | + * When no prefix change occurres. | ||
69 | + */ | ||
70 | + NO_PREFIX_CHANGE_FOR_INTRA, | ||
71 | + | ||
72 | + /** | ||
73 | + * When no prefix change occurres. | ||
74 | + */ | ||
75 | + NO_PREFIX_CHANGE_FOR_INTER | ||
76 | + } | ||
77 | + | ||
78 | + private List<YangAtomicPath> absPaths; | ||
79 | + private YangNode rootNode; | ||
80 | + private PrefixResolverType type; | ||
81 | + private String curPrefix; | ||
82 | + private Map<YangAtomicPath, YangNode> resolvedNodes; | ||
83 | + | ||
84 | + /** | ||
85 | + * Creates an instance of x-path linker. | ||
86 | + */ | ||
87 | + public YangXpathLinker() { | ||
88 | + absPaths = new ArrayList<>(); | ||
89 | + setResolvedNodes(new HashMap<>()); | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * Returns list of target nodes paths. | ||
94 | + * | ||
95 | + * @return target nodes paths | ||
96 | + */ | ||
97 | + private List<YangAtomicPath> getAbsPaths() { | ||
98 | + return absPaths; | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * Sets target nodes paths. | ||
103 | + * | ||
104 | + * @param absPaths target nodes paths | ||
105 | + */ | ||
106 | + private void setAbsPaths(List<YangAtomicPath> absPaths) { | ||
107 | + this.absPaths = absPaths; | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * Returns current prefix. | ||
112 | + * | ||
113 | + * @return current prefix | ||
114 | + */ | ||
115 | + private String getCurPrefix() { | ||
116 | + return curPrefix; | ||
117 | + } | ||
118 | + | ||
119 | + /** | ||
120 | + * Sets current prefix. | ||
121 | + * | ||
122 | + * @param curPrefix current prefix | ||
123 | + */ | ||
124 | + private void setCurPrefix(String curPrefix) { | ||
125 | + this.curPrefix = curPrefix; | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * Return root node. | ||
130 | + * | ||
131 | + * @return root Node | ||
132 | + */ | ||
133 | + private YangNode getRootNode() { | ||
134 | + return rootNode; | ||
135 | + } | ||
136 | + | ||
137 | + /** | ||
138 | + * Sets root node. | ||
139 | + * | ||
140 | + * @param rootNode root node | ||
141 | + */ | ||
142 | + private void setRootNode(YangNode rootNode) { | ||
143 | + this.rootNode = rootNode; | ||
144 | + } | ||
145 | + | ||
146 | + /** | ||
147 | + * Returns prefix resolver type. | ||
148 | + * | ||
149 | + * @return prefix resolver type | ||
150 | + */ | ||
151 | + private PrefixResolverType getPrefixResolverType() { | ||
152 | + return type; | ||
153 | + } | ||
154 | + | ||
155 | + /** | ||
156 | + * Sets prefix resolver type. | ||
157 | + * | ||
158 | + * @param type prefix resolver type | ||
159 | + */ | ||
160 | + private void setPrefixResolverType(PrefixResolverType type) { | ||
161 | + this.type = type; | ||
162 | + } | ||
163 | + | ||
164 | + /** | ||
165 | + * Returns resolved nodes. | ||
166 | + * | ||
167 | + * @return resolved nodes | ||
168 | + */ | ||
169 | + public Map<YangAtomicPath, YangNode> getResolvedNodes() { | ||
170 | + return resolvedNodes; | ||
171 | + } | ||
172 | + | ||
173 | + /** | ||
174 | + * Sets resolved nodes. | ||
175 | + * | ||
176 | + * @param resolvedNodes resolved nodes | ||
177 | + */ | ||
178 | + private void setResolvedNodes(Map<YangAtomicPath, YangNode> resolvedNodes) { | ||
179 | + this.resolvedNodes = resolvedNodes; | ||
180 | + } | ||
181 | + | ||
182 | + /** | ||
183 | + * Adds node to resolved nodes. | ||
184 | + * | ||
185 | + * @param path absolute path | ||
186 | + * @param node resolved node | ||
187 | + */ | ||
188 | + private void addToResolvedNodes(YangAtomicPath path, YangNode node) { | ||
189 | + getResolvedNodes().put(path, node); | ||
190 | + } | ||
191 | + | ||
192 | + /** | ||
193 | + * Returns list of augment nodes. | ||
194 | + * | ||
195 | + * @param node root node | ||
196 | + * @return list of augment nodes | ||
197 | + */ | ||
198 | + public List<YangAugment> getListOfYangAugment(YangNode node) { | ||
199 | + node = node.getChild(); | ||
200 | + List<YangAugment> augments = new ArrayList<>(); | ||
201 | + while (node != null) { | ||
202 | + if (node instanceof YangAugment) { | ||
203 | + augments.add((YangAugment) node); | ||
204 | + } | ||
205 | + node = node.getNextSibling(); | ||
206 | + } | ||
207 | + return augments; | ||
208 | + } | ||
209 | + | ||
210 | + /** | ||
211 | + * Process absolute node path for target leaf. | ||
212 | + * | ||
213 | + * @param absPaths absolute path node list | ||
214 | + * @param root root node | ||
215 | + * @return linked target node | ||
216 | + */ | ||
217 | + public T processLeafRefXpathLinking(List<YangAtomicPath> absPaths, YangNode root) { | ||
218 | + | ||
219 | + YangNode targetNode = null; | ||
220 | + setRootNode(root); | ||
221 | + YangAtomicPath leafRefPath = absPaths.get(absPaths.size() - 1); | ||
222 | + | ||
223 | + // When leaf-ref path contains only one absolute path. | ||
224 | + if (absPaths.size() == 1) { | ||
225 | + targetNode = getTargetNodewhenSizeIsOne(absPaths); | ||
226 | + } else { | ||
227 | + absPaths.remove(absPaths.size() - 1); | ||
228 | + | ||
229 | + setAbsPaths(absPaths); | ||
230 | + targetNode = parseData(root); | ||
231 | + } | ||
232 | + if (targetNode == null) { | ||
233 | + targetNode = parsePath(getIncludedNode(root)); | ||
234 | + } | ||
235 | + | ||
236 | + if (targetNode != null) { | ||
237 | + YangLeaf targetLeaf = searchReferredLeaf(targetNode, leafRefPath.getNodeIdentifier().getName()); | ||
238 | + if (targetLeaf == null) { | ||
239 | + YangLeafList targetLeafList = searchReferredLeafList(targetNode, | ||
240 | + leafRefPath.getNodeIdentifier().getName()); | ||
241 | + if (targetLeafList != null) { | ||
242 | + return (T) targetLeafList; | ||
243 | + } else { | ||
244 | + throw new LinkerException( | ||
245 | + "YANG file error: Unable to find base leaf/leaf-list for given leafref " | ||
246 | + + leafRefPath.getNodeIdentifier().getName()); | ||
247 | + } | ||
248 | + } | ||
249 | + return (T) targetLeaf; | ||
250 | + } | ||
251 | + return null; | ||
252 | + } | ||
253 | + | ||
254 | + /** | ||
255 | + * Returns target node when leaf-ref has only one absolute path in list. | ||
256 | + * | ||
257 | + * @param absPaths absolute paths | ||
258 | + * @return target node | ||
259 | + */ | ||
260 | + private YangNode getTargetNodewhenSizeIsOne(List<YangAtomicPath> absPaths) { | ||
261 | + if (absPaths.get(0).getNodeIdentifier().getPrefix() != null | ||
262 | + && !absPaths.get(0).getNodeIdentifier().getPrefix().equals(getRootsPrefix(getRootNode()))) { | ||
263 | + return getImportedNode(getRootNode(), absPaths.get(0).getNodeIdentifier()); | ||
264 | + } | ||
265 | + return getRootNode(); | ||
266 | + | ||
267 | + } | ||
268 | + | ||
269 | + /** | ||
270 | + * Process absolute node path linking for augment. | ||
271 | + * | ||
272 | + * @param absPaths absolute path node list | ||
273 | + * @param root root node | ||
274 | + * @return linked target node | ||
275 | + */ | ||
276 | + public YangNode processAugmentXpathLinking(List<YangAtomicPath> absPaths, YangNode root) { | ||
277 | + | ||
278 | + setAbsPaths(absPaths); | ||
279 | + setRootNode(root); | ||
280 | + | ||
281 | + YangNode targetNode = parseData(root); | ||
282 | + | ||
283 | + if (targetNode == null) { | ||
284 | + targetNode = parsePath(getIncludedNode(root)); | ||
285 | + } | ||
286 | + return targetNode; | ||
287 | + | ||
288 | + } | ||
289 | + | ||
290 | + /** | ||
291 | + * Searches for the referred leaf in target node. | ||
292 | + * | ||
293 | + * @param targetNode target node | ||
294 | + * @param leafName leaf name | ||
295 | + * @return target leaf | ||
296 | + */ | ||
297 | + private YangLeaf searchReferredLeaf(YangNode targetNode, String leafName) { | ||
298 | + if (!(targetNode instanceof YangLeavesHolder)) { | ||
299 | + throw new LinkerException("Refered node " + targetNode.getName() + | ||
300 | + "should be of type leaves holder "); | ||
301 | + } | ||
302 | + YangLeavesHolder holder = (YangLeavesHolder) targetNode; | ||
303 | + List<YangLeaf> leaves = holder.getListOfLeaf(); | ||
304 | + for (YangLeaf leaf : leaves) { | ||
305 | + if (leaf.getName().equals(leafName)) { | ||
306 | + return leaf; | ||
307 | + } | ||
308 | + } | ||
309 | + return null; | ||
310 | + } | ||
311 | + | ||
312 | + /** | ||
313 | + * Searches for the referred leaf-list in target node. | ||
314 | + * | ||
315 | + * @param targetNode target node | ||
316 | + * @param leafListName leaf-list name | ||
317 | + * @return target leaf-list | ||
318 | + */ | ||
319 | + private YangLeafList searchReferredLeafList(YangNode targetNode, String leafListName) { | ||
320 | + if (!(targetNode instanceof YangLeavesHolder)) { | ||
321 | + throw new LinkerException("Refered node " + targetNode.getName() + | ||
322 | + "should be of type leaves holder "); | ||
323 | + } | ||
324 | + YangLeavesHolder holder = (YangLeavesHolder) targetNode; | ||
325 | + List<YangLeafList> leavesList = holder.getListOfLeafList(); | ||
326 | + for (YangLeafList leafList : leavesList) { | ||
327 | + if (leafList.getName().equals(leafListName)) { | ||
328 | + return leafList; | ||
329 | + } | ||
330 | + } | ||
331 | + return null; | ||
332 | + } | ||
333 | + | ||
334 | + /** | ||
335 | + * Process linking using for node identifier for inter/intra file. | ||
336 | + * | ||
337 | + * @param root root node | ||
338 | + * @return linked target node | ||
339 | + */ | ||
340 | + private YangNode parseData(YangNode root) { | ||
341 | + String rootPrefix = getRootsPrefix(root); | ||
342 | + Iterator<YangAtomicPath> pathIterator = getAbsPaths().iterator(); | ||
343 | + YangAtomicPath path = pathIterator.next(); | ||
344 | + if (path.getNodeIdentifier().getPrefix() != null | ||
345 | + && !path.getNodeIdentifier().getPrefix().equals(rootPrefix)) { | ||
346 | + return parsePath(getImportedNode(root, path.getNodeIdentifier())); | ||
347 | + } else { | ||
348 | + return parsePath(root); | ||
349 | + } | ||
350 | + } | ||
351 | + | ||
352 | + /** | ||
353 | + * Process linking of target node in root node. | ||
354 | + * | ||
355 | + * @param root root node | ||
356 | + * @return linked target node | ||
357 | + */ | ||
358 | + private YangNode parsePath(YangNode root) { | ||
359 | + | ||
360 | + YangNode tempNode = root; | ||
361 | + Stack<YangNode> linkerStack = new Stack<>(); | ||
362 | + Iterator<YangAtomicPath> pathIterator = getAbsPaths().iterator(); | ||
363 | + YangAtomicPath tempPath = pathIterator.next(); | ||
364 | + setCurPrefix(tempPath.getNodeIdentifier().getPrefix()); | ||
365 | + int index = 0; | ||
366 | + YangNode tempAugment = null; | ||
367 | + do { | ||
368 | + | ||
369 | + if (tempNode instanceof YangUses) { | ||
370 | + tempNode = handleUsesNode(tempNode, tempPath.getNodeIdentifier()); | ||
371 | + if (pathIterator.hasNext()) { | ||
372 | + tempPath = pathIterator.next(); | ||
373 | + index++; | ||
374 | + } else { | ||
375 | + addToResolvedNodes(tempPath, tempNode); | ||
376 | + return tempNode; | ||
377 | + } | ||
378 | + } | ||
379 | + | ||
380 | + if (tempPath.getNodeIdentifier().getPrefix() == null) { | ||
381 | + tempAugment = resolveIntraFileAugment(tempPath, root); | ||
382 | + } else { | ||
383 | + tempAugment = resolveInterFileAugment(tempPath, root); | ||
384 | + } | ||
385 | + | ||
386 | + if (tempAugment != null) { | ||
387 | + linkerStack.push(tempNode); | ||
388 | + tempNode = tempAugment; | ||
389 | + } | ||
390 | + | ||
391 | + tempNode = searchTargetNode(tempNode, tempPath.getNodeIdentifier()); | ||
392 | + if (tempNode == null && linkerStack.size() != 0) { | ||
393 | + tempNode = linkerStack.peek(); | ||
394 | + linkerStack.pop(); | ||
395 | + tempNode = searchTargetNode(tempNode, tempPath.getNodeIdentifier()); | ||
396 | + } | ||
397 | + | ||
398 | + if (tempNode != null) { | ||
399 | + addToResolvedNodes(tempPath, tempNode); | ||
400 | + } | ||
401 | + | ||
402 | + if (index == getAbsPaths().size() - 1) { | ||
403 | + break; | ||
404 | + } | ||
405 | + tempPath = pathIterator.next(); | ||
406 | + index++; | ||
407 | + } while (validate(tempNode, index)); | ||
408 | + return tempNode; | ||
409 | + } | ||
410 | + | ||
411 | + /** | ||
412 | + * Resolves intra file augment linking. | ||
413 | + * | ||
414 | + * @param tempPath temporary absolute path | ||
415 | + * @param root root node | ||
416 | + * @return linked target node | ||
417 | + */ | ||
418 | + private YangNode resolveIntraFileAugment(YangAtomicPath tempPath, YangNode root) { | ||
419 | + YangNode tempAugment = null; | ||
420 | + setPrefixResolverType(PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTRA); | ||
421 | + if (getCurPrefix() != tempPath.getNodeIdentifier().getPrefix()) { | ||
422 | + setPrefixResolverType(PrefixResolverType.INTRA_TO_INTER); | ||
423 | + root = getIncludedNode(getRootNode()); | ||
424 | + } | ||
425 | + | ||
426 | + setCurPrefix(tempPath.getNodeIdentifier().getPrefix()); | ||
427 | + tempAugment = getAugment(tempPath.getNodeIdentifier(), root, getAbsPaths()); | ||
428 | + if (tempAugment == null) { | ||
429 | + tempAugment = getAugment(tempPath.getNodeIdentifier(), getRootNode(), getAbsPaths()); | ||
430 | + } | ||
431 | + return tempAugment; | ||
432 | + } | ||
433 | + | ||
434 | + /** | ||
435 | + * Resolves inter file augment linking. | ||
436 | + * | ||
437 | + * @param tempPath temporary absolute path | ||
438 | + * @param root root node | ||
439 | + * @return linked target node | ||
440 | + */ | ||
441 | + private YangNode resolveInterFileAugment(YangAtomicPath tempPath, YangNode root) { | ||
442 | + | ||
443 | + YangNode tempAugment = null; | ||
444 | + if (tempPath.getNodeIdentifier().getPrefix().equals(getCurPrefix())) { | ||
445 | + setPrefixResolverType(PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTER); | ||
446 | + } else { | ||
447 | + setCurPrefix(tempPath.getNodeIdentifier().getPrefix()); | ||
448 | + setPrefixResolverType(PrefixResolverType.INTER_TO_INTER); | ||
449 | + if (getCurPrefix() == null) { | ||
450 | + setPrefixResolverType(PrefixResolverType.INTER_TO_INTRA); | ||
451 | + } | ||
452 | + root = getImportedNode(getRootNode(), tempPath.getNodeIdentifier()); | ||
453 | + } | ||
454 | + tempAugment = getAugment(tempPath.getNodeIdentifier(), root, getAbsPaths()); | ||
455 | + if (tempAugment == null && getPrefixResolverType().equals(PrefixResolverType.INTER_TO_INTER)) { | ||
456 | + return resolveInterToInterFileAugment(root); | ||
457 | + } | ||
458 | + return tempAugment; | ||
459 | + } | ||
460 | + | ||
461 | + /** | ||
462 | + * Resolves augment when prefix changed from inter file to inter file. | ||
463 | + * it may be possible that the prefix used in imported module is different the | ||
464 | + * given list of node identifiers. | ||
465 | + * | ||
466 | + * @param root root node | ||
467 | + * @return target node | ||
468 | + */ | ||
469 | + private YangNode resolveInterToInterFileAugment(YangNode root) { | ||
470 | + List<YangAugment> augments = getListOfYangAugment(root); | ||
471 | + int index; | ||
472 | + List<YangAtomicPath> absPaths = new ArrayList<>(); | ||
473 | + for (YangAugment augment : augments) { | ||
474 | + index = 0; | ||
475 | + | ||
476 | + for (YangAtomicPath path : augment.getTargetNode()) { | ||
477 | + | ||
478 | + if (!searchForAugmentInImportedNode(path.getNodeIdentifier(), index)) { | ||
479 | + absPaths.clear(); | ||
480 | + break; | ||
481 | + } | ||
482 | + absPaths.add(path); | ||
483 | + index++; | ||
484 | + } | ||
485 | + if (!absPaths.isEmpty() && absPaths.size() == getAbsPaths().size() - 1) { | ||
486 | + return augment; | ||
487 | + } else { | ||
488 | + absPaths.clear(); | ||
489 | + } | ||
490 | + } | ||
491 | + return null; | ||
492 | + } | ||
493 | + | ||
494 | + /** | ||
495 | + * Searches for the augment node in imported module when prefix has changed from | ||
496 | + * inter file to inter file. | ||
497 | + * @param nodeId node id | ||
498 | + * @param index index | ||
499 | + * @return true if found | ||
500 | + */ | ||
501 | + private boolean searchForAugmentInImportedNode(YangNodeIdentifier nodeId, int index) { | ||
502 | + YangNodeIdentifier tempNodeId = getAbsPaths().get(index).getNodeIdentifier(); | ||
503 | + return nodeId.getName().equals(tempNodeId.getName()); | ||
504 | + } | ||
505 | + | ||
506 | + /** | ||
507 | + * Returns augment node. | ||
508 | + * | ||
509 | + * @param tempNodeId temporary absolute path id | ||
510 | + * @param root root node | ||
511 | + * @return linked target node | ||
512 | + */ | ||
513 | + private YangNode getAugment(YangNodeIdentifier tempNodeId, YangNode root, List<YangAtomicPath> absPaths) { | ||
514 | + String augmentName = getAugmentNodeIdentifier(tempNodeId, absPaths); | ||
515 | + if (augmentName != null) { | ||
516 | + return searchAugmentNode(root, augmentName); | ||
517 | + } | ||
518 | + return null; | ||
519 | + } | ||
520 | + | ||
521 | + /** | ||
522 | + * Process linking using import list. | ||
523 | + * | ||
524 | + * @param root root node | ||
525 | + * @param nodeId node identifier | ||
526 | + * @return linked target node | ||
527 | + */ | ||
528 | + private YangNode getImportedNode(YangNode root, YangNodeIdentifier nodeId) { | ||
529 | + | ||
530 | + List<YangImport> importList = new ArrayList<>(); | ||
531 | + | ||
532 | + if (root instanceof YangModule) { | ||
533 | + importList = ((YangModule) root).getImportList(); | ||
534 | + } else { | ||
535 | + importList = ((YangSubModule) root).getImportList(); | ||
536 | + } | ||
537 | + | ||
538 | + for (YangImport imported : importList) { | ||
539 | + if (imported.getPrefixId().equals(nodeId.getPrefix())) { | ||
540 | + return imported.getImportedNode(); | ||
541 | + } | ||
542 | + } | ||
543 | + | ||
544 | + return root; | ||
545 | + } | ||
546 | + | ||
547 | + /** | ||
548 | + * Process linking using include list. | ||
549 | + * | ||
550 | + * @param root root node | ||
551 | + * @return linked target node | ||
552 | + */ | ||
553 | + private YangNode getIncludedNode(YangNode root) { | ||
554 | + | ||
555 | + List<YangInclude> includeList = new ArrayList<>(); | ||
556 | + | ||
557 | + if (root instanceof YangModule) { | ||
558 | + includeList = ((YangModule) root).getIncludeList(); | ||
559 | + } else { | ||
560 | + includeList = ((YangSubModule) root).getIncludeList(); | ||
561 | + } | ||
562 | + | ||
563 | + for (YangInclude included : includeList) { | ||
564 | + return included.getIncludedNode(); | ||
565 | + } | ||
566 | + | ||
567 | + return root; | ||
568 | + } | ||
569 | + | ||
570 | + /** | ||
571 | + * Returns augments node id. | ||
572 | + * | ||
573 | + * @param nodeId node identifier | ||
574 | + * @return augment node id | ||
575 | + */ | ||
576 | + private String getAugmentNodeIdentifier(YangNodeIdentifier nodeId, List<YangAtomicPath> absPaths) { | ||
577 | + | ||
578 | + Iterator<YangAtomicPath> nodeIdIterator = absPaths.iterator(); | ||
579 | + YangAtomicPath tempNodeId = null; | ||
580 | + StringBuilder builder = new StringBuilder(); | ||
581 | + while (nodeIdIterator.hasNext()) { | ||
582 | + tempNodeId = nodeIdIterator.next(); | ||
583 | + if (!tempNodeId.getNodeIdentifier().equals(nodeId)) { | ||
584 | + if (tempNodeId.getNodeIdentifier().getPrefix() != null | ||
585 | + && (getPrefixResolverType().equals(PrefixResolverType.INTER_TO_INTER) | ||
586 | + || getPrefixResolverType().equals(PrefixResolverType.INTRA_TO_INTER))) { | ||
587 | + builder.append("/" + tempNodeId.getNodeIdentifier().getPrefix()); | ||
588 | + builder.append(":" + tempNodeId.getNodeIdentifier().getName()); | ||
589 | + } else { | ||
590 | + builder.append("/" + tempNodeId.getNodeIdentifier().getName()); | ||
591 | + } | ||
592 | + } else { | ||
593 | + return builder.toString(); | ||
594 | + } | ||
595 | + } | ||
596 | + return null; | ||
597 | + } | ||
598 | + | ||
599 | + /** | ||
600 | + * Searches augment node in root node. | ||
601 | + * | ||
602 | + * @param node root node | ||
603 | + * @param tempNodeId node identifier | ||
604 | + * @return target augment node | ||
605 | + */ | ||
606 | + private YangNode searchAugmentNode(YangNode node, String tempNodeId) { | ||
607 | + node = node.getChild(); | ||
608 | + while (node != null) { | ||
609 | + if (node instanceof YangAugment) { | ||
610 | + if (((YangAugment) node).getName().equals(tempNodeId)) { | ||
611 | + return node; | ||
612 | + } | ||
613 | + } | ||
614 | + node = node.getNextSibling(); | ||
615 | + } | ||
616 | + return null; | ||
617 | + } | ||
618 | + | ||
619 | + /** | ||
620 | + * Validates for target node if target node found or not. | ||
621 | + * | ||
622 | + * @param tempNode temporary node | ||
623 | + * @param index current index of list | ||
624 | + * @return false if target node found | ||
625 | + */ | ||
626 | + private boolean validate(YangNode tempNode, int index) { | ||
627 | + | ||
628 | + int size = getAbsPaths().size(); | ||
629 | + if (tempNode != null && index != size) { | ||
630 | + return true; | ||
631 | + } else if (tempNode != null && index == size) { | ||
632 | + return false; | ||
633 | + // this is your target node. | ||
634 | + } else if (tempNode == null && index != size) { | ||
635 | + return false; | ||
636 | + // this could be in submodule as well. | ||
637 | + } | ||
638 | + return false; | ||
639 | + } | ||
640 | + | ||
641 | + /** | ||
642 | + * Searches target node in root node. | ||
643 | + * | ||
644 | + * @param node root node | ||
645 | + * @param curNodeId YANG node identifier | ||
646 | + * @return linked target node | ||
647 | + */ | ||
648 | + private YangNode searchTargetNode(YangNode node, YangNodeIdentifier curNodeId) { | ||
649 | + | ||
650 | + if (node != null) { | ||
651 | + node = node.getChild(); | ||
652 | + } | ||
653 | + | ||
654 | + while (node != null) { | ||
655 | + if (node.getName().equals(curNodeId.getName())) { | ||
656 | + return node; | ||
657 | + } | ||
658 | + node = node.getNextSibling(); | ||
659 | + } | ||
660 | + return null; | ||
661 | + } | ||
662 | + | ||
663 | + /** | ||
664 | + * Handles linking when uses node is present. | ||
665 | + * | ||
666 | + * @param node uses node | ||
667 | + * @param curNodeId current node id | ||
668 | + * @return linked node | ||
669 | + */ | ||
670 | + private YangNode handleUsesNode(YangNode node, YangNodeIdentifier curNodeId) { | ||
671 | + YangNode tempNode = null; | ||
672 | + tempNode = searchInUsesNode((YangUses) node, curNodeId); | ||
673 | + if (tempNode != null) { | ||
674 | + return tempNode; | ||
675 | + } | ||
676 | + return null; | ||
677 | + } | ||
678 | + | ||
679 | + /** | ||
680 | + * Searches target node in uses resolved list. | ||
681 | + * | ||
682 | + * @param uses uses node | ||
683 | + * @param curNodeId current node id | ||
684 | + * @return linked target node | ||
685 | + */ | ||
686 | + private YangNode searchInUsesNode(YangUses uses, YangNodeIdentifier curNodeId) { | ||
687 | + | ||
688 | + List<YangNode> resolvedNodes = uses.getUsesResolvedNodeList(); | ||
689 | + for (YangNode node : resolvedNodes) { | ||
690 | + if (node.getName().equals(curNodeId.getName())) { | ||
691 | + return node; | ||
692 | + } | ||
693 | + } | ||
694 | + return null; | ||
695 | + } | ||
696 | + | ||
697 | + /** | ||
698 | + * Returns root prefix. | ||
699 | + * | ||
700 | + * @param root root node | ||
701 | + * @return root prefix | ||
702 | + */ | ||
703 | + private String getRootsPrefix(YangNode root) { | ||
704 | + if (root instanceof YangModule) { | ||
705 | + return ((YangModule) root).getPrefix(); | ||
706 | + } else { | ||
707 | + return ((YangSubModule) root).getPrefix(); | ||
708 | + } | ||
709 | + } | ||
710 | + | ||
711 | +} |
... | @@ -18,18 +18,20 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -18,18 +18,20 @@ package org.onosproject.yangutils.parser.impl.listeners; |
18 | 18 | ||
19 | import java.util.List; | 19 | import java.util.List; |
20 | 20 | ||
21 | +import org.onosproject.yangutils.datamodel.YangAtomicPath; | ||
21 | import org.onosproject.yangutils.datamodel.YangAugment; | 22 | import org.onosproject.yangutils.datamodel.YangAugment; |
22 | import org.onosproject.yangutils.datamodel.YangModule; | 23 | import org.onosproject.yangutils.datamodel.YangModule; |
23 | import org.onosproject.yangutils.datamodel.YangNode; | 24 | import org.onosproject.yangutils.datamodel.YangNode; |
24 | -import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
25 | import org.onosproject.yangutils.datamodel.YangSubModule; | 25 | import org.onosproject.yangutils.datamodel.YangSubModule; |
26 | import org.onosproject.yangutils.datamodel.YangUses; | 26 | import org.onosproject.yangutils.datamodel.YangUses; |
27 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 27 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
28 | import org.onosproject.yangutils.datamodel.utils.Parsable; | 28 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
29 | +import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl; | ||
29 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 30 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
30 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 31 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
31 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 32 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
32 | 33 | ||
34 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo; | ||
33 | import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION; | 35 | import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION; |
34 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.AUGMENT_DATA; | 36 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.AUGMENT_DATA; |
35 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CASE_DATA; | 37 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CASE_DATA; |
... | @@ -38,22 +40,17 @@ import static org.onosproject.yangutils.datamodel.utils.YangConstructType.DESCRI | ... | @@ -38,22 +40,17 @@ import static org.onosproject.yangutils.datamodel.utils.YangConstructType.DESCRI |
38 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.REFERENCE_DATA; | 40 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.REFERENCE_DATA; |
39 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.STATUS_DATA; | 41 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.STATUS_DATA; |
40 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.WHEN_DATA; | 42 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.WHEN_DATA; |
41 | -import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerUtil.generateNameForAugmentNode; | ||
42 | -import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerUtil.getParentsPrefix; | ||
43 | -import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerUtil.parserException; | ||
44 | -import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerUtil.validateNodeInTargetPath; | ||
45 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; | 43 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; |
46 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 44 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
47 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 45 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
48 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction | 46 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; |
49 | - .constructExtendedListenerErrorMessage; | 47 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
50 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction | ||
51 | - .constructListenerErrorMessage; | ||
52 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 48 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
53 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 49 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
54 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 50 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
55 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; | 51 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; |
56 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidAbsoluteSchemaNodeId; | 52 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidAbsoluteSchemaNodeId; |
53 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat; | ||
57 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 54 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
58 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; | 55 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; |
59 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds; | 56 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds; |
... | @@ -106,7 +103,7 @@ public final class AugmentListener { | ... | @@ -106,7 +103,7 @@ public final class AugmentListener { |
106 | checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA, ctx.augment().getText(), ENTRY); | 103 | checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA, ctx.augment().getText(), ENTRY); |
107 | 104 | ||
108 | // Validate augment argument string | 105 | // Validate augment argument string |
109 | - List<YangNodeIdentifier> targetNodes = getValidAbsoluteSchemaNodeId(ctx.augment().getText(), | 106 | + List<YangAtomicPath> targetNodes = getValidAbsoluteSchemaNodeId(ctx.augment().getText(), |
110 | AUGMENT_DATA, ctx); | 107 | AUGMENT_DATA, ctx); |
111 | 108 | ||
112 | // Validate sub statement cardinality. | 109 | // Validate sub statement cardinality. |
... | @@ -126,7 +123,7 @@ public final class AugmentListener { | ... | @@ -126,7 +123,7 @@ public final class AugmentListener { |
126 | // TODO: handle in linker. | 123 | // TODO: handle in linker. |
127 | 124 | ||
128 | yangAugment.setTargetNode(targetNodes); | 125 | yangAugment.setTargetNode(targetNodes); |
129 | - yangAugment.setName(generateNameForAugmentNode(curData, targetNodes, listener)); | 126 | + yangAugment.setName(removeQuotesAndHandleConcat(ctx.augment().getText())); |
130 | 127 | ||
131 | try { | 128 | try { |
132 | curNode.addChild(yangAugment); | 129 | curNode.addChild(yangAugment); |
... | @@ -135,6 +132,13 @@ public final class AugmentListener { | ... | @@ -135,6 +132,13 @@ public final class AugmentListener { |
135 | AUGMENT_DATA, ctx.augment().getText(), ENTRY, e.getMessage())); | 132 | AUGMENT_DATA, ctx.augment().getText(), ENTRY, e.getMessage())); |
136 | } | 133 | } |
137 | listener.getParsedDataStack().push(yangAugment); | 134 | listener.getParsedDataStack().push(yangAugment); |
135 | + | ||
136 | + // Add resolution information to the list | ||
137 | + YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangAugment>(yangAugment, | ||
138 | + curNode, line, | ||
139 | + charPositionInLine); | ||
140 | + addToResolutionList(resolutionInfo, ctx); | ||
141 | + | ||
138 | } else { | 142 | } else { |
139 | throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, AUGMENT_DATA, | 143 | throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, AUGMENT_DATA, |
140 | ctx.augment().getText(), ENTRY)); | 144 | ctx.augment().getText(), ENTRY)); |
... | @@ -177,35 +181,19 @@ public final class AugmentListener { | ... | @@ -177,35 +181,19 @@ public final class AugmentListener { |
177 | } | 181 | } |
178 | 182 | ||
179 | /** | 183 | /** |
180 | - * Validates whether the current target node path is correct or not. | 184 | + * Add to resolution list. |
181 | * | 185 | * |
182 | - * @param targetNodes list of target nodes | 186 | + * @param resolutionInfo resolution information. |
183 | - * @param curNode current Node | 187 | + * @param ctx context object of the grammar rule |
184 | - * @param ctx augment context | ||
185 | - * @param curNode current YANG node | ||
186 | */ | 188 | */ |
187 | - private static void validateTargetNodePath(List<YangNodeIdentifier> targetNodes, YangNode curNode, | 189 | + private static void addToResolutionList(YangResolutionInfoImpl<YangAugment> resolutionInfo, |
188 | GeneratedYangParser.AugmentStatementContext ctx) { | 190 | GeneratedYangParser.AugmentStatementContext ctx) { |
189 | 191 | ||
190 | - YangNodeIdentifier moduleId = targetNodes.get(0); | 192 | + try { |
191 | - if (moduleId.getPrefix() == null) { | 193 | + addResolutionInfo(resolutionInfo); |
192 | - if (!moduleId.getName().equals(curNode.getName())) { | 194 | + } catch (DataModelException e) { |
193 | - throw parserException(ctx); | 195 | + throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, |
194 | - } else { | 196 | + AUGMENT_DATA, ctx.augment().getText(), EXIT, e.getMessage())); |
195 | - //validateNodeInTargetPath(curNode, targetNodes, ctx); | ||
196 | - // TODO: handle in linker. | ||
197 | - } | ||
198 | - } else { | ||
199 | - String parentPrefix = getParentsPrefix(curNode); | ||
200 | - if (parentPrefix != null) { | ||
201 | - if (!parentPrefix.equals(moduleId.getPrefix())) { | ||
202 | - // TODO: handle in linker. | ||
203 | - } else { | ||
204 | - validateNodeInTargetPath(curNode, targetNodes, ctx); | ||
205 | - } | ||
206 | - } else { | ||
207 | - // TODO: handle in linker. | ||
208 | - } | ||
209 | } | 197 | } |
210 | } | 198 | } |
211 | } | 199 | } | ... | ... |
... | @@ -709,10 +709,10 @@ public final class ListenerUtil { | ... | @@ -709,10 +709,10 @@ public final class ListenerUtil { |
709 | * @param ctx yang construct's context to get the line number and character position | 709 | * @param ctx yang construct's context to get the line number and character position |
710 | * @return target nodes list of absolute schema node id | 710 | * @return target nodes list of absolute schema node id |
711 | */ | 711 | */ |
712 | - public static List<YangNodeIdentifier> getValidAbsoluteSchemaNodeId(String argumentString, | 712 | + public static List<YangAtomicPath> getValidAbsoluteSchemaNodeId(String argumentString, |
713 | YangConstructType yangConstructType, ParserRuleContext ctx) { | 713 | YangConstructType yangConstructType, ParserRuleContext ctx) { |
714 | 714 | ||
715 | - List<YangNodeIdentifier> targetNodes = new LinkedList<>(); | 715 | + List<YangAtomicPath> targetNodes = new ArrayList<>(); |
716 | YangNodeIdentifier yangNodeIdentifier; | 716 | YangNodeIdentifier yangNodeIdentifier; |
717 | String tmpSchemaNodeId = removeQuotesAndHandleConcat(argumentString); | 717 | String tmpSchemaNodeId = removeQuotesAndHandleConcat(argumentString); |
718 | 718 | ||
... | @@ -728,7 +728,9 @@ public final class ListenerUtil { | ... | @@ -728,7 +728,9 @@ public final class ListenerUtil { |
728 | String[] tmpData = tmpSchemaNodeId.replaceFirst(CARET + SLASH, EMPTY_STRING).split(SLASH); | 728 | String[] tmpData = tmpSchemaNodeId.replaceFirst(CARET + SLASH, EMPTY_STRING).split(SLASH); |
729 | for (String nodeIdentifiers : tmpData) { | 729 | for (String nodeIdentifiers : tmpData) { |
730 | yangNodeIdentifier = getValidNodeIdentifier(nodeIdentifiers, yangConstructType, ctx); | 730 | yangNodeIdentifier = getValidNodeIdentifier(nodeIdentifiers, yangConstructType, ctx); |
731 | - targetNodes.add(yangNodeIdentifier); | 731 | + YangAtomicPath yangAbsPath = new YangAtomicPath(); |
732 | + yangAbsPath.setNodeIdentifier(yangNodeIdentifier); | ||
733 | + targetNodes.add(yangAbsPath); | ||
732 | } | 734 | } |
733 | return targetNodes; | 735 | return targetNodes; |
734 | } | 736 | } | ... | ... |
... | @@ -17,11 +17,9 @@ | ... | @@ -17,11 +17,9 @@ |
17 | package org.onosproject.yangutils.plugin.manager; | 17 | package org.onosproject.yangutils.plugin.manager; |
18 | 18 | ||
19 | import java.io.File; | 19 | import java.io.File; |
20 | -import java.io.FileInputStream; | ||
21 | import java.io.FileOutputStream; | 20 | import java.io.FileOutputStream; |
22 | import java.io.IOException; | 21 | import java.io.IOException; |
23 | import java.io.InputStream; | 22 | import java.io.InputStream; |
24 | -import java.io.ObjectInputStream; | ||
25 | import java.io.ObjectOutputStream; | 23 | import java.io.ObjectOutputStream; |
26 | import java.nio.file.Files; | 24 | import java.nio.file.Files; |
27 | import java.nio.file.StandardCopyOption; | 25 | import java.nio.file.StandardCopyOption; |
... | @@ -41,6 +39,7 @@ import org.onosproject.yangutils.datamodel.YangNode; | ... | @@ -41,6 +39,7 @@ import org.onosproject.yangutils.datamodel.YangNode; |
41 | import org.slf4j.Logger; | 39 | import org.slf4j.Logger; |
42 | import org.sonatype.plexus.build.incremental.BuildContext; | 40 | import org.sonatype.plexus.build.incremental.BuildContext; |
43 | 41 | ||
42 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.deSerializeDataModel; | ||
44 | import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; |
45 | import static org.onosproject.yangutils.utils.UtilConstants.JAR; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.JAR; |
46 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 45 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
... | @@ -155,32 +154,6 @@ public final class YangPluginUtils { | ... | @@ -155,32 +154,6 @@ public final class YangPluginUtils { |
155 | } | 154 | } |
156 | 155 | ||
157 | /** | 156 | /** |
158 | - * Returns de-serializes YANG data-model nodes. | ||
159 | - * | ||
160 | - * @param serailizedfileInfoSet YANG file info set | ||
161 | - * @return de-serializes YANG data-model nodes | ||
162 | - * @throws IOException when fails do IO operations | ||
163 | - */ | ||
164 | - public static List<YangNode> deSerializeDataModel(List<String> serailizedfileInfoSet) throws IOException { | ||
165 | - | ||
166 | - List<YangNode> nodes = new ArrayList<>(); | ||
167 | - for (String fileInfo : serailizedfileInfoSet) { | ||
168 | - YangNode node = null; | ||
169 | - try { | ||
170 | - FileInputStream fileInputStream = new FileInputStream(fileInfo); | ||
171 | - ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); | ||
172 | - node = (YangNode) objectInputStream.readObject(); | ||
173 | - nodes.add(node); | ||
174 | - objectInputStream.close(); | ||
175 | - fileInputStream.close(); | ||
176 | - } catch (IOException | ClassNotFoundException e) { | ||
177 | - throw new IOException(fileInfo + " not found."); | ||
178 | - } | ||
179 | - } | ||
180 | - return nodes; | ||
181 | - } | ||
182 | - | ||
183 | - /** | ||
184 | * Returns list of jar path. | 157 | * Returns list of jar path. |
185 | * | 158 | * |
186 | * @param project maven project | 159 | * @param project maven project |
... | @@ -188,7 +161,7 @@ public final class YangPluginUtils { | ... | @@ -188,7 +161,7 @@ public final class YangPluginUtils { |
188 | * @param remoteRepos remote repository | 161 | * @param remoteRepos remote repository |
189 | * @return list of jar paths | 162 | * @return list of jar paths |
190 | */ | 163 | */ |
191 | - private static List<String> resolveDependecyJarPath(MavenProject project, ArtifactRepository localRepository, | 164 | + private static List<String> resolveDependencyJarPath(MavenProject project, ArtifactRepository localRepository, |
192 | List<ArtifactRepository> remoteRepos) { | 165 | List<ArtifactRepository> remoteRepos) { |
193 | 166 | ||
194 | StringBuilder path = new StringBuilder(); | 167 | StringBuilder path = new StringBuilder(); |
... | @@ -232,7 +205,7 @@ public final class YangPluginUtils { | ... | @@ -232,7 +205,7 @@ public final class YangPluginUtils { |
232 | List<ArtifactRepository> remoteRepos, String directory) | 205 | List<ArtifactRepository> remoteRepos, String directory) |
233 | throws IOException { | 206 | throws IOException { |
234 | 207 | ||
235 | - List<String> dependeciesJarPaths = resolveDependecyJarPath(project, localRepository, remoteRepos); | 208 | + List<String> dependeciesJarPaths = resolveDependencyJarPath(project, localRepository, remoteRepos); |
236 | List<YangNode> resolvedDataModelNodes = new ArrayList<>(); | 209 | List<YangNode> resolvedDataModelNodes = new ArrayList<>(); |
237 | for (String dependecy : dependeciesJarPaths) { | 210 | for (String dependecy : dependeciesJarPaths) { |
238 | resolvedDataModelNodes.addAll(deSerializeDataModel(parseJarFile(dependecy, directory))); | 211 | resolvedDataModelNodes.addAll(deSerializeDataModel(parseJarFile(dependecy, directory))); | ... | ... |
... | @@ -87,8 +87,14 @@ public class YangUtilManager | ... | @@ -87,8 +87,14 @@ public class YangUtilManager |
87 | /** | 87 | /** |
88 | * Source directory for generated files. | 88 | * Source directory for generated files. |
89 | */ | 89 | */ |
90 | - @Parameter(property = "genFilesDir", defaultValue = "src/main/java") | 90 | + @Parameter(property = "classFileDir", defaultValue = "target/generated-sources") |
91 | - private String genFilesDir; | 91 | + private String classFileDir; |
92 | + | ||
93 | + /** | ||
94 | + * Source directory for manager's generated files. | ||
95 | + */ | ||
96 | + @Parameter(property = "managerFileDir", defaultValue = "src/main/java") | ||
97 | + private String managerFileDir; | ||
92 | 98 | ||
93 | /** | 99 | /** |
94 | * Base directory for project. | 100 | * Base directory for project. |
... | @@ -153,11 +159,12 @@ public class YangUtilManager | ... | @@ -153,11 +159,12 @@ public class YangUtilManager |
153 | /* | 159 | /* |
154 | * For deleting the generated code in previous build. | 160 | * For deleting the generated code in previous build. |
155 | */ | 161 | */ |
156 | - deleteDirectory(getDirectory(baseDir, genFilesDir) + DEFAULT_PKG); | 162 | + deleteDirectory(getDirectory(baseDir, classFileDir) + DEFAULT_PKG); |
157 | deleteDirectory(getDirectory(baseDir, outputDirectory)); | 163 | deleteDirectory(getDirectory(baseDir, outputDirectory)); |
158 | 164 | ||
159 | String searchDir = getDirectory(baseDir, yangFilesDir); | 165 | String searchDir = getDirectory(baseDir, yangFilesDir); |
160 | - String codeGenDir = getDirectory(baseDir, genFilesDir) + SLASH; | 166 | + String codeGenDir = getDirectory(baseDir, classFileDir) + SLASH; |
167 | + String managerCodeGenDir = getDirectory(baseDir, managerFileDir) + SLASH; | ||
161 | 168 | ||
162 | // Creates conflict resolver and set values to it. | 169 | // Creates conflict resolver and set values to it. |
163 | YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil(); | 170 | YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil(); |
... | @@ -167,6 +174,7 @@ public class YangUtilManager | ... | @@ -167,6 +174,7 @@ public class YangUtilManager |
167 | conflictResolver.setPrefixForIdentifier(prefixForIdentifier); | 174 | conflictResolver.setPrefixForIdentifier(prefixForIdentifier); |
168 | YangPluginConfig yangPlugin = new YangPluginConfig(); | 175 | YangPluginConfig yangPlugin = new YangPluginConfig(); |
169 | yangPlugin.setCodeGenDir(codeGenDir); | 176 | yangPlugin.setCodeGenDir(codeGenDir); |
177 | + yangPlugin.setManagerCodeGenDir(managerCodeGenDir); | ||
170 | yangPlugin.setConflictResolver(conflictResolver); | 178 | yangPlugin.setConflictResolver(conflictResolver); |
171 | 179 | ||
172 | /* | 180 | /* |
... | @@ -195,18 +203,18 @@ public class YangUtilManager | ... | @@ -195,18 +203,18 @@ public class YangUtilManager |
195 | // Serialize data model. | 203 | // Serialize data model. |
196 | serializeDataModel(getDirectory(baseDir, outputDirectory), getYangFileInfoSet(), project, true); | 204 | serializeDataModel(getDirectory(baseDir, outputDirectory), getYangFileInfoSet(), project, true); |
197 | 205 | ||
198 | - addToCompilationRoot(getDirectory(baseDir, genFilesDir), project, context); | 206 | + addToCompilationRoot(codeGenDir, project, context); |
207 | + addToCompilationRoot(managerCodeGenDir, project, context); | ||
199 | 208 | ||
200 | copyYangFilesToTarget(getYangFileInfoSet(), getDirectory(baseDir, outputDirectory), project); | 209 | copyYangFilesToTarget(getYangFileInfoSet(), getDirectory(baseDir, outputDirectory), project); |
201 | } catch (IOException | ParserException e) { | 210 | } catch (IOException | ParserException e) { |
202 | - getLog().info(e); | ||
203 | String fileName = ""; | 211 | String fileName = ""; |
204 | if (getCurYangFileInfo() != null) { | 212 | if (getCurYangFileInfo() != null) { |
205 | fileName = getCurYangFileInfo().getYangFileName(); | 213 | fileName = getCurYangFileInfo().getYangFileName(); |
206 | } | 214 | } |
207 | try { | 215 | try { |
208 | translatorErrorHandler(getRootNode()); | 216 | translatorErrorHandler(getRootNode()); |
209 | - deleteDirectory(getDirectory(baseDir, genFilesDir) + DEFAULT_PKG); | 217 | + deleteDirectory(getDirectory(baseDir, classFileDir) + DEFAULT_PKG); |
210 | } catch (IOException ex) { | 218 | } catch (IOException ex) { |
211 | throw new MojoExecutionException( | 219 | throw new MojoExecutionException( |
212 | "Error handler failed to delete files for data model node."); | 220 | "Error handler failed to delete files for data model node."); |
... | @@ -255,14 +263,12 @@ public class YangUtilManager | ... | @@ -255,14 +263,12 @@ public class YangUtilManager |
255 | public void resolveDependenciesUsingLinker() | 263 | public void resolveDependenciesUsingLinker() |
256 | throws MojoExecutionException { | 264 | throws MojoExecutionException { |
257 | createYangNodeSet(); | 265 | createYangNodeSet(); |
258 | - for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { | ||
259 | - setCurYangFileInfo(yangFileInfo); | ||
260 | try { | 266 | try { |
261 | yangLinker.resolveDependencies(getYangNodeSet()); | 267 | yangLinker.resolveDependencies(getYangNodeSet()); |
262 | } catch (LinkerException e) { | 268 | } catch (LinkerException e) { |
263 | throw new MojoExecutionException(e.getMessage()); | 269 | throw new MojoExecutionException(e.getMessage()); |
264 | } | 270 | } |
265 | - } | 271 | + |
266 | } | 272 | } |
267 | 273 | ||
268 | /** | 274 | /** | ... | ... |
... | @@ -122,6 +122,11 @@ public final class GeneratedTempFileType { | ... | @@ -122,6 +122,11 @@ public final class GeneratedTempFileType { |
122 | public static final int EVENT_SUBJECT_SETTER_MASK = 524288; | 122 | public static final int EVENT_SUBJECT_SETTER_MASK = 524288; |
123 | 123 | ||
124 | /** | 124 | /** |
125 | + * Event subject setter implementation of class. | ||
126 | + */ | ||
127 | + public static final int AUGMENTE_CLASS_CONSTRUCTOR_MASK = 1048576; | ||
128 | + | ||
129 | + /** | ||
125 | * Creates an instance of generated temp file type. | 130 | * Creates an instance of generated temp file type. |
126 | */ | 131 | */ |
127 | private GeneratedTempFileType() { | 132 | private GeneratedTempFileType() { | ... | ... |
utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
... | @@ -21,10 +21,6 @@ import java.util.SortedSet; | ... | @@ -21,10 +21,6 @@ import java.util.SortedSet; |
21 | import java.util.TreeSet; | 21 | import java.util.TreeSet; |
22 | 22 | ||
23 | import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT_EVENT; | 23 | import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT_EVENT; |
24 | -import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST; | ||
25 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION_HOLDER_CLASS_IMPORT_CLASS; | ||
26 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO_CLASS_IMPORT_CLASS; | ||
27 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO_CLASS_IMPORT_PKG; | ||
28 | import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS; | 24 | import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS; |
29 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 25 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
30 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER; | 26 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER; |
... | @@ -40,9 +36,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; | ... | @@ -40,9 +36,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; |
40 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 36 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
41 | import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG; |
42 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
43 | -import static org.onosproject.yangutils.utils.UtilConstants.PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG; | ||
44 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
45 | - | ||
46 | import static java.util.Collections.sort; | 40 | import static java.util.Collections.sort; |
47 | 41 | ||
48 | /** | 42 | /** |
... | @@ -220,33 +214,6 @@ public class JavaImportData { | ... | @@ -220,33 +214,6 @@ public class JavaImportData { |
220 | } | 214 | } |
221 | 215 | ||
222 | /** | 216 | /** |
223 | - * Returns import for array list attribute. | ||
224 | - * | ||
225 | - * @return import for array list attribute | ||
226 | - */ | ||
227 | - public String getImportForArrayList() { | ||
228 | - return IMPORT + COLLECTION_IMPORTS + PERIOD + ARRAY_LIST + SEMI_COLAN + NEW_LINE; | ||
229 | - } | ||
230 | - | ||
231 | - /** | ||
232 | - * Returns import string for AugmentationHolder class. | ||
233 | - * | ||
234 | - * @return import string for AugmentationHolder class | ||
235 | - */ | ||
236 | - public String getAugmentationHolderImport() { | ||
237 | - return IMPORT + PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG + PERIOD + AUGMENTATION_HOLDER_CLASS_IMPORT_CLASS; | ||
238 | - } | ||
239 | - | ||
240 | - /** | ||
241 | - * Returns import string for AugmentedInfo class. | ||
242 | - * | ||
243 | - * @return import string for AugmentedInfo class | ||
244 | - */ | ||
245 | - public String getAugmentedInfoImport() { | ||
246 | - return IMPORT + AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + AUGMENTED_INFO_CLASS_IMPORT_CLASS; | ||
247 | - } | ||
248 | - | ||
249 | - /** | ||
250 | * Returns import string for ListenerService class. | 217 | * Returns import string for ListenerService class. |
251 | * | 218 | * |
252 | * @return import string for ListenerService class | 219 | * @return import string for ListenerService class | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
23 | 23 | ||
24 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; | 24 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; |
25 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor; | 25 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor; |
26 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | 26 | +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * Represents implementation of java bean code fragments temporary implementations. | 29 | * Represents implementation of java bean code fragments temporary implementations. |
... | @@ -88,7 +88,7 @@ public class TempJavaBeanFragmentFiles | ... | @@ -88,7 +88,7 @@ public class TempJavaBeanFragmentFiles |
88 | */ | 88 | */ |
89 | private void addConstructor(JavaAttributeInfo attr, YangPluginConfig pluginConfig) | 89 | private void addConstructor(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
90 | throws IOException { | 90 | throws IOException { |
91 | - appendToFile(getConstructorImplTempFileHandle(), getConstructor(getGeneratedJavaClassName(), attr, | 91 | + appendToFile(getConstructorImplTempFileHandle(), getConstructor(attr, |
92 | getGeneratedJavaFiles(), pluginConfig)); | 92 | getGeneratedJavaFiles(), pluginConfig)); |
93 | } | 93 | } |
94 | 94 | ... | ... |
... | @@ -36,7 +36,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetG | ... | @@ -36,7 +36,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetG |
36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile; | 36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile; |
37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; | 37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; |
38 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPrefixForIdentifier; | 38 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPrefixForIdentifier; |
39 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | 39 | +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
40 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
41 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT; |
42 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; | ... | ... |
... | @@ -29,6 +29,7 @@ import org.onosproject.yangutils.datamodel.YangList; | ... | @@ -29,6 +29,7 @@ import org.onosproject.yangutils.datamodel.YangList; |
29 | import org.onosproject.yangutils.datamodel.YangNode; | 29 | import org.onosproject.yangutils.datamodel.YangNode; |
30 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 30 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
31 | import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; | 31 | import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; |
32 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; | ||
32 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; | 33 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; |
33 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | 34 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
34 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | 35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
... | @@ -44,6 +45,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -44,6 +45,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; | 45 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; |
45 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; | 46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
46 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; | 47 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; |
48 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.AUGMENTE_CLASS_CONSTRUCTOR_MASK; | ||
47 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; | 49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; |
48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; | 50 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; |
49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; | 51 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; |
... | @@ -63,10 +65,8 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato | ... | @@ -63,10 +65,8 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato |
63 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; | 65 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; |
64 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; | 66 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; |
65 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; | 67 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
66 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | 68 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
67 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 69 | +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedConstructor; |
68 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; | ||
69 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | ||
70 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; | 70 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; |
71 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; | 71 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; |
72 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod; | 72 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod; |
... | @@ -80,17 +80,13 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator | ... | @@ -80,17 +80,13 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator |
80 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString; | 80 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString; |
81 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod; | 81 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod; |
82 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString; | 82 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString; |
83 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addArrayListImport; | 83 | +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
84 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addAugmentationHoldersImport; | 84 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports; |
85 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addAugmentedInfoImport; | ||
86 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | ||
87 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.isAugmentationHolderExtended; | ||
88 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.isAugmentedInfoExtended; | ||
89 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.sortImports; | ||
90 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; | 85 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; |
91 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | 86 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
92 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT; | 87 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT; |
93 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; | 88 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; |
89 | +import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | ||
94 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 90 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
95 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 91 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
96 | import static org.onosproject.yangutils.utils.UtilConstants.IMPL; | 92 | import static org.onosproject.yangutils.utils.UtilConstants.IMPL; |
... | @@ -104,12 +100,14 @@ import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALIT | ... | @@ -104,12 +100,14 @@ import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALIT |
104 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 100 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
105 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; | 101 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
106 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 102 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
107 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; | ||
108 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; | 103 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; |
109 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
110 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; | 104 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
111 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; | 105 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; |
106 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
112 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; | 107 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; |
108 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
109 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
110 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; | ||
113 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; | 111 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
114 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles; | 112 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles; |
115 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength; | 113 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength; |
... | @@ -227,6 +225,10 @@ public class TempJavaFragmentFiles { | ... | @@ -227,6 +225,10 @@ public class TempJavaFragmentFiles { |
227 | private static final String IMPL_CLASS_FILE_NAME_SUFFIX = IMPL; | 225 | private static final String IMPL_CLASS_FILE_NAME_SUFFIX = IMPL; |
228 | 226 | ||
229 | /** | 227 | /** |
228 | + * File name for augment copy constructor method. | ||
229 | + */ | ||
230 | + private static final String AUGMENT_CONSTRUCTOR_FILE_NAME = "AugmentConstructor"; | ||
231 | + /** | ||
230 | * Java file handle for interface file. | 232 | * Java file handle for interface file. |
231 | */ | 233 | */ |
232 | private File interfaceJavaFileHandle; | 234 | private File interfaceJavaFileHandle; |
... | @@ -302,6 +304,11 @@ public class TempJavaFragmentFiles { | ... | @@ -302,6 +304,11 @@ public class TempJavaFragmentFiles { |
302 | private boolean isAttributePresent; | 304 | private boolean isAttributePresent; |
303 | 305 | ||
304 | /** | 306 | /** |
307 | + * Temporary file handle for augments copy constructor method of class. | ||
308 | + */ | ||
309 | + private File augmentConstructorImplTempFileHandle; | ||
310 | + | ||
311 | + /** | ||
305 | * Retrieves the absolute path where the file needs to be generated. | 312 | * Retrieves the absolute path where the file needs to be generated. |
306 | * | 313 | * |
307 | * @return absolute path where the file needs to be generated | 314 | * @return absolute path where the file needs to be generated |
... | @@ -539,6 +546,7 @@ public class TempJavaFragmentFiles { | ... | @@ -539,6 +546,7 @@ public class TempJavaFragmentFiles { |
539 | addGeneratedTempFile(ATTRIBUTES_MASK); | 546 | addGeneratedTempFile(ATTRIBUTES_MASK); |
540 | addGeneratedTempFile(GETTER_FOR_CLASS_MASK); | 547 | addGeneratedTempFile(GETTER_FOR_CLASS_MASK); |
541 | addGeneratedTempFile(SETTER_FOR_CLASS_MASK); | 548 | addGeneratedTempFile(SETTER_FOR_CLASS_MASK); |
549 | + addGeneratedTempFile(AUGMENTE_CLASS_CONSTRUCTOR_MASK); | ||
542 | } | 550 | } |
543 | 551 | ||
544 | /* | 552 | /* |
... | @@ -617,6 +625,9 @@ public class TempJavaFragmentFiles { | ... | @@ -617,6 +625,9 @@ public class TempJavaFragmentFiles { |
617 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { | 625 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
618 | setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME)); | 626 | setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME)); |
619 | } | 627 | } |
628 | + if ((getGeneratedTempFiles() & AUGMENTE_CLASS_CONSTRUCTOR_MASK) != 0) { | ||
629 | + setAugmentConstructorImplTempFileHandle(getTemporaryFileHandle(AUGMENT_CONSTRUCTOR_FILE_NAME)); | ||
630 | + } | ||
620 | 631 | ||
621 | } | 632 | } |
622 | 633 | ||
... | @@ -801,6 +812,24 @@ public class TempJavaFragmentFiles { | ... | @@ -801,6 +812,24 @@ public class TempJavaFragmentFiles { |
801 | } | 812 | } |
802 | 813 | ||
803 | /** | 814 | /** |
815 | + * Returns augments copy constructor method impl class file. | ||
816 | + * | ||
817 | + * @return augments copy constructor method impl class file | ||
818 | + */ | ||
819 | + public File getAugmentConstructorImplTempFileHandle() { | ||
820 | + return augmentConstructorImplTempFileHandle; | ||
821 | + } | ||
822 | + | ||
823 | + /** | ||
824 | + * Sets augments copy constructor method impl class. | ||
825 | + * | ||
826 | + * @param augmentConstructorImplTempFileHandle augments copy constructor method impl class file | ||
827 | + */ | ||
828 | + public void setAugmentConstructorImplTempFileHandle(File augmentConstructorImplTempFileHandle) { | ||
829 | + this.augmentConstructorImplTempFileHandle = augmentConstructorImplTempFileHandle; | ||
830 | + } | ||
831 | + | ||
832 | + /** | ||
804 | * Adds attribute for class. | 833 | * Adds attribute for class. |
805 | * | 834 | * |
806 | * @param attr attribute info | 835 | * @param attr attribute info |
... | @@ -973,6 +1002,17 @@ public class TempJavaFragmentFiles { | ... | @@ -973,6 +1002,17 @@ public class TempJavaFragmentFiles { |
973 | } | 1002 | } |
974 | 1003 | ||
975 | /** | 1004 | /** |
1005 | + * Adds constructor for augment class. | ||
1006 | + * | ||
1007 | + * @param attr attribute info | ||
1008 | + * @throws IOException when fails to append to temporary file | ||
1009 | + */ | ||
1010 | + private void addAugmentConstructor(JavaAttributeInfo attr, YangPluginConfig pluginConfig) | ||
1011 | + throws IOException { | ||
1012 | + appendToFile(getAugmentConstructorImplTempFileHandle(), getAugmentedConstructor(attr, pluginConfig)); | ||
1013 | + } | ||
1014 | + | ||
1015 | + /** | ||
976 | * Returns a temporary file handle for the specific file type. | 1016 | * Returns a temporary file handle for the specific file type. |
977 | * | 1017 | * |
978 | * @param fileName file name | 1018 | * @param fileName file name |
... | @@ -981,7 +1021,7 @@ public class TempJavaFragmentFiles { | ... | @@ -981,7 +1021,7 @@ public class TempJavaFragmentFiles { |
981 | */ | 1021 | */ |
982 | File getTemporaryFileHandle(String fileName) | 1022 | File getTemporaryFileHandle(String fileName) |
983 | throws IOException { | 1023 | throws IOException { |
984 | - String path = getTempDirPath(); | 1024 | + String path = getTempDirPath(getAbsoluteDirPath()); |
985 | File dir = new File(path); | 1025 | File dir = new File(path); |
986 | if (!dir.exists()) { | 1026 | if (!dir.exists()) { |
987 | dir.mkdirs(); | 1027 | dir.mkdirs(); |
... | @@ -1011,13 +1051,14 @@ public class TempJavaFragmentFiles { | ... | @@ -1011,13 +1051,14 @@ public class TempJavaFragmentFiles { |
1011 | * Returns data from the temporary files. | 1051 | * Returns data from the temporary files. |
1012 | * | 1052 | * |
1013 | * @param file temporary file handle | 1053 | * @param file temporary file handle |
1054 | + * @param absolutePath absolute path | ||
1014 | * @return stored data from temporary files | 1055 | * @return stored data from temporary files |
1015 | * @throws IOException when failed to get data from the given file | 1056 | * @throws IOException when failed to get data from the given file |
1016 | */ | 1057 | */ |
1017 | - public String getTemporaryDataFromFileHandle(File file) | 1058 | + public String getTemporaryDataFromFileHandle(File file, String absolutePath) |
1018 | throws IOException { | 1059 | throws IOException { |
1019 | 1060 | ||
1020 | - String path = getTempDirPath(); | 1061 | + String path = getTempDirPath(absolutePath); |
1021 | if (new File(path + file.getName()).exists()) { | 1062 | if (new File(path + file.getName()).exists()) { |
1022 | return readAppendFile(path + file.getName(), EMPTY_STRING); | 1063 | return readAppendFile(path + file.getName(), EMPTY_STRING); |
1023 | } else { | 1064 | } else { |
... | @@ -1029,10 +1070,11 @@ public class TempJavaFragmentFiles { | ... | @@ -1029,10 +1070,11 @@ public class TempJavaFragmentFiles { |
1029 | /** | 1070 | /** |
1030 | * Returns temporary directory path. | 1071 | * Returns temporary directory path. |
1031 | * | 1072 | * |
1073 | + * @param absolutePath absolute path | ||
1032 | * @return directory path | 1074 | * @return directory path |
1033 | */ | 1075 | */ |
1034 | - String getTempDirPath() { | 1076 | + String getTempDirPath(String absolutePath) { |
1035 | - return getPackageDirPathFromJavaJPackage(getAbsoluteDirPath()) + SLASH + getGeneratedJavaClassName() | 1077 | + return getPackageDirPathFromJavaJPackage(absolutePath) + SLASH + getGeneratedJavaClassName() |
1036 | + TEMP_FOLDER_NAME_SUFIX + SLASH; | 1078 | + TEMP_FOLDER_NAME_SUFIX + SLASH; |
1037 | } | 1079 | } |
1038 | 1080 | ||
... | @@ -1208,63 +1250,6 @@ public class TempJavaFragmentFiles { | ... | @@ -1208,63 +1250,6 @@ public class TempJavaFragmentFiles { |
1208 | } | 1250 | } |
1209 | 1251 | ||
1210 | /** | 1252 | /** |
1211 | - * Resolves groupings java qualified info. | ||
1212 | - * | ||
1213 | - * @param curNode grouping node | ||
1214 | - * @param pluginConfig plugin configurations | ||
1215 | - * @return groupings java qualified info | ||
1216 | - */ | ||
1217 | - public static JavaQualifiedTypeInfo resolveGroupingsQuailifiedInfo(YangNode curNode, | ||
1218 | - YangPluginConfig pluginConfig) { | ||
1219 | - | ||
1220 | - JavaFileInfo groupingFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | ||
1221 | - JavaQualifiedTypeInfo qualifiedTypeInfo = new JavaQualifiedTypeInfo(); | ||
1222 | - if (groupingFileInfo.getPackage() == null) { | ||
1223 | - List<String> parentNames = new ArrayList<>(); | ||
1224 | - | ||
1225 | - YangNode tempNode = curNode.getParent(); | ||
1226 | - YangNode groupingSuperParent = null; | ||
1227 | - while (tempNode != null) { | ||
1228 | - parentNames.add(tempNode.getName()); | ||
1229 | - groupingSuperParent = tempNode; | ||
1230 | - tempNode = tempNode.getParent(); | ||
1231 | - } | ||
1232 | - | ||
1233 | - String pkg = null; | ||
1234 | - JavaFileInfo parentInfo = ((JavaFileInfoContainer) groupingSuperParent).getJavaFileInfo(); | ||
1235 | - if (parentInfo.getPackage() == null) { | ||
1236 | - if (groupingSuperParent instanceof YangJavaModule) { | ||
1237 | - YangJavaModule module = (YangJavaModule) groupingSuperParent; | ||
1238 | - String modulePkg = getRootPackage(module.getVersion(), module.getNameSpace().getUri(), module | ||
1239 | - .getRevision().getRevDate(), pluginConfig.getConflictResolver()); | ||
1240 | - pkg = modulePkg; | ||
1241 | - } else if (groupingSuperParent instanceof YangJavaSubModule) { | ||
1242 | - YangJavaSubModule submodule = (YangJavaSubModule) groupingSuperParent; | ||
1243 | - String subModulePkg = getRootPackage(submodule.getVersion(), | ||
1244 | - submodule.getNameSpaceFromModule(submodule.getBelongsTo()), | ||
1245 | - submodule.getRevision().getRevDate(), pluginConfig.getConflictResolver()); | ||
1246 | - pkg = subModulePkg; | ||
1247 | - } | ||
1248 | - } else { | ||
1249 | - pkg = parentInfo.getPackage(); | ||
1250 | - } | ||
1251 | - for (String name : parentNames) { | ||
1252 | - pkg = pkg + PERIOD + getCamelCase(name, pluginConfig.getConflictResolver()); | ||
1253 | - } | ||
1254 | - | ||
1255 | - qualifiedTypeInfo.setPkgInfo(pkg.toLowerCase()); | ||
1256 | - qualifiedTypeInfo.setClassInfo( | ||
1257 | - getCapitalCase(getCamelCase(curNode.getName(), pluginConfig.getConflictResolver()))); | ||
1258 | - return qualifiedTypeInfo; | ||
1259 | - | ||
1260 | - } else { | ||
1261 | - qualifiedTypeInfo.setPkgInfo(groupingFileInfo.getPackage().toLowerCase()); | ||
1262 | - qualifiedTypeInfo.setClassInfo(getCapitalCase(groupingFileInfo.getJavaName())); | ||
1263 | - return qualifiedTypeInfo; | ||
1264 | - } | ||
1265 | - } | ||
1266 | - | ||
1267 | - /** | ||
1268 | * Returns interface fragment files for node. | 1253 | * Returns interface fragment files for node. |
1269 | * | 1254 | * |
1270 | * @param node YANG node | 1255 | * @param node YANG node |
... | @@ -1326,18 +1311,30 @@ public class TempJavaFragmentFiles { | ... | @@ -1326,18 +1311,30 @@ public class TempJavaFragmentFiles { |
1326 | if (!(leaf instanceof JavaLeafInfoContainer)) { | 1311 | if (!(leaf instanceof JavaLeafInfoContainer)) { |
1327 | throw new TranslatorException("Leaf does not have java information"); | 1312 | throw new TranslatorException("Leaf does not have java information"); |
1328 | } | 1313 | } |
1314 | + addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(leaf, yangPluginConfig), | ||
1315 | + yangPluginConfig); | ||
1316 | + } | ||
1317 | + } | ||
1318 | + } | ||
1319 | + | ||
1320 | + /** | ||
1321 | + * Returns java attribute for leaf. | ||
1322 | + * | ||
1323 | + * @param leaf YANG leaf | ||
1324 | + * @param yangPluginConfig plugin configurations | ||
1325 | + * @return java attribute for leaf | ||
1326 | + */ | ||
1327 | + private JavaAttributeInfo getJavaAttributeOfLeaf(YangLeaf leaf, | ||
1328 | + YangPluginConfig yangPluginConfig) { | ||
1329 | JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf; | 1329 | JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf; |
1330 | javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver()); | 1330 | javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver()); |
1331 | javaLeaf.updateJavaQualifiedInfo(); | 1331 | javaLeaf.updateJavaQualifiedInfo(); |
1332 | - JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData( | 1332 | + return getAttributeInfoForTheData( |
1333 | javaLeaf.getJavaQualifiedInfo(), | 1333 | javaLeaf.getJavaQualifiedInfo(), |
1334 | javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()), | 1334 | javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()), |
1335 | javaLeaf.getDataType(), | 1335 | javaLeaf.getDataType(), |
1336 | getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()), | 1336 | getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()), |
1337 | false); | 1337 | false); |
1338 | - addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, yangPluginConfig); | ||
1339 | - } | ||
1340 | - } | ||
1341 | } | 1338 | } |
1342 | 1339 | ||
1343 | /** | 1340 | /** |
... | @@ -1354,19 +1351,30 @@ public class TempJavaFragmentFiles { | ... | @@ -1354,19 +1351,30 @@ public class TempJavaFragmentFiles { |
1354 | if (!(leafList instanceof JavaLeafInfoContainer)) { | 1351 | if (!(leafList instanceof JavaLeafInfoContainer)) { |
1355 | throw new TranslatorException("Leaf-list does not have java information"); | 1352 | throw new TranslatorException("Leaf-list does not have java information"); |
1356 | } | 1353 | } |
1354 | + addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(leafList, yangPluginConfig), | ||
1355 | + yangPluginConfig); | ||
1356 | + } | ||
1357 | + } | ||
1358 | + } | ||
1359 | + | ||
1360 | + /** | ||
1361 | + * Returns java attribute for leaf-list. | ||
1362 | + * | ||
1363 | + * @param leafList YANG leaf-list | ||
1364 | + * @param yangPluginConfig plugin configurations | ||
1365 | + * @return java attribute for leaf-list | ||
1366 | + */ | ||
1367 | + private JavaAttributeInfo getJavaAttributeOfLeafList(YangLeafList leafList, YangPluginConfig yangPluginConfig) { | ||
1357 | JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList; | 1368 | JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList; |
1358 | javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver()); | 1369 | javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver()); |
1359 | javaLeaf.updateJavaQualifiedInfo(); | 1370 | javaLeaf.updateJavaQualifiedInfo(); |
1360 | getJavaImportData().setIfListImported(true); | 1371 | getJavaImportData().setIfListImported(true); |
1361 | - JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData( | 1372 | + return getAttributeInfoForTheData( |
1362 | javaLeaf.getJavaQualifiedInfo(), | 1373 | javaLeaf.getJavaQualifiedInfo(), |
1363 | javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()), | 1374 | javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()), |
1364 | javaLeaf.getDataType(), | 1375 | javaLeaf.getDataType(), |
1365 | getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()), | 1376 | getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()), |
1366 | true); | 1377 | true); |
1367 | - addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, yangPluginConfig); | ||
1368 | - } | ||
1369 | - } | ||
1370 | } | 1378 | } |
1371 | 1379 | ||
1372 | /** | 1380 | /** |
... | @@ -1455,6 +1463,15 @@ public class TempJavaFragmentFiles { | ... | @@ -1455,6 +1463,15 @@ public class TempJavaFragmentFiles { |
1455 | } | 1463 | } |
1456 | 1464 | ||
1457 | /** | 1465 | /** |
1466 | + * Returns java class name. | ||
1467 | + * | ||
1468 | + * @return java class name | ||
1469 | + */ | ||
1470 | + String getImplClassName() { | ||
1471 | + return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName()); | ||
1472 | + } | ||
1473 | + | ||
1474 | + /** | ||
1458 | * Returns the directory path. | 1475 | * Returns the directory path. |
1459 | * | 1476 | * |
1460 | * @return directory path | 1477 | * @return directory path |
... | @@ -1475,6 +1492,8 @@ public class TempJavaFragmentFiles { | ... | @@ -1475,6 +1492,8 @@ public class TempJavaFragmentFiles { |
1475 | List<String> imports = new ArrayList<>(); | 1492 | List<String> imports = new ArrayList<>(); |
1476 | imports = getJavaImportData().getImports(); | 1493 | imports = getJavaImportData().getImports(); |
1477 | 1494 | ||
1495 | + JavaFileInfo curInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | ||
1496 | + | ||
1478 | createPackage(curNode); | 1497 | createPackage(curNode); |
1479 | 1498 | ||
1480 | /* | 1499 | /* |
... | @@ -1505,50 +1524,50 @@ public class TempJavaFragmentFiles { | ... | @@ -1505,50 +1524,50 @@ public class TempJavaFragmentFiles { |
1505 | validateLineLength(getInterfaceJavaFileHandle()); | 1524 | validateLineLength(getInterfaceJavaFileHandle()); |
1506 | } | 1525 | } |
1507 | insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose()); | 1526 | insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose()); |
1508 | - if (isAugmentationHolderExtended(getJavaExtendsListHolder().getExtendsList())) { | 1527 | + |
1509 | - addAugmentationHoldersImport(curNode, imports, false); | ||
1510 | - } | ||
1511 | - if (isAugmentedInfoExtended(getJavaExtendsListHolder().getExtendsList())) { | ||
1512 | - addAugmentedInfoImport(curNode, imports, false); | ||
1513 | - } | ||
1514 | if (curNode instanceof YangCase) { | 1528 | if (curNode instanceof YangCase) { |
1515 | removeCaseImport(imports); | 1529 | removeCaseImport(imports); |
1516 | } | 1530 | } |
1531 | + if (curNode instanceof YangJavaAugment) { | ||
1532 | + updateAugmentConstructorTempFile(curNode, curInfo.getPluginConfig()); | ||
1533 | + YangJavaAugment augment = (YangJavaAugment) curNode; | ||
1534 | + List<JavaQualifiedTypeInfo> infoList = augment.getExtendedClassInfo(); | ||
1535 | + for (JavaQualifiedTypeInfo info : infoList) { | ||
1536 | + if (info.getClassInfo() | ||
1537 | + .equals(getCapitalCase(getCamelCase(augment.getAugmentedNode().getName(), null)))) { | ||
1538 | + removeAugmentedImport(imports, info); | ||
1539 | + } | ||
1540 | + | ||
1541 | + } | ||
1542 | + } | ||
1517 | } | 1543 | } |
1518 | if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & IMPL_CLASS_MASK) != 0) { | 1544 | if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & IMPL_CLASS_MASK) != 0) { |
1519 | if (isAttributePresent()) { | 1545 | if (isAttributePresent()) { |
1520 | addImportsToStringAndHasCodeMethods(curNode, imports); | 1546 | addImportsToStringAndHasCodeMethods(curNode, imports); |
1521 | } | 1547 | } |
1522 | - if (isAugmentationHolderExtended(getJavaExtendsListHolder().getExtendsList())) { | ||
1523 | - addAugmentedInfoImport(curNode, imports, true); | ||
1524 | - addArrayListImport(curNode, imports, true); | ||
1525 | - } | ||
1526 | sortImports(imports); | 1548 | sortImports(imports); |
1527 | /* | 1549 | /* |
1550 | + * Create impl class file. | ||
1551 | + */ | ||
1552 | + setImplClassJavaFileHandle(getJavaFileHandle(getImplClassName())); | ||
1553 | + setImplClassJavaFileHandle( | ||
1554 | + generateImplClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent(), imports)); | ||
1555 | + | ||
1556 | + /* | ||
1528 | * Create builder class file. | 1557 | * Create builder class file. |
1529 | */ | 1558 | */ |
1559 | + if ((fileType & BUILDER_CLASS_MASK) != 0) { | ||
1530 | setBuilderClassJavaFileHandle(getJavaFileHandle(getJavaClassName(BUILDER_CLASS_FILE_NAME_SUFFIX))); | 1560 | setBuilderClassJavaFileHandle(getJavaFileHandle(getJavaClassName(BUILDER_CLASS_FILE_NAME_SUFFIX))); |
1531 | setBuilderClassJavaFileHandle( | 1561 | setBuilderClassJavaFileHandle( |
1532 | - generateBuilderClassFile(getBuilderClassJavaFileHandle(), imports, curNode, | 1562 | + generateBuilderClassFile(getBuilderClassJavaFileHandle(), curNode, |
1533 | isAttributePresent())); | 1563 | isAttributePresent())); |
1534 | /* | 1564 | /* |
1535 | - * Create impl class file. | ||
1536 | - */ | ||
1537 | - if ((fileType & IMPL_CLASS_MASK) != 0) { | ||
1538 | - setImplClassJavaFileHandle(getJavaFileHandle(getJavaClassName(IMPL_CLASS_FILE_NAME_SUFFIX))); | ||
1539 | - setImplClassJavaFileHandle( | ||
1540 | - generateImplClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent())); | ||
1541 | - /* | ||
1542 | * Append impl class to builder class and close it. | 1565 | * Append impl class to builder class and close it. |
1543 | */ | 1566 | */ |
1544 | - mergeJavaFiles(getImplClassJavaFileHandle(), getBuilderClassJavaFileHandle()); | 1567 | + mergeJavaFiles(getBuilderClassJavaFileHandle(), getImplClassJavaFileHandle()); |
1545 | - validateLineLength(getBuilderClassJavaFileHandle()); | 1568 | + validateLineLength(getImplClassJavaFileHandle()); |
1546 | - } | ||
1547 | - insertDataIntoJavaFile(getBuilderClassJavaFileHandle(), getJavaClassDefClose()); | ||
1548 | - if (isAugmentationHolderExtended(getJavaExtendsListHolder().getExtendsList())) { | ||
1549 | - addAugmentedInfoImport(curNode, imports, false); | ||
1550 | - addArrayListImport(curNode, imports, false); | ||
1551 | } | 1569 | } |
1570 | + insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose()); | ||
1552 | } | 1571 | } |
1553 | /* | 1572 | /* |
1554 | * Close all the file handles. | 1573 | * Close all the file handles. |
... | @@ -1557,6 +1576,47 @@ public class TempJavaFragmentFiles { | ... | @@ -1557,6 +1576,47 @@ public class TempJavaFragmentFiles { |
1557 | } | 1576 | } |
1558 | 1577 | ||
1559 | /** | 1578 | /** |
1579 | + * Updates augment constructor temp file. | ||
1580 | + * | ||
1581 | + * @param curNode current augment node | ||
1582 | + * @param pluginConfig plugin configurations | ||
1583 | + * @throws IOException when fails to do IO operations | ||
1584 | + */ | ||
1585 | + private void updateAugmentConstructorTempFile(YangNode curNode, YangPluginConfig pluginConfig) | ||
1586 | + throws IOException { | ||
1587 | + YangJavaAugment augment = (YangJavaAugment) curNode; | ||
1588 | + | ||
1589 | + YangNode augmentedNode = augment.getAugmentedNode(); | ||
1590 | + if (augmentedNode instanceof YangLeavesHolder) { | ||
1591 | + YangLeavesHolder holder = (YangLeavesHolder) augmentedNode; | ||
1592 | + if (holder.getListOfLeaf() != null) { | ||
1593 | + for (YangLeaf leaf : holder.getListOfLeaf()) { | ||
1594 | + addAugmentConstructor(getJavaAttributeOfLeaf(leaf, | ||
1595 | + pluginConfig), pluginConfig); | ||
1596 | + } | ||
1597 | + | ||
1598 | + } | ||
1599 | + if (holder.getListOfLeafList() != null) { | ||
1600 | + for (YangLeafList leafList : holder.getListOfLeafList()) { | ||
1601 | + addAugmentConstructor(getJavaAttributeOfLeafList(leafList, | ||
1602 | + pluginConfig), pluginConfig); | ||
1603 | + } | ||
1604 | + | ||
1605 | + } | ||
1606 | + } | ||
1607 | + augmentedNode = augmentedNode.getChild(); | ||
1608 | + boolean isList = false; | ||
1609 | + while (augmentedNode != null) { | ||
1610 | + if (augmentedNode instanceof YangList) { | ||
1611 | + isList = true; | ||
1612 | + } | ||
1613 | + addAugmentConstructor(getCurNodeAsAttributeInTarget(augmentedNode, augment, isList), pluginConfig); | ||
1614 | + augmentedNode = augmentedNode.getNextSibling(); | ||
1615 | + } | ||
1616 | + | ||
1617 | + } | ||
1618 | + | ||
1619 | + /** | ||
1560 | * Adds imports for ToString and HashCodeMethod. | 1620 | * Adds imports for ToString and HashCodeMethod. |
1561 | * | 1621 | * |
1562 | * @param curNode current YANG node | 1622 | * @param curNode current YANG node |
... | @@ -1570,6 +1630,27 @@ public class TempJavaFragmentFiles { | ... | @@ -1570,6 +1630,27 @@ public class TempJavaFragmentFiles { |
1570 | } | 1630 | } |
1571 | 1631 | ||
1572 | /** | 1632 | /** |
1633 | + * Removes augmented node import info from import list. | ||
1634 | + * | ||
1635 | + * @param imports list of imports | ||
1636 | + * @return import for class | ||
1637 | + */ | ||
1638 | + private List<String> removeAugmentedImport(List<String> imports, JavaQualifiedTypeInfo augmentedInfo) { | ||
1639 | + String augmentedNodeImport = null; | ||
1640 | + if (imports != null && augmentedInfo != null) { | ||
1641 | + augmentedNodeImport = IMPORT + augmentedInfo.getPkgInfo() + PERIOD + getCapitalCase(DEFAULT) | ||
1642 | + + augmentedInfo.getClassInfo() + PERIOD + augmentedInfo.getClassInfo() | ||
1643 | + + BUILDER + SEMI_COLAN + NEW_LINE; | ||
1644 | + imports.remove(augmentedNodeImport); | ||
1645 | + augmentedNodeImport = IMPORT + augmentedInfo.getPkgInfo() + PERIOD | ||
1646 | + + augmentedInfo.getClassInfo() + PERIOD + augmentedInfo.getClassInfo() | ||
1647 | + + BUILDER + SEMI_COLAN + NEW_LINE; | ||
1648 | + imports.remove(augmentedNodeImport); | ||
1649 | + } | ||
1650 | + return imports; | ||
1651 | + } | ||
1652 | + | ||
1653 | + /** | ||
1573 | * Removes case import info from import list. | 1654 | * Removes case import info from import list. |
1574 | * | 1655 | * |
1575 | * @param imports list of imports | 1656 | * @param imports list of imports |
... | @@ -1602,13 +1683,13 @@ public class TempJavaFragmentFiles { | ... | @@ -1602,13 +1683,13 @@ public class TempJavaFragmentFiles { |
1602 | closeFile(getInterfaceJavaFileHandle(), isError); | 1683 | closeFile(getInterfaceJavaFileHandle(), isError); |
1603 | } | 1684 | } |
1604 | if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { | 1685 | if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { |
1605 | - closeFile(getBuilderClassJavaFileHandle(), isError); | 1686 | + closeFile(getBuilderClassJavaFileHandle(), true); |
1606 | } | 1687 | } |
1607 | if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) { | 1688 | if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) { |
1608 | closeFile(getBuilderInterfaceJavaFileHandle(), true); | 1689 | closeFile(getBuilderInterfaceJavaFileHandle(), true); |
1609 | } | 1690 | } |
1610 | if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) { | 1691 | if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) { |
1611 | - closeFile(getImplClassJavaFileHandle(), true); | 1692 | + closeFile(getImplClassJavaFileHandle(), isError); |
1612 | } | 1693 | } |
1613 | 1694 | ||
1614 | /* | 1695 | /* |
... | @@ -1632,6 +1713,9 @@ public class TempJavaFragmentFiles { | ... | @@ -1632,6 +1713,9 @@ public class TempJavaFragmentFiles { |
1632 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { | 1713 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
1633 | closeFile(getFromStringImplTempFileHandle(), true); | 1714 | closeFile(getFromStringImplTempFileHandle(), true); |
1634 | } | 1715 | } |
1716 | + if ((getGeneratedTempFiles() & AUGMENTE_CLASS_CONSTRUCTOR_MASK) != 0) { | ||
1717 | + closeFile(getAugmentConstructorImplTempFileHandle(), true); | ||
1718 | + } | ||
1635 | } | 1719 | } |
1636 | 1720 | ||
1637 | /** | 1721 | /** | ... | ... |
... | @@ -27,7 +27,6 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | ... | @@ -27,7 +27,6 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
27 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | 27 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
28 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 28 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
29 | 29 | ||
30 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | ||
31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | 30 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; |
32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
33 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_ENUM_MASK; | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_ENUM_MASK; |
... | @@ -54,9 +53,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator | ... | @@ -54,9 +53,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator |
54 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; | 53 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; |
55 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; | 54 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; |
56 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; | 55 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; |
57 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addAnnotationsImports; | 56 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAnnotationsImports; |
58 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addListnersImport; | 57 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addListenersImport; |
59 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | 58 | +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
60 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | 59 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
61 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 60 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
62 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; | 61 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; |
... | @@ -390,7 +389,7 @@ public class TempJavaServiceFragmentFiles | ... | @@ -390,7 +389,7 @@ public class TempJavaServiceFragmentFiles |
390 | } | 389 | } |
391 | 390 | ||
392 | if (isNotification) { | 391 | if (isNotification) { |
393 | - addListnersImport(curNode, imports, true, LISTENER_SERVICE); | 392 | + addListenersImport(curNode, imports, true, LISTENER_SERVICE); |
394 | } | 393 | } |
395 | /** | 394 | /** |
396 | * Creates rpc interface file. | 395 | * Creates rpc interface file. |
... | @@ -399,8 +398,8 @@ public class TempJavaServiceFragmentFiles | ... | @@ -399,8 +398,8 @@ public class TempJavaServiceFragmentFiles |
399 | generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports, isAttributePresent()); | 398 | generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports, isAttributePresent()); |
400 | 399 | ||
401 | if (isNotification) { | 400 | if (isNotification) { |
402 | - addListnersImport(curNode, imports, false, LISTENER_SERVICE); | 401 | + addListenersImport(curNode, imports, false, LISTENER_SERVICE); |
403 | - addListnersImport(curNode, imports, true, LISTENER_REG); | 402 | + addListenersImport(curNode, imports, true, LISTENER_REG); |
404 | } | 403 | } |
405 | addAnnotationsImports(imports, true); | 404 | addAnnotationsImports(imports, true); |
406 | /** | 405 | /** |
... | @@ -411,14 +410,14 @@ public class TempJavaServiceFragmentFiles | ... | @@ -411,14 +410,14 @@ public class TempJavaServiceFragmentFiles |
411 | 410 | ||
412 | insertDataIntoJavaFile(getManagerJavaFileHandle(), getJavaClassDefClose()); | 411 | insertDataIntoJavaFile(getManagerJavaFileHandle(), getJavaClassDefClose()); |
413 | if (isNotification) { | 412 | if (isNotification) { |
414 | - addListnersImport(curNode, imports, false, LISTENER_REG); | 413 | + addListenersImport(curNode, imports, false, LISTENER_REG); |
415 | } | 414 | } |
416 | addAnnotationsImports(imports, false); | 415 | addAnnotationsImports(imports, false); |
417 | 416 | ||
418 | if (isNotification) { | 417 | if (isNotification) { |
419 | - generateEventJavaFile(GENERATE_EVENT_CLASS, curNode); | 418 | + generateEventJavaFile(curNode); |
420 | generateEventListenerJavaFile(GENERATE_EVENT_LISTENER_INTERFACE, curNode); | 419 | generateEventListenerJavaFile(GENERATE_EVENT_LISTENER_INTERFACE, curNode); |
421 | - generateEventSubjectJavaFile(GENERATE_EVENT_SUBJECT_CLASS, curNode); | 420 | + generateEventSubjectJavaFile(curNode); |
422 | } | 421 | } |
423 | 422 | ||
424 | /** | 423 | /** |
... | @@ -478,11 +477,10 @@ public class TempJavaServiceFragmentFiles | ... | @@ -478,11 +477,10 @@ public class TempJavaServiceFragmentFiles |
478 | /** | 477 | /** |
479 | * Constructs java code exit. | 478 | * Constructs java code exit. |
480 | * | 479 | * |
481 | - * @param fileType generated file type | ||
482 | * @param curNode current YANG node | 480 | * @param curNode current YANG node |
483 | * @throws IOException when fails to generate java files | 481 | * @throws IOException when fails to generate java files |
484 | */ | 482 | */ |
485 | - public void generateEventJavaFile(int fileType, YangNode curNode) | 483 | + public void generateEventJavaFile(YangNode curNode) |
486 | throws IOException { | 484 | throws IOException { |
487 | 485 | ||
488 | List<String> imports = new ArrayList<>(); | 486 | List<String> imports = new ArrayList<>(); |
... | @@ -536,11 +534,10 @@ public class TempJavaServiceFragmentFiles | ... | @@ -536,11 +534,10 @@ public class TempJavaServiceFragmentFiles |
536 | /** | 534 | /** |
537 | * Constructs java code exit. | 535 | * Constructs java code exit. |
538 | * | 536 | * |
539 | - * @param fileType generated file type | ||
540 | * @param curNode current YANG node | 537 | * @param curNode current YANG node |
541 | * @throws IOException when fails to generate java files | 538 | * @throws IOException when fails to generate java files |
542 | */ | 539 | */ |
543 | - public void generateEventSubjectJavaFile(int fileType, YangNode curNode) | 540 | + public void generateEventSubjectJavaFile(YangNode curNode) |
544 | throws IOException { | 541 | throws IOException { |
545 | 542 | ||
546 | String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) | 543 | String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) |
... | @@ -778,7 +775,7 @@ public class TempJavaServiceFragmentFiles | ... | @@ -778,7 +775,7 @@ public class TempJavaServiceFragmentFiles |
778 | /** | 775 | /** |
779 | * Returns a temporary file handle for the event's file type. | 776 | * Returns a temporary file handle for the event's file type. |
780 | * | 777 | * |
781 | - * @param fileName file name | 778 | + * @param name file name |
782 | * @return temporary file handle | 779 | * @return temporary file handle |
783 | * @throws IOException when fails to create new file handle | 780 | * @throws IOException when fails to create new file handle |
784 | */ | 781 | */ |
... | @@ -786,9 +783,10 @@ public class TempJavaServiceFragmentFiles | ... | @@ -786,9 +783,10 @@ public class TempJavaServiceFragmentFiles |
786 | throws IOException { | 783 | throws IOException { |
787 | 784 | ||
788 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | 785 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
786 | + JavaFileInfo childInfo = ((JavaFileInfoContainer) curNode.getChild()).getJavaFileInfo(); | ||
789 | 787 | ||
790 | return getFileObject(getDirPath(parentInfo), name, JAVA_FILE_EXTENSION, | 788 | return getFileObject(getDirPath(parentInfo), name, JAVA_FILE_EXTENSION, |
791 | - parentInfo); | 789 | + childInfo); |
792 | } | 790 | } |
793 | 791 | ||
794 | /** | 792 | /** | ... | ... |
... | @@ -39,7 +39,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato | ... | @@ -39,7 +39,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato |
39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | 39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
40 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc; | 40 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc; |
41 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; | 41 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; |
42 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | 42 | +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
43 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
44 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
45 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; | 45 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; | ... | ... |
... | @@ -16,17 +16,22 @@ | ... | @@ -16,17 +16,22 @@ |
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; | ||
19 | 21 | ||
20 | import org.onosproject.yangutils.datamodel.YangAugment; | 22 | import org.onosproject.yangutils.datamodel.YangAugment; |
23 | +import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 24 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 25 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | 26 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; |
24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 27 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
28 | +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 static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
29 | import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; | 33 | import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; |
34 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
30 | 35 | ||
31 | /** | 36 | /** |
32 | * Represents augment information extended to support java code generation. | 37 | * Represents augment information extended to support java code generation. |
... | @@ -38,11 +43,21 @@ public class YangJavaAugment | ... | @@ -38,11 +43,21 @@ public class YangJavaAugment |
38 | private static final long serialVersionUID = 806201632L; | 43 | private static final long serialVersionUID = 806201632L; |
39 | 44 | ||
40 | /** | 45 | /** |
46 | + * Prefix to be added to generated java file for augment node. | ||
47 | + */ | ||
48 | + private static final String AUGMENTED = "Augmented"; | ||
49 | + | ||
50 | + /** | ||
41 | * Contains the information of the java file being generated. | 51 | * Contains the information of the java file being generated. |
42 | */ | 52 | */ |
43 | private JavaFileInfo javaFileInfo; | 53 | private JavaFileInfo javaFileInfo; |
44 | 54 | ||
45 | /** | 55 | /** |
56 | + * TargetNodes java qualified info. | ||
57 | + */ | ||
58 | + private List<JavaQualifiedTypeInfo> extendedClassInfo; | ||
59 | + | ||
60 | + /** | ||
46 | * File handle to maintain temporary java code fragments as per the code | 61 | * File handle to maintain temporary java code fragments as per the code |
47 | * snippet types. | 62 | * snippet types. |
48 | */ | 63 | */ |
... | @@ -54,6 +69,7 @@ public class YangJavaAugment | ... | @@ -54,6 +69,7 @@ public class YangJavaAugment |
54 | public YangJavaAugment() { | 69 | public YangJavaAugment() { |
55 | super(); | 70 | super(); |
56 | setJavaFileInfo(new JavaFileInfo()); | 71 | setJavaFileInfo(new JavaFileInfo()); |
72 | + setExtendedClassInfo(new ArrayList<>()); | ||
57 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 73 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
58 | } | 74 | } |
59 | 75 | ||
... | @@ -130,4 +146,46 @@ public class YangJavaAugment | ... | @@ -130,4 +146,46 @@ public class YangJavaAugment |
130 | throw new TranslatorException("Failed to generate code for augmentable node " + getName()); | 146 | throw new TranslatorException("Failed to generate code for augmentable node " + getName()); |
131 | } | 147 | } |
132 | } | 148 | } |
149 | + | ||
150 | + /** | ||
151 | + * Returns augment class name. | ||
152 | + * | ||
153 | + * @return augment class name | ||
154 | + */ | ||
155 | + public String getAugmentClassName() { | ||
156 | + YangNodeIdentifier nodeId = getTargetNode().get(getTargetNode().size() - 1).getNodeIdentifier(); | ||
157 | + if (nodeId.getPrefix() != null) { | ||
158 | + return AUGMENTED + getCapitalCase(nodeId.getPrefix()) + getCapitalCase(nodeId.getName()); | ||
159 | + } else { | ||
160 | + return AUGMENTED + getCapitalCase(nodeId.getName()); | ||
161 | + } | ||
162 | + } | ||
163 | + | ||
164 | + /** | ||
165 | + * Returns extended class info. | ||
166 | + * | ||
167 | + * @return extended class info | ||
168 | + */ | ||
169 | + public List<JavaQualifiedTypeInfo> getExtendedClassInfo() { | ||
170 | + return extendedClassInfo; | ||
171 | + } | ||
172 | + | ||
173 | + /** | ||
174 | + * Sets extended class info. | ||
175 | + * | ||
176 | + * @param augmentedInfo extended class info | ||
177 | + */ | ||
178 | + private void setExtendedClassInfo(List<JavaQualifiedTypeInfo> augmentedInfo) { | ||
179 | + extendedClassInfo = augmentedInfo; | ||
180 | + } | ||
181 | + | ||
182 | + /** | ||
183 | + * Adds to extended class info list. | ||
184 | + * | ||
185 | + * @param augmentedInfo extended class info | ||
186 | + */ | ||
187 | + public void addToExtendedClassInfo(JavaQualifiedTypeInfo augmentedInfo) { | ||
188 | + getExtendedClassInfo().add(augmentedInfo); | ||
189 | + } | ||
190 | + | ||
133 | } | 191 | } | ... | ... |
... | @@ -35,7 +35,7 @@ import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaMode | ... | @@ -35,7 +35,7 @@ import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaMode |
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; |
37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; | 37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
38 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | 38 | +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
40 | 40 | ||
41 | /** | 41 | /** | ... | ... |
... | @@ -16,12 +16,18 @@ | ... | @@ -16,12 +16,18 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.translator.tojava.javamodel; | 17 | package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | 18 | ||
19 | +import java.io.File; | ||
19 | import java.io.IOException; | 20 | import java.io.IOException; |
21 | +import java.util.ArrayList; | ||
22 | +import java.util.List; | ||
23 | + | ||
20 | import org.onosproject.yangutils.datamodel.RpcNotificationContainer; | 24 | import org.onosproject.yangutils.datamodel.RpcNotificationContainer; |
21 | import org.onosproject.yangutils.datamodel.YangCase; | 25 | import org.onosproject.yangutils.datamodel.YangCase; |
22 | import org.onosproject.yangutils.datamodel.YangChoice; | 26 | import org.onosproject.yangutils.datamodel.YangChoice; |
27 | +import org.onosproject.yangutils.datamodel.YangGrouping; | ||
23 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 28 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
24 | import org.onosproject.yangutils.datamodel.YangNode; | 29 | import org.onosproject.yangutils.datamodel.YangNode; |
30 | +import org.onosproject.yangutils.datamodel.YangTypeDef; | ||
25 | import org.onosproject.yangutils.datamodel.YangTypeHolder; | 31 | import org.onosproject.yangutils.datamodel.YangTypeHolder; |
26 | import org.onosproject.yangutils.datamodel.utils.DataModelUtils; | 32 | import org.onosproject.yangutils.datamodel.utils.DataModelUtils; |
27 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 33 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
... | @@ -38,7 +44,12 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -38,7 +44,12 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
38 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
39 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 45 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
40 | import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile; | 46 | import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile; |
47 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | ||
48 | +import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | ||
49 | +import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | ||
50 | +import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; | ||
41 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 51 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
52 | +import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; | ||
42 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | 53 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
43 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 54 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
44 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; | 55 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; |
... | @@ -65,9 +76,14 @@ public final class YangJavaModelUtils { | ... | @@ -65,9 +76,14 @@ public final class YangJavaModelUtils { |
65 | YangPluginConfig yangPluginConfig) | 76 | YangPluginConfig yangPluginConfig) |
66 | throws IOException { | 77 | throws IOException { |
67 | 78 | ||
79 | + if (javaCodeGeneratorInfo instanceof YangJavaAugment) { | ||
80 | + javaCodeGeneratorInfo.getJavaFileInfo() | ||
81 | + .setJavaName(((YangJavaAugment) javaCodeGeneratorInfo).getAugmentClassName()); | ||
82 | + } else { | ||
68 | javaCodeGeneratorInfo.getJavaFileInfo() | 83 | javaCodeGeneratorInfo.getJavaFileInfo() |
69 | .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), | 84 | .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), |
70 | yangPluginConfig.getConflictResolver())); | 85 | yangPluginConfig.getConflictResolver())); |
86 | + } | ||
71 | javaCodeGeneratorInfo.getJavaFileInfo().setPackage(getCurNodePackage((YangNode) javaCodeGeneratorInfo)); | 87 | javaCodeGeneratorInfo.getJavaFileInfo().setPackage(getCurNodePackage((YangNode) javaCodeGeneratorInfo)); |
72 | javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath( | 88 | javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath( |
73 | getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage())); | 89 | getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage())); |
... | @@ -83,15 +99,14 @@ public final class YangJavaModelUtils { | ... | @@ -83,15 +99,14 @@ public final class YangJavaModelUtils { |
83 | * @throws IOException IO operations fails | 99 | * @throws IOException IO operations fails |
84 | */ | 100 | */ |
85 | private static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, YangPluginConfig yangPlugin, | 101 | private static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, YangPluginConfig yangPlugin, |
86 | - String pkg) | 102 | + String pkg) throws IOException { |
87 | - throws IOException { | ||
88 | javaCodeGeneratorInfo.getJavaFileInfo() | 103 | javaCodeGeneratorInfo.getJavaFileInfo() |
89 | .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), | 104 | .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), |
90 | yangPlugin.getConflictResolver())); | 105 | yangPlugin.getConflictResolver())); |
91 | javaCodeGeneratorInfo.getJavaFileInfo().setPackage(pkg); | 106 | javaCodeGeneratorInfo.getJavaFileInfo().setPackage(pkg); |
92 | javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath( | 107 | javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath( |
93 | getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage())); | 108 | getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage())); |
94 | - javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getCodeGenDir()); | 109 | + javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getManagerCodeGenDir()); |
95 | javaCodeGeneratorInfo.getJavaFileInfo().setPluginConfig(yangPlugin); | 110 | javaCodeGeneratorInfo.getJavaFileInfo().setPluginConfig(yangPlugin); |
96 | } | 111 | } |
97 | 112 | ||
... | @@ -253,26 +268,44 @@ public final class YangJavaModelUtils { | ... | @@ -253,26 +268,44 @@ public final class YangJavaModelUtils { |
253 | 268 | ||
254 | generateCodeOfNode(javaCodeGeneratorInfo, yangPlugin); | 269 | generateCodeOfNode(javaCodeGeneratorInfo, yangPlugin); |
255 | 270 | ||
256 | - /* | 271 | + if (javaCodeGeneratorInfo instanceof YangJavaAugment) { |
257 | - TODO: Need to use this, when augmentation is added in YMS | 272 | + JavaQualifiedTypeInfo augmentedBuilderInfo = new JavaQualifiedTypeInfo(); |
258 | - * For augmentation of nodes. | 273 | + JavaQualifiedTypeInfo augmentedBuilderClassInfo = new JavaQualifiedTypeInfo(); |
259 | - | 274 | + JavaQualifiedTypeInfo augmentedClassInfo = new JavaQualifiedTypeInfo(); |
260 | - if (javaCodeGeneratorInfo instanceof YangAugmentationHolder) { | 275 | + JavaQualifiedTypeInfo augmentedImplInfo = new JavaQualifiedTypeInfo(); |
261 | - JavaQualifiedTypeInfo augmentationHoldersInfo = new JavaQualifiedTypeInfo(); | 276 | + YangNode augmentedNode = ((YangJavaAugment) javaCodeGeneratorInfo).getAugmentedNode(); |
262 | - augmentationHoldersInfo.setClassInfo(AUGMENTATION_HOLDER); | 277 | + String name = null; |
263 | - augmentationHoldersInfo.setPkgInfo(PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG); | 278 | + JavaFileInfo augmentedfileInfo = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo(); |
279 | + if (augmentedfileInfo.getJavaName() != null) { | ||
280 | + name = getCapitalCase(augmentedfileInfo.getJavaName()); | ||
281 | + augmentedClassInfo.setClassInfo(name); | ||
282 | + augmentedClassInfo.setPkgInfo(augmentedfileInfo.getPackage()); | ||
283 | + } else { | ||
284 | + name = getCapitalCase(getCamelCase(augmentedNode.getName(), yangPlugin.getConflictResolver())); | ||
285 | + augmentedClassInfo.setClassInfo(name); | ||
286 | + augmentedClassInfo.setPkgInfo(getAugmentedNodesPackage(augmentedNode, yangPlugin)); | ||
287 | + } | ||
288 | + augmentedBuilderInfo.setClassInfo(name + PERIOD + name + BUILDER); | ||
289 | + augmentedBuilderInfo.setPkgInfo(augmentedClassInfo.getPkgInfo()); | ||
290 | + augmentedBuilderClassInfo.setClassInfo(getCapitalCase(DEFAULT) + name + PERIOD + name + BUILDER); | ||
291 | + augmentedBuilderClassInfo.setPkgInfo(augmentedClassInfo.getPkgInfo()); | ||
292 | + augmentedImplInfo.setClassInfo(getCapitalCase(DEFAULT) + name); | ||
293 | + augmentedImplInfo.setPkgInfo(augmentedBuilderInfo.getPkgInfo()); | ||
294 | + ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedBuilderInfo); | ||
295 | + ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedImplInfo); | ||
296 | + ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedBuilderClassInfo); | ||
297 | + ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedClassInfo); | ||
264 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() | 298 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() |
265 | - .addToExtendsList(augmentationHoldersInfo, (YangNode) javaCodeGeneratorInfo); | 299 | + .addToExtendsList(augmentedClassInfo, (YangNode) javaCodeGeneratorInfo); |
266 | - | 300 | + javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() |
267 | - } else if (javaCodeGeneratorInfo instanceof YangAugment) { | 301 | + .addToExtendsList(augmentedBuilderInfo, (YangNode) javaCodeGeneratorInfo); |
268 | - JavaQualifiedTypeInfo augmentedInfo = new JavaQualifiedTypeInfo(); | 302 | + javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() |
269 | - augmentedInfo.setClassInfo(AUGMENTED_INFO); | 303 | + .addToExtendsList(augmentedImplInfo, (YangNode) javaCodeGeneratorInfo); |
270 | - augmentedInfo.setPkgInfo(PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG); | ||
271 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() | 304 | javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() |
272 | - .addToExtendsList(augmentedInfo, (YangNode) javaCodeGeneratorInfo); | 305 | + .addToExtendsList(augmentedBuilderClassInfo, (YangNode) javaCodeGeneratorInfo); |
273 | 306 | ||
274 | } | 307 | } |
275 | - */ | 308 | + |
276 | if (javaCodeGeneratorInfo instanceof YangCase) { | 309 | if (javaCodeGeneratorInfo instanceof YangCase) { |
277 | YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent(); | 310 | YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent(); |
278 | JavaQualifiedTypeInfo parentsInfo = new JavaQualifiedTypeInfo(); | 311 | JavaQualifiedTypeInfo parentsInfo = new JavaQualifiedTypeInfo(); |
... | @@ -289,6 +322,45 @@ public final class YangJavaModelUtils { | ... | @@ -289,6 +322,45 @@ public final class YangJavaModelUtils { |
289 | } | 322 | } |
290 | } | 323 | } |
291 | 324 | ||
325 | + private static String getAugmentedNodesPackage(YangNode node, YangPluginConfig yangPluginConfig) { | ||
326 | + | ||
327 | + List<String> clsInfo = new ArrayList<>(); | ||
328 | + node = node.getParent(); | ||
329 | + while (node != null) { | ||
330 | + if (!(node instanceof YangJavaModule) | ||
331 | + || !(node instanceof YangJavaSubModule)) { | ||
332 | + if (node instanceof YangJavaAugment) { | ||
333 | + clsInfo.add(((YangJavaAugment) node).getAugmentClassName()); | ||
334 | + } else { | ||
335 | + clsInfo.add(getCamelCase(node.getName(), yangPluginConfig.getConflictResolver())); | ||
336 | + } | ||
337 | + } | ||
338 | + if (node instanceof YangJavaModule | ||
339 | + || node instanceof YangJavaSubModule) { | ||
340 | + break; | ||
341 | + } | ||
342 | + node = node.getParent(); | ||
343 | + } | ||
344 | + | ||
345 | + StringBuilder pkg = new StringBuilder(); | ||
346 | + if (node instanceof YangJavaModule) { | ||
347 | + YangJavaModule module = (YangJavaModule) node; | ||
348 | + pkg.append(getRootPackage(module.getVersion(), module.getNameSpace().getUri(), module | ||
349 | + .getRevision().getRevDate(), yangPluginConfig.getConflictResolver())); | ||
350 | + } else if (node instanceof YangJavaSubModule) { | ||
351 | + YangJavaSubModule submodule = (YangJavaSubModule) node; | ||
352 | + pkg.append(getRootPackage(submodule.getVersion(), | ||
353 | + submodule.getNameSpaceFromModule(submodule.getBelongsTo()), | ||
354 | + submodule.getRevision().getRevDate(), yangPluginConfig.getConflictResolver())); | ||
355 | + } | ||
356 | + for (int i = 1; i <= clsInfo.size(); i++) { | ||
357 | + pkg.append("." + clsInfo.get(clsInfo.size() - i)); | ||
358 | + } | ||
359 | + | ||
360 | + return pkg.toString().toLowerCase(); | ||
361 | + | ||
362 | + } | ||
363 | + | ||
292 | /** | 364 | /** |
293 | * Generates code for the current data model node. | 365 | * Generates code for the current data model node. |
294 | * | 366 | * |
... | @@ -370,4 +442,44 @@ public final class YangJavaModelUtils { | ... | @@ -370,4 +442,44 @@ public final class YangJavaModelUtils { |
370 | pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName(); | 442 | pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName(); |
371 | return pkg.toLowerCase(); | 443 | return pkg.toLowerCase(); |
372 | } | 444 | } |
445 | + | ||
446 | + /** | ||
447 | + * Returns true if root node contains any data node. | ||
448 | + * | ||
449 | + * @param node root YANG node | ||
450 | + * @return true if root node contains any data node | ||
451 | + */ | ||
452 | + public static boolean isManagerCodeGenRequired(YangNode node) { | ||
453 | + YangLeavesHolder holder = (YangLeavesHolder) node; | ||
454 | + | ||
455 | + if (holder.getListOfLeaf() != null && !holder.getListOfLeaf().isEmpty()) { | ||
456 | + return true; | ||
457 | + } else if (holder.getListOfLeafList() != null && !holder.getListOfLeafList().isEmpty()) { | ||
458 | + return true; | ||
459 | + } | ||
460 | + node = node.getChild(); | ||
461 | + return node != null && !(node instanceof YangTypeDef) && !(node instanceof YangGrouping); | ||
462 | + } | ||
463 | + | ||
464 | + /** | ||
465 | + * Return false if files are already present. | ||
466 | + * | ||
467 | + * @param info java file info | ||
468 | + * @return false if files already present | ||
469 | + */ | ||
470 | + public static boolean isGenerationOfCodeReq(JavaFileInfo info) { | ||
471 | + File codeGenDir = new File(info.getBaseCodeGenPath() | ||
472 | + + info.getPackageFilePath()); | ||
473 | + File[] files = codeGenDir.listFiles(); | ||
474 | + if (files.length >= 1) { | ||
475 | + for (File file : files) { | ||
476 | + if (file.getName().contentEquals(getCapitalCase(info.getJavaName() + MANAGER + ".java")) | ||
477 | + || file.getName().contentEquals(getCapitalCase(info.getJavaName() + SERVICE + ".java"))) { | ||
478 | + return false; | ||
479 | + } | ||
480 | + } | ||
481 | + } | ||
482 | + return true; | ||
483 | + } | ||
484 | + | ||
373 | } | 485 | } | ... | ... |
... | @@ -33,8 +33,10 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -33,8 +33,10 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
33 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | 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; | 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
36 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | ||
37 | import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode; | 36 | import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode; |
37 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.isManagerCodeGenRequired; | ||
38 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.isGenerationOfCodeReq; | ||
39 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | ||
38 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; | 40 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; |
39 | 41 | ||
40 | /** | 42 | /** |
... | @@ -60,7 +62,7 @@ public class YangJavaModule | ... | @@ -60,7 +62,7 @@ public class YangJavaModule |
60 | /** | 62 | /** |
61 | * List of notifications nodes. | 63 | * List of notifications nodes. |
62 | */ | 64 | */ |
63 | - private List<YangNode> notificationNodes; | 65 | + private transient List<YangNode> notificationNodes; |
64 | 66 | ||
65 | /** | 67 | /** |
66 | * Creates a YANG node of module type. | 68 | * Creates a YANG node of module type. |
... | @@ -153,10 +155,15 @@ public class YangJavaModule | ... | @@ -153,10 +155,15 @@ public class YangJavaModule |
153 | * | 155 | * |
154 | * The manager class needs to extend the "ListenerRegistry". | 156 | * The manager class needs to extend the "ListenerRegistry". |
155 | */ | 157 | */ |
158 | + | ||
156 | try { | 159 | try { |
160 | + if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { | ||
157 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); | 161 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); |
162 | + } | ||
158 | searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + | 163 | searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + |
159 | getJavaFileInfo().getPackageFilePath()); | 164 | getJavaFileInfo().getPackageFilePath()); |
165 | + searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() + | ||
166 | + getJavaFileInfo().getPackageFilePath()); | ||
160 | } catch (IOException e) { | 167 | } catch (IOException e) { |
161 | throw new TranslatorException("Failed to generate code for module node " + getName()); | 168 | throw new TranslatorException("Failed to generate code for module node " + getName()); |
162 | } | 169 | } | ... | ... |
... | @@ -35,8 +35,10 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -35,8 +35,10 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | 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; | 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
37 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 37 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
38 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | ||
39 | import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode; | 38 | import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode; |
39 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.isManagerCodeGenRequired; | ||
40 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.isGenerationOfCodeReq; | ||
41 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | ||
40 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; | 42 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; |
41 | 43 | ||
42 | /** | 44 | /** |
... | @@ -62,7 +64,7 @@ public class YangJavaSubModule | ... | @@ -62,7 +64,7 @@ public class YangJavaSubModule |
62 | /** | 64 | /** |
63 | * List of notifications nodes. | 65 | * List of notifications nodes. |
64 | */ | 66 | */ |
65 | - private List<YangNode> notificationNodes = new ArrayList<>(); | 67 | + private transient List<YangNode> notificationNodes = new ArrayList<>(); |
66 | 68 | ||
67 | /** | 69 | /** |
68 | * Creates YANG java sub module object. | 70 | * Creates YANG java sub module object. |
... | @@ -167,9 +169,13 @@ public class YangJavaSubModule | ... | @@ -167,9 +169,13 @@ public class YangJavaSubModule |
167 | * The manager class needs to extend the "ListenerRegistry". | 169 | * The manager class needs to extend the "ListenerRegistry". |
168 | */ | 170 | */ |
169 | try { | 171 | try { |
172 | + if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { | ||
170 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); | 173 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); |
174 | + } | ||
171 | searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + | 175 | searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + |
172 | getJavaFileInfo().getPackageFilePath()); | 176 | getJavaFileInfo().getPackageFilePath()); |
177 | + searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() + | ||
178 | + getJavaFileInfo().getPackageFilePath()); | ||
173 | } catch (IOException e) { | 179 | } catch (IOException e) { |
174 | throw new TranslatorException("Failed to generate code for submodule node " + getName()); | 180 | throw new TranslatorException("Failed to generate code for submodule node " + getName()); |
175 | } | 181 | } | ... | ... |
... | @@ -16,13 +16,15 @@ | ... | @@ -16,13 +16,15 @@ |
16 | 16 | ||
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.YangIdentity; | 20 | import org.onosproject.yangutils.datamodel.YangIdentity; |
20 | import org.onosproject.yangutils.datamodel.YangNode; | 21 | import org.onosproject.yangutils.datamodel.YangNode; |
21 | import org.onosproject.yangutils.datamodel.YangNotification; | 22 | import org.onosproject.yangutils.datamodel.YangNotification; |
22 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
24 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ||
25 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 26 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 27 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
25 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaIdentity; | ||
26 | 28 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; | 29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; | 30 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; |
... | @@ -36,9 +38,11 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -36,9 +38,11 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; | 38 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
37 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; | 39 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; |
38 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; | 40 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
41 | +import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT; | ||
39 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
40 | import static org.onosproject.yangutils.utils.UtilConstants.CLASS; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.CLASS; |
41 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
45 | +import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | ||
42 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; | 46 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; |
43 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; | 47 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; |
44 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; | 48 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; |
... | @@ -47,7 +51,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRIN | ... | @@ -47,7 +51,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRIN |
47 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; | 51 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; |
48 | import static org.onosproject.yangutils.utils.UtilConstants.EXTEND; | 52 | import static org.onosproject.yangutils.utils.UtilConstants.EXTEND; |
49 | import static org.onosproject.yangutils.utils.UtilConstants.FINAL; | 53 | import static org.onosproject.yangutils.utils.UtilConstants.FINAL; |
50 | -import static org.onosproject.yangutils.utils.UtilConstants.IMPL; | ||
51 | import static org.onosproject.yangutils.utils.UtilConstants.IMPLEMENTS; | 54 | import static org.onosproject.yangutils.utils.UtilConstants.IMPLEMENTS; |
52 | import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; | 55 | import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; |
53 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_REG; | 56 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_REG; |
... | @@ -61,7 +64,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING | ... | @@ -61,7 +64,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING |
61 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; | 64 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
62 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 65 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
63 | import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT; | 66 | import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT; |
64 | -import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT; | ||
65 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 67 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
66 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 68 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
67 | 69 | ||
... | @@ -91,12 +93,6 @@ public final class ClassDefinitionGenerator { | ... | @@ -91,12 +93,6 @@ public final class ClassDefinitionGenerator { |
91 | * class / interface definition start. | 93 | * class / interface definition start. |
92 | */ | 94 | */ |
93 | switch (genFileTypes) { | 95 | switch (genFileTypes) { |
94 | - case BUILDER_CLASS_MASK: | ||
95 | - return getBuilderClassDefinition(yangName); | ||
96 | - case IMPL_CLASS_MASK: | ||
97 | - return getImplClassDefinition(yangName); | ||
98 | - case BUILDER_INTERFACE_MASK: | ||
99 | - return getBuilderInterfaceDefinition(yangName); | ||
100 | case GENERATE_TYPEDEF_CLASS: | 96 | case GENERATE_TYPEDEF_CLASS: |
101 | case GENERATE_UNION_CLASS: | 97 | case GENERATE_UNION_CLASS: |
102 | return getTypeClassDefinition(yangName); | 98 | return getTypeClassDefinition(yangName); |
... | @@ -125,6 +121,12 @@ public final class ClassDefinitionGenerator { | ... | @@ -125,6 +121,12 @@ public final class ClassDefinitionGenerator { |
125 | switch (genFileTypes) { | 121 | switch (genFileTypes) { |
126 | case INTERFACE_MASK: | 122 | case INTERFACE_MASK: |
127 | return getInterfaceDefinition(yangName, curNode); | 123 | return getInterfaceDefinition(yangName, curNode); |
124 | + case BUILDER_CLASS_MASK: | ||
125 | + return getBuilderClassDefinition(yangName, curNode); | ||
126 | + case IMPL_CLASS_MASK: | ||
127 | + return getImplClassDefinition(yangName, curNode); | ||
128 | + case BUILDER_INTERFACE_MASK: | ||
129 | + return getBuilderInterfaceDefinition(yangName, curNode); | ||
128 | case GENERATE_SERVICE_AND_MANAGER: | 130 | case GENERATE_SERVICE_AND_MANAGER: |
129 | return getRpcInterfaceDefinition(yangName, curNode); | 131 | return getRpcInterfaceDefinition(yangName, curNode); |
130 | case GENERATE_EVENT_CLASS: | 132 | case GENERATE_EVENT_CLASS: |
... | @@ -158,22 +160,10 @@ public final class ClassDefinitionGenerator { | ... | @@ -158,22 +160,10 @@ public final class ClassDefinitionGenerator { |
158 | * @return definition | 160 | * @return definition |
159 | */ | 161 | */ |
160 | private static String getInterfaceDefinition(String yangName, YangNode curNode) { | 162 | private static String getInterfaceDefinition(String yangName, YangNode curNode) { |
161 | - JavaExtendsListHolder holder = ((TempJavaCodeFragmentFilesContainer) curNode) | ||
162 | - .getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder(); | ||
163 | - | ||
164 | - if (holder.getExtendsList() != null && !holder.getExtendsList().isEmpty()) { | ||
165 | - String def = PUBLIC + SPACE + INTERFACE + SPACE + yangName + SPACE + EXTEND + SPACE; | ||
166 | - for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | ||
167 | - if (!holder.getExtendedClassStore().get(info)) { | ||
168 | - def = def + info.getClassInfo() + COMMA + SPACE; | ||
169 | - } else { | ||
170 | - def = def + info.getPkgInfo() + PERIOD + info.getClassInfo() + COMMA + SPACE; | ||
171 | - } | ||
172 | - } | ||
173 | 163 | ||
174 | - def = trimAtLast(def, COMMA); | 164 | + String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, INTERFACE_MASK); |
175 | - | 165 | + if (clsDef != null) { |
176 | - return def + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 166 | + return clsDef; |
177 | } | 167 | } |
178 | return PUBLIC + SPACE + INTERFACE + SPACE + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 168 | return PUBLIC + SPACE + INTERFACE + SPACE + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
179 | } | 169 | } |
... | @@ -185,7 +175,14 @@ public final class ClassDefinitionGenerator { | ... | @@ -185,7 +175,14 @@ public final class ClassDefinitionGenerator { |
185 | * is being generated | 175 | * is being generated |
186 | * @return definition | 176 | * @return definition |
187 | */ | 177 | */ |
188 | - private static String getBuilderInterfaceDefinition(String yangName) { | 178 | + private static String getBuilderInterfaceDefinition(String yangName, YangNode curNode) { |
179 | + String clsDef = ""; | ||
180 | + if (curNode instanceof YangAugment) { | ||
181 | + clsDef = getClassDefinitionForWhenExtended(curNode, yangName, BUILDER_INTERFACE_MASK); | ||
182 | + if (clsDef != null) { | ||
183 | + return clsDef; | ||
184 | + } | ||
185 | + } | ||
189 | return INTERFACE + SPACE + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + NEW_LINE; | 186 | return INTERFACE + SPACE + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + NEW_LINE; |
190 | } | 187 | } |
191 | 188 | ||
... | @@ -195,7 +192,14 @@ public final class ClassDefinitionGenerator { | ... | @@ -195,7 +192,14 @@ public final class ClassDefinitionGenerator { |
195 | * @param yangName file name | 192 | * @param yangName file name |
196 | * @return definition | 193 | * @return definition |
197 | */ | 194 | */ |
198 | - private static String getBuilderClassDefinition(String yangName) { | 195 | + private static String getBuilderClassDefinition(String yangName, YangNode curNode) { |
196 | + String clsDef = ""; | ||
197 | + if (curNode instanceof YangAugment) { | ||
198 | + clsDef = getClassDefinitionForWhenExtended(curNode, yangName, BUILDER_CLASS_MASK); | ||
199 | + if (clsDef != null) { | ||
200 | + return clsDef; | ||
201 | + } | ||
202 | + } | ||
199 | return PUBLIC + SPACE + CLASS + SPACE + yangName + BUILDER + SPACE + IMPLEMENTS + SPACE + yangName + PERIOD | 203 | return PUBLIC + SPACE + CLASS + SPACE + yangName + BUILDER + SPACE + IMPLEMENTS + SPACE + yangName + PERIOD |
200 | + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 204 | + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
201 | } | 205 | } |
... | @@ -206,8 +210,15 @@ public final class ClassDefinitionGenerator { | ... | @@ -206,8 +210,15 @@ public final class ClassDefinitionGenerator { |
206 | * @param yangName file name | 210 | * @param yangName file name |
207 | * @return definition | 211 | * @return definition |
208 | */ | 212 | */ |
209 | - private static String getImplClassDefinition(String yangName) { | 213 | + private static String getImplClassDefinition(String yangName, YangNode curNode) { |
210 | - return PUBLIC + SPACE + FINAL + SPACE + CLASS + SPACE + yangName + IMPL + SPACE + IMPLEMENTS + SPACE | 214 | + String clsDef = ""; |
215 | + if (curNode instanceof YangAugment) { | ||
216 | + clsDef = getClassDefinitionForWhenExtended(curNode, yangName, IMPL_CLASS_MASK); | ||
217 | + if (clsDef != null) { | ||
218 | + return clsDef; | ||
219 | + } | ||
220 | + } | ||
221 | + return PUBLIC + SPACE + CLASS + SPACE + getCapitalCase(DEFAULT) + yangName + SPACE + IMPLEMENTS + SPACE | ||
211 | + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | 222 | + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
212 | } | 223 | } |
213 | 224 | ||
... | @@ -228,19 +239,19 @@ public final class ClassDefinitionGenerator { | ... | @@ -228,19 +239,19 @@ public final class ClassDefinitionGenerator { |
228 | * @return identity class definition | 239 | * @return identity class definition |
229 | */ | 240 | */ |
230 | private static String getIdentityClassDefinition(String yangName, YangNode curNode) { | 241 | private static String getIdentityClassDefinition(String yangName, YangNode curNode) { |
231 | - if (!(curNode instanceof YangJavaIdentity)) { | 242 | + if (!(curNode instanceof YangIdentity)) { |
232 | throw new TranslatorException("Expected java identity instance node"); | 243 | throw new TranslatorException("Expected java identity instance node"); |
233 | } | 244 | } |
234 | - YangJavaIdentity identity = (YangJavaIdentity) curNode; | 245 | + YangIdentity identity = (YangIdentity) curNode; |
235 | if (identity.getBaseNode() != null) { | 246 | if (identity.getBaseNode() != null) { |
236 | YangIdentity baseIdentity = identity.getBaseNode().getReferredIdentity(); | 247 | YangIdentity baseIdentity = identity.getBaseNode().getReferredIdentity(); |
237 | - if (!(baseIdentity instanceof YangJavaIdentity)) { | 248 | + if (!(baseIdentity instanceof YangIdentity)) { |
238 | throw new TranslatorException("Expected java identity instance node"); | 249 | throw new TranslatorException("Expected java identity instance node"); |
239 | } | 250 | } |
240 | 251 | ||
241 | - YangJavaIdentity baseJavaIdentity = (YangJavaIdentity) baseIdentity; | 252 | + JavaFileInfo fileInfo = ((JavaFileInfoContainer) baseIdentity).getJavaFileInfo(); |
242 | return PUBLIC + SPACE + ABSTRACT + SPACE + CLASS + SPACE + yangName + SPACE + EXTEND + SPACE | 253 | return PUBLIC + SPACE + ABSTRACT + SPACE + CLASS + SPACE + yangName + SPACE + EXTEND + SPACE |
243 | - + getCapitalCase(baseJavaIdentity.getJavaFileInfo().getJavaName()) + SPACE + | 254 | + + getCapitalCase(fileInfo.getJavaName()) + SPACE + |
244 | OPEN_CURLY_BRACKET + NEW_LINE; | 255 | OPEN_CURLY_BRACKET + NEW_LINE; |
245 | } | 256 | } |
246 | 257 | ||
... | @@ -332,4 +343,99 @@ public final class ClassDefinitionGenerator { | ... | @@ -332,4 +343,99 @@ public final class ClassDefinitionGenerator { |
332 | 343 | ||
333 | return intfDef; | 344 | return intfDef; |
334 | } | 345 | } |
346 | + | ||
347 | + /** | ||
348 | + * Returns class definition when class is extending another class. | ||
349 | + * | ||
350 | + * @param curNode current node | ||
351 | + * @param yangName name | ||
352 | + * @param genFileTypes gen file type | ||
353 | + * @return class definition | ||
354 | + */ | ||
355 | + private static String getClassDefinitionForWhenExtended(YangNode curNode, String yangName, int genFileTypes) { | ||
356 | + JavaExtendsListHolder holder = ((TempJavaCodeFragmentFilesContainer) curNode) | ||
357 | + .getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder(); | ||
358 | + | ||
359 | + if (holder.getExtendsList() != null && !holder.getExtendsList().isEmpty()) { | ||
360 | + String def = PUBLIC + SPACE; | ||
361 | + switch (genFileTypes) { | ||
362 | + case INTERFACE_MASK: | ||
363 | + def = def + INTERFACE + SPACE + yangName + SPACE + EXTEND + SPACE; | ||
364 | + for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | ||
365 | + if (curNode instanceof YangAugment) { | ||
366 | + if (!info.getClassInfo().contains(BUILDER) && !info.getClassInfo().contains( | ||
367 | + getCapitalCase(DEFAULT))) { | ||
368 | + def = getDefinitionString(def, info, holder); | ||
369 | + } | ||
370 | + } else { | ||
371 | + def = getDefinitionString(def, info, holder); | ||
372 | + } | ||
373 | + } | ||
374 | + def = trimAtLast(def, COMMA); | ||
375 | + | ||
376 | + return def + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | ||
377 | + case BUILDER_INTERFACE_MASK: | ||
378 | + String builderDef = INTERFACE + SPACE + yangName + BUILDER + SPACE + EXTEND + SPACE; | ||
379 | + for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | ||
380 | + if (info.getClassInfo().contains(BUILDER) && !info.getClassInfo().contains( | ||
381 | + getCapitalCase(DEFAULT))) { | ||
382 | + builderDef = getDefinitionString(builderDef, info, holder); | ||
383 | + } | ||
384 | + } | ||
385 | + | ||
386 | + builderDef = trimAtLast(builderDef, COMMA); | ||
387 | + | ||
388 | + return builderDef + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | ||
389 | + case BUILDER_CLASS_MASK: | ||
390 | + def = def + CLASS + SPACE + yangName + BUILDER + SPACE + EXTEND + SPACE; | ||
391 | + for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | ||
392 | + if (info.getClassInfo().contains(BUILDER) | ||
393 | + && info.getClassInfo().contains(getCapitalCase(DEFAULT))) { | ||
394 | + def = getDefinitionString(def, info, holder); | ||
395 | + } | ||
396 | + } | ||
397 | + | ||
398 | + def = trimAtLast(def, COMMA); | ||
399 | + | ||
400 | + return def + SPACE + IMPLEMENTS + SPACE + yangName + PERIOD | ||
401 | + + yangName + BUILDER + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | ||
402 | + | ||
403 | + case IMPL_CLASS_MASK: | ||
404 | + def = def + SPACE + CLASS + SPACE + getCapitalCase(DEFAULT) + yangName + SPACE + EXTEND + SPACE; | ||
405 | + for (JavaQualifiedTypeInfo info : holder.getExtendsList()) { | ||
406 | + if (!info.getClassInfo().contains(BUILDER) | ||
407 | + && info.getClassInfo().contains(getCapitalCase(DEFAULT))) { | ||
408 | + def = getDefinitionString(def, info, holder); | ||
409 | + } | ||
410 | + } | ||
411 | + | ||
412 | + def = trimAtLast(def, COMMA); | ||
413 | + | ||
414 | + return def + SPACE + IMPLEMENTS + SPACE | ||
415 | + + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | ||
416 | + | ||
417 | + default: | ||
418 | + return null; | ||
419 | + } | ||
420 | + } | ||
421 | + return null; | ||
422 | + } | ||
423 | + | ||
424 | + /** | ||
425 | + * Returns updated class definition. | ||
426 | + * | ||
427 | + * @param def current definition | ||
428 | + * @param info java qualified info | ||
429 | + * @param holder extend list holder | ||
430 | + * @return updated class definition | ||
431 | + */ | ||
432 | + private static String getDefinitionString(String def, JavaQualifiedTypeInfo info, JavaExtendsListHolder holder) { | ||
433 | + if (!holder.getExtendedClassStore().get(info)) { | ||
434 | + def = def + info.getClassInfo() + COMMA + SPACE; | ||
435 | + } else { | ||
436 | + def = def + info.getPkgInfo() + PERIOD + info.getClassInfo() + COMMA + SPACE; | ||
437 | + } | ||
438 | + return def; | ||
439 | + } | ||
440 | + | ||
335 | } | 441 | } | ... | ... |
... | @@ -16,31 +16,51 @@ | ... | @@ -16,31 +16,51 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.translator.tojava.utils; | 17 | package org.onosproject.yangutils.translator.tojava.utils; |
18 | 18 | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 22 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
23 | +import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | ||
24 | +import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | ||
25 | +import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; | ||
20 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 26 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
21 | 27 | ||
22 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; | 28 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; |
23 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | 29 | +import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION_IMPORT; |
24 | -import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST; | ||
25 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; | ||
26 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | 30 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
27 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | 31 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
28 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | 32 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
33 | +import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION; | ||
34 | +import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION_IMPORT; | ||
35 | +import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE_ANNOTATION_IMPORT; | ||
29 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; | 36 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET; |
30 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; |
38 | +import static org.onosproject.yangutils.utils.UtilConstants.ENUM; | ||
31 | import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; |
32 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
41 | +import static org.onosproject.yangutils.utils.UtilConstants.IMMEDIATE; | ||
33 | import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; |
43 | +import static org.onosproject.yangutils.utils.UtilConstants.INT; | ||
34 | import static org.onosproject.yangutils.utils.UtilConstants.LIST; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.LIST; |
35 | -import static org.onosproject.yangutils.utils.UtilConstants.NEW; | 45 | +import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; |
46 | +import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_FACTORY_IMPORT; | ||
47 | +import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT; | ||
36 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 48 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
49 | +import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; | ||
37 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; | 50 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; |
38 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 51 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
39 | import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; | 52 | import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; |
53 | +import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; | ||
40 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 54 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
55 | +import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION; | ||
56 | +import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_IMPORT; | ||
41 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 57 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
42 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | 58 | +import static org.onosproject.yangutils.utils.UtilConstants.TRUE; |
59 | +import static org.onosproject.yangutils.utils.UtilConstants.TYPE; | ||
43 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; | 60 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; |
61 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
62 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | ||
63 | +import static java.util.Collections.sort; | ||
44 | 64 | ||
45 | /** | 65 | /** |
46 | * Represents utility class to generate the java snippet. | 66 | * Represents utility class to generate the java snippet. |
... | @@ -121,17 +141,6 @@ public final class JavaCodeSnippetGen { | ... | @@ -121,17 +141,6 @@ public final class JavaCodeSnippetGen { |
121 | } | 141 | } |
122 | 142 | ||
123 | /** | 143 | /** |
124 | - * Returns attribute of augmented info for generated impl file. | ||
125 | - * | ||
126 | - * @return attribute of augmented info for generated impl file | ||
127 | - */ | ||
128 | - public static String getAugmentedInfoAttribute() { | ||
129 | - return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + getListAttribute(AUGMENTED_INFO) + SPACE | ||
130 | - + getSmallCase(AUGMENTED_INFO) + LIST + SPACE + EQUAL + SPACE + NEW + SPACE + ARRAY_LIST | ||
131 | - + DIAMOND_OPEN_BRACKET + DIAMOND_CLOSE_BRACKET + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN; | ||
132 | - } | ||
133 | - | ||
134 | - /** | ||
135 | * Returns based on the file type and the YANG name of the file, generate the class | 144 | * Returns based on the file type and the YANG name of the file, generate the class |
136 | * / interface definition close. | 145 | * / interface definition close. |
137 | * | 146 | * |
... | @@ -155,4 +164,128 @@ public final class JavaCodeSnippetGen { | ... | @@ -155,4 +164,128 @@ public final class JavaCodeSnippetGen { |
155 | + value + CLOSE_PARENTHESIS + COMMA + NEW_LINE; | 164 | + value + CLOSE_PARENTHESIS + COMMA + NEW_LINE; |
156 | } | 165 | } |
157 | 166 | ||
167 | + /** | ||
168 | + * Adds annotations imports. | ||
169 | + * | ||
170 | + * @param imports list if imports | ||
171 | + * @param operation to add or to delete | ||
172 | + */ | ||
173 | + public static void addAnnotationsImports(List<String> imports, boolean operation) { | ||
174 | + if (operation) { | ||
175 | + imports.add(ACTIVATE_ANNOTATION_IMPORT); | ||
176 | + imports.add(DEACTIVATE_ANNOTATION_IMPORT); | ||
177 | + imports.add(COMPONENT_ANNOTATION_IMPORT); | ||
178 | + imports.add(SERVICE_ANNOTATION_IMPORT); | ||
179 | + imports.add(LOGGER_FACTORY_IMPORT); | ||
180 | + imports.add(LOGGER_IMPORT); | ||
181 | + } else { | ||
182 | + imports.remove(ACTIVATE_ANNOTATION_IMPORT); | ||
183 | + imports.remove(DEACTIVATE_ANNOTATION_IMPORT); | ||
184 | + imports.remove(COMPONENT_ANNOTATION_IMPORT); | ||
185 | + imports.remove(SERVICE_ANNOTATION_IMPORT); | ||
186 | + imports.remove(LOGGER_FACTORY_IMPORT); | ||
187 | + imports.remove(LOGGER_IMPORT); | ||
188 | + } | ||
189 | + sortImports(imports); | ||
190 | + } | ||
191 | + | ||
192 | + /** | ||
193 | + * Returns sorted import list. | ||
194 | + * | ||
195 | + * @param imports import list | ||
196 | + * @return sorted import list | ||
197 | + */ | ||
198 | + public static List<String> sortImports(List<String> imports) { | ||
199 | + sort(imports); | ||
200 | + return imports; | ||
201 | + } | ||
202 | + | ||
203 | + /** | ||
204 | + * Returns event enum start. | ||
205 | + * | ||
206 | + * @return event enum start | ||
207 | + */ | ||
208 | + public static String getEventEnumTypeStart() { | ||
209 | + return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + ENUM + SPACE + TYPE + SPACE + OPEN_CURLY_BRACKET | ||
210 | + + NEW_LINE; | ||
211 | + } | ||
212 | + | ||
213 | + /** | ||
214 | + * Adds listener's imports. | ||
215 | + * | ||
216 | + * @param curNode currentYangNode. | ||
217 | + * @param imports import list | ||
218 | + * @param operation add or remove | ||
219 | + * @param classInfo class info to be added to import list | ||
220 | + */ | ||
221 | + public static void addListenersImport(YangNode curNode, List<String> imports, boolean operation, | ||
222 | + String classInfo) { | ||
223 | + String thisImport = ""; | ||
224 | + if (classInfo.equals(LISTENER_SERVICE)) { | ||
225 | + thisImport = getTempJavaFragment(curNode).getJavaImportData().getListenerServiceImport(); | ||
226 | + performOperationOnImports(imports, thisImport, operation); | ||
227 | + } else { | ||
228 | + thisImport = getTempJavaFragment(curNode).getJavaImportData().getListenerRegistryImport(); | ||
229 | + performOperationOnImports(imports, thisImport, operation); | ||
230 | + } | ||
231 | + } | ||
232 | + | ||
233 | + /** | ||
234 | + * Performs given operations on import list. | ||
235 | + * | ||
236 | + * @param imports list of imports | ||
237 | + * @param curImport current import | ||
238 | + * @param operation add or remove | ||
239 | + * @return import list | ||
240 | + */ | ||
241 | + private static List<String> performOperationOnImports(List<String> imports, String curImport, | ||
242 | + boolean operation) { | ||
243 | + if (operation) { | ||
244 | + imports.add(curImport); | ||
245 | + } else { | ||
246 | + imports.remove(curImport); | ||
247 | + } | ||
248 | + sortImports(imports); | ||
249 | + return imports; | ||
250 | + } | ||
251 | + | ||
252 | + /** | ||
253 | + * Returns temp java fragment. | ||
254 | + * | ||
255 | + * @param curNode current YANG node | ||
256 | + * @return temp java fragments | ||
257 | + */ | ||
258 | + public static TempJavaFragmentFiles getTempJavaFragment(YangNode curNode) { | ||
259 | + TempJavaCodeFragmentFiles container = ((TempJavaCodeFragmentFilesContainer) curNode) | ||
260 | + .getTempJavaCodeFragmentFiles(); | ||
261 | + if (container.getBeanTempFiles() != null) { | ||
262 | + return container.getBeanTempFiles(); | ||
263 | + } | ||
264 | + if (container.getServiceTempFiles() != null) { | ||
265 | + return container.getServiceTempFiles(); | ||
266 | + } | ||
267 | + | ||
268 | + return null; | ||
269 | + } | ||
270 | + | ||
271 | + /** | ||
272 | + * Returns integer attribute for enum's class to get the values. | ||
273 | + * | ||
274 | + * @param className enum's class name | ||
275 | + * @return enum's attribute | ||
276 | + */ | ||
277 | + public static String getEnumsValueAttribute(String className) { | ||
278 | + return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + INT + SPACE + getSmallCase(className) | ||
279 | + + SEMI_COLAN + NEW_LINE; | ||
280 | + } | ||
281 | + | ||
282 | + /** | ||
283 | + * Returns component string. | ||
284 | + * | ||
285 | + * @return component string | ||
286 | + */ | ||
287 | + public static String addComponentString() { | ||
288 | + return NEW_LINE + COMPONENT_ANNOTATION + SPACE + OPEN_PARENTHESIS + IMMEDIATE + SPACE | ||
289 | + + EQUAL + SPACE + TRUE + CLOSE_PARENTHESIS + NEW_LINE + SERVICE_ANNOTATION; | ||
290 | + } | ||
158 | } | 291 | } | ... | ... |
... | @@ -28,7 +28,7 @@ import org.onosproject.yangutils.translator.tojava.JavaImportData; | ... | @@ -28,7 +28,7 @@ import org.onosproject.yangutils.translator.tojava.JavaImportData; |
28 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 28 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
29 | 29 | ||
30 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 30 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
31 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.getTempJavaFragement; | 31 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getTempJavaFragment; |
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 |
... | @@ -62,7 +62,7 @@ public class JavaExtendsListHolder { | ... | @@ -62,7 +62,7 @@ public class JavaExtendsListHolder { |
62 | * @param extendedClass map of classes need to be extended | 62 | * @param extendedClass map of classes need to be extended |
63 | */ | 63 | */ |
64 | private void setExtendedClassStore(Map<JavaQualifiedTypeInfo, Boolean> extendedClass) { | 64 | private void setExtendedClassStore(Map<JavaQualifiedTypeInfo, Boolean> extendedClass) { |
65 | - this.extendedClassStore = extendedClass; | 65 | + extendedClassStore = extendedClass; |
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
... | @@ -74,7 +74,7 @@ public class JavaExtendsListHolder { | ... | @@ -74,7 +74,7 @@ public class JavaExtendsListHolder { |
74 | public void addToExtendsList(JavaQualifiedTypeInfo info, YangNode node) { | 74 | public void addToExtendsList(JavaQualifiedTypeInfo info, YangNode node) { |
75 | JavaFileInfo fileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo(); | 75 | JavaFileInfo fileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo(); |
76 | 76 | ||
77 | - JavaImportData importData = getTempJavaFragement(node).getJavaImportData(); | 77 | + JavaImportData importData = getTempJavaFragment(node).getJavaImportData(); |
78 | boolean qualified = importData.addImportInfo(info, | 78 | boolean qualified = importData.addImportInfo(info, |
79 | getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage()); | 79 | getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage()); |
80 | 80 | ||
... | @@ -99,7 +99,7 @@ public class JavaExtendsListHolder { | ... | @@ -99,7 +99,7 @@ public class JavaExtendsListHolder { |
99 | * @param classInfoList the extends List to set | 99 | * @param classInfoList the extends List to set |
100 | */ | 100 | */ |
101 | private void setExtendsList(List<JavaQualifiedTypeInfo> classInfoList) { | 101 | private void setExtendsList(List<JavaQualifiedTypeInfo> classInfoList) { |
102 | - this.extendsList = classInfoList; | 102 | + extendsList = classInfoList; |
103 | } | 103 | } |
104 | 104 | ||
105 | /** | 105 | /** | ... | ... |
... | @@ -21,14 +21,14 @@ import java.io.IOException; | ... | @@ -21,14 +21,14 @@ import java.io.IOException; |
21 | import java.util.ArrayList; | 21 | import java.util.ArrayList; |
22 | import java.util.List; | 22 | import java.util.List; |
23 | 23 | ||
24 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
24 | import org.onosproject.yangutils.datamodel.YangNode; | 25 | import org.onosproject.yangutils.datamodel.YangNode; |
26 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 27 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
26 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | 28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
27 | -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | ||
28 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
29 | import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; | 30 | import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; |
30 | import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; | 31 | import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; |
31 | -import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
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.BUILDER_CLASS_MASK; | 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
... | @@ -43,6 +43,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -43,6 +43,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
43 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; | 43 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; |
44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; | 44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
45 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; | 45 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; |
46 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.AUGMENTE_CLASS_CONSTRUCTOR_MASK; | ||
46 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; | 47 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; |
47 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; | 48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; |
48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; | 49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; |
... | @@ -62,17 +63,14 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. | ... | @@ -62,17 +63,14 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. |
62 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; | 63 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; |
63 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; | 64 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; |
64 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; | 65 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; |
65 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getAugmentedInfoAttribute; | ||
66 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle; | 66 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle; |
67 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getEnumsValueAttribute; | 67 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEnumsValueAttribute; |
68 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; | 68 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; |
69 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
70 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addActivateMethod; | 69 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addActivateMethod; |
71 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod; | 70 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod; |
72 | -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl; | 71 | +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedNodesConstructorStart; |
73 | -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentInfoListImpl; | ||
74 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart; | 72 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart; |
75 | -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstrcutor; | 73 | +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstructor; |
76 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfMethod; | 74 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfMethod; |
77 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethodClose; | 75 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethodClose; |
78 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethodOpen; | 76 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethodOpen; |
... | @@ -82,31 +80,36 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator | ... | @@ -82,31 +80,36 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator |
82 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose; | 80 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose; |
83 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen; | 81 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen; |
84 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString; | 82 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString; |
85 | -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRemoveAugmentationImpl; | ||
86 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodClose; | 83 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodClose; |
87 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen; | 84 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen; |
88 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.getEventEnumTypeStart; | 85 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEventEnumTypeStart; |
89 | -import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.isAugmentationHolderExtended; | ||
90 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | 86 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
91 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | 87 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
88 | +import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | ||
92 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | 89 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
90 | +import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | ||
91 | +import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; | ||
93 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 92 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
94 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING; | 93 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING; |
95 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; | 94 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; |
96 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_SUBJECT_NAME_SUFFIX; | 95 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_SUBJECT_NAME_SUFFIX; |
97 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 96 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
98 | -import static org.onosproject.yangutils.utils.UtilConstants.IMPL; | ||
99 | import static org.onosproject.yangutils.utils.UtilConstants.INT; | 97 | import static org.onosproject.yangutils.utils.UtilConstants.INT; |
100 | import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_STATEMENT; | 98 | import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_STATEMENT; |
101 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; | 99 | import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; |
102 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 100 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
101 | +import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; | ||
102 | +import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; | ||
103 | import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; | 103 | import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; |
104 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; | 104 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; |
105 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 105 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
106 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_METHOD_STRING; | 106 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_METHOD_STRING; |
107 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | 107 | +import static org.onosproject.yangutils.utils.UtilConstants.SUPER; |
108 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; | 108 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
109 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; | 109 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; |
110 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
111 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
112 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
110 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; | 113 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
111 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 114 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
112 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength; | 115 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength; |
... | @@ -134,6 +137,7 @@ public final class JavaFileGenerator { | ... | @@ -134,6 +137,7 @@ public final class JavaFileGenerator { |
134 | throws IOException { | 137 | throws IOException { |
135 | 138 | ||
136 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | 139 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
140 | + String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | ||
137 | 141 | ||
138 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 142 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
139 | 143 | ||
... | @@ -149,7 +153,7 @@ public final class JavaFileGenerator { | ... | @@ -149,7 +153,7 @@ public final class JavaFileGenerator { |
149 | */ | 153 | */ |
150 | insertDataIntoJavaFile(file, getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, | 154 | insertDataIntoJavaFile(file, getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, |
151 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 155 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
152 | - .getBeanTempFiles())); | 156 | + .getBeanTempFiles(), path)); |
153 | } catch (IOException e) { | 157 | } catch (IOException e) { |
154 | throw new IOException("No data found in temporary java code fragment files for " + className | 158 | throw new IOException("No data found in temporary java code fragment files for " + className |
155 | + " while interface file generation"); | 159 | + " while interface file generation"); |
... | @@ -176,7 +180,7 @@ public final class JavaFileGenerator { | ... | @@ -176,7 +180,7 @@ public final class JavaFileGenerator { |
176 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 180 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
177 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 181 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); |
178 | 182 | ||
179 | - initiateJavaFileGeneration(file, className, BUILDER_INTERFACE_MASK, null, path, pluginConfig); | 183 | + initiateJavaFileGeneration(file, BUILDER_INTERFACE_MASK, null, curNode, className); |
180 | List<String> methods = new ArrayList<>(); | 184 | List<String> methods = new ArrayList<>(); |
181 | if (isAttrPresent) { | 185 | if (isAttrPresent) { |
182 | try { | 186 | try { |
... | @@ -185,14 +189,14 @@ public final class JavaFileGenerator { | ... | @@ -185,14 +189,14 @@ public final class JavaFileGenerator { |
185 | */ | 189 | */ |
186 | methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, | 190 | methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, |
187 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 191 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
188 | - .getBeanTempFiles())); | 192 | + .getBeanTempFiles(), path)); |
189 | /** | 193 | /** |
190 | * Setter methods. | 194 | * Setter methods. |
191 | */ | 195 | */ |
192 | methods.add(NEW_LINE); | 196 | methods.add(NEW_LINE); |
193 | methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK, | 197 | methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK, |
194 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 198 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
195 | - .getBeanTempFiles())); | 199 | + .getBeanTempFiles(), path)); |
196 | } catch (IOException e) { | 200 | } catch (IOException e) { |
197 | throw new IOException("No data found in temporary java code fragment files for " + className | 201 | throw new IOException("No data found in temporary java code fragment files for " + className |
198 | + " while builder interface file generation"); | 202 | + " while builder interface file generation"); |
... | @@ -220,15 +224,13 @@ public final class JavaFileGenerator { | ... | @@ -220,15 +224,13 @@ public final class JavaFileGenerator { |
220 | * Returns generated builder class file for current node. | 224 | * Returns generated builder class file for current node. |
221 | * | 225 | * |
222 | * @param file file | 226 | * @param file file |
223 | - * @param imports imports for the file | ||
224 | * @param curNode current YANG node | 227 | * @param curNode current YANG node |
225 | * @param isAttrPresent if any attribute is present or not | 228 | * @param isAttrPresent if any attribute is present or not |
226 | * @return builder class file | 229 | * @return builder class file |
227 | * @throws IOException when fails to write in file | 230 | * @throws IOException when fails to write in file |
228 | */ | 231 | */ |
229 | - public static File generateBuilderClassFile(File file, List<String> imports, YangNode curNode, | 232 | + public static File generateBuilderClassFile(File file, YangNode curNode, |
230 | - boolean isAttrPresent) | 233 | + boolean isAttrPresent) throws IOException { |
231 | - throws IOException { | ||
232 | 234 | ||
233 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | 235 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
234 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); | 236 | YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig(); |
... | @@ -236,9 +238,12 @@ public final class JavaFileGenerator { | ... | @@ -236,9 +238,12 @@ public final class JavaFileGenerator { |
236 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 238 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
237 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 239 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); |
238 | 240 | ||
239 | - initiateJavaFileGeneration(file, className, BUILDER_CLASS_MASK, imports, path, pluginConfig); | 241 | + initiateJavaFileGeneration(file, BUILDER_CLASS_MASK, null, curNode, className); |
240 | - | ||
241 | List<String> methods = new ArrayList<>(); | 242 | List<String> methods = new ArrayList<>(); |
243 | + boolean isAugmentNode = false; | ||
244 | + if (curNode instanceof YangAugment) { | ||
245 | + isAugmentNode = true; | ||
246 | + } | ||
242 | 247 | ||
243 | if (isAttrPresent) { | 248 | if (isAttrPresent) { |
244 | /** | 249 | /** |
... | @@ -248,7 +253,7 @@ public final class JavaFileGenerator { | ... | @@ -248,7 +253,7 @@ public final class JavaFileGenerator { |
248 | insertDataIntoJavaFile(file, | 253 | insertDataIntoJavaFile(file, |
249 | NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, | 254 | NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, |
250 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 255 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
251 | - .getBeanTempFiles())); | 256 | + .getBeanTempFiles(), path)); |
252 | } catch (IOException e) { | 257 | } catch (IOException e) { |
253 | throw new IOException("No data found in temporary java code fragment files for " + className | 258 | throw new IOException("No data found in temporary java code fragment files for " + className |
254 | + " while builder class file generation"); | 259 | + " while builder class file generation"); |
... | @@ -260,14 +265,30 @@ public final class JavaFileGenerator { | ... | @@ -260,14 +265,30 @@ public final class JavaFileGenerator { |
260 | */ | 265 | */ |
261 | methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, | 266 | methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, |
262 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 267 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
263 | - .getBeanTempFiles())); | 268 | + .getBeanTempFiles(), path)); |
264 | /** | 269 | /** |
265 | * Setter methods. | 270 | * Setter methods. |
266 | */ | 271 | */ |
267 | methods.add(getDataFromTempFileHandle(SETTER_FOR_CLASS_MASK, | 272 | methods.add(getDataFromTempFileHandle(SETTER_FOR_CLASS_MASK, |
268 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 273 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
269 | - .getBeanTempFiles()) + | 274 | + .getBeanTempFiles(), path)); |
270 | - NEW_LINE); | 275 | + |
276 | + if (isAugmentNode) { | ||
277 | + YangAugment augment = (YangAugment) curNode; | ||
278 | + String augmentNode = getCapitalCase( | ||
279 | + getCamelCase(augment.getAugmentedNode().getName(), pluginConfig.getConflictResolver())); | ||
280 | + /** | ||
281 | + * Constructor. | ||
282 | + */ | ||
283 | + String constructor = getAugmentedNodesConstructorStart(className, augmentNode) | ||
284 | + + getDataFromTempFileHandle(AUGMENTE_CLASS_CONSTRUCTOR_MASK, | ||
285 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | ||
286 | + .getBeanTempFiles(), path); | ||
287 | + | ||
288 | + methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + | ||
289 | + NEW_LINE + NEW_LINE); | ||
290 | + } | ||
291 | + insertDataIntoJavaFile(file, NEW_LINE); | ||
271 | } catch (IOException e) { | 292 | } catch (IOException e) { |
272 | throw new IOException("No data found in temporary java code fragment files for " + className | 293 | throw new IOException("No data found in temporary java code fragment files for " + className |
273 | + " while builder class file generation"); | 294 | + " while builder class file generation"); |
... | @@ -289,6 +310,7 @@ public final class JavaFileGenerator { | ... | @@ -289,6 +310,7 @@ public final class JavaFileGenerator { |
289 | for (String method : methods) { | 310 | for (String method : methods) { |
290 | insertDataIntoJavaFile(file, method); | 311 | insertDataIntoJavaFile(file, method); |
291 | } | 312 | } |
313 | + insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET); | ||
292 | return validateLineLength(file); | 314 | return validateLineLength(file); |
293 | } | 315 | } |
294 | 316 | ||
... | @@ -309,6 +331,7 @@ public final class JavaFileGenerator { | ... | @@ -309,6 +331,7 @@ public final class JavaFileGenerator { |
309 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | 331 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
310 | 332 | ||
311 | String className = getCapitalCase(javaFileInfo.getJavaName()) + MANAGER; | 333 | String className = getCapitalCase(javaFileInfo.getJavaName()) + MANAGER; |
334 | + String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | ||
312 | 335 | ||
313 | initiateJavaFileGeneration(file, GENERATE_SERVICE_AND_MANAGER, imports, curNode, className); | 336 | initiateJavaFileGeneration(file, GENERATE_SERVICE_AND_MANAGER, imports, curNode, className); |
314 | 337 | ||
... | @@ -326,14 +349,14 @@ public final class JavaFileGenerator { | ... | @@ -326,14 +349,14 @@ public final class JavaFileGenerator { |
326 | methods.add( | 349 | methods.add( |
327 | getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, | 350 | getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, |
328 | ((TempJavaCodeFragmentFilesContainer) curNode) | 351 | ((TempJavaCodeFragmentFilesContainer) curNode) |
329 | - .getTempJavaCodeFragmentFiles().getServiceTempFiles())); | 352 | + .getTempJavaCodeFragmentFiles().getServiceTempFiles(), path)); |
330 | /** | 353 | /** |
331 | * Setter methods. | 354 | * Setter methods. |
332 | */ | 355 | */ |
333 | methods.add( | 356 | methods.add( |
334 | getDataFromTempFileHandle(SETTER_FOR_CLASS_MASK, | 357 | getDataFromTempFileHandle(SETTER_FOR_CLASS_MASK, |
335 | ((TempJavaCodeFragmentFilesContainer) curNode) | 358 | ((TempJavaCodeFragmentFilesContainer) curNode) |
336 | - .getTempJavaCodeFragmentFiles().getServiceTempFiles()) | 359 | + .getTempJavaCodeFragmentFiles().getServiceTempFiles(), path) |
337 | + NEW_LINE); | 360 | + NEW_LINE); |
338 | 361 | ||
339 | } | 362 | } |
... | @@ -343,7 +366,7 @@ public final class JavaFileGenerator { | ... | @@ -343,7 +366,7 @@ public final class JavaFileGenerator { |
343 | * Rpc methods | 366 | * Rpc methods |
344 | */ | 367 | */ |
345 | methods.add(getDataFromTempFileHandle(RPC_IMPL_MASK, | 368 | methods.add(getDataFromTempFileHandle(RPC_IMPL_MASK, |
346 | - javaGeninfo.getTempJavaCodeFragmentFiles().getServiceTempFiles())); | 369 | + javaGeninfo.getTempJavaCodeFragmentFiles().getServiceTempFiles(), path)); |
347 | } | 370 | } |
348 | insertDataIntoJavaFile(file, NEW_LINE); | 371 | insertDataIntoJavaFile(file, NEW_LINE); |
349 | 372 | ||
... | @@ -367,10 +390,11 @@ public final class JavaFileGenerator { | ... | @@ -367,10 +390,11 @@ public final class JavaFileGenerator { |
367 | * @param file file | 390 | * @param file file |
368 | * @param curNode current YANG node | 391 | * @param curNode current YANG node |
369 | * @param isAttrPresent if any attribute is present or not | 392 | * @param isAttrPresent if any attribute is present or not |
393 | + * @param imports list of imports | ||
370 | * @return impl class file | 394 | * @return impl class file |
371 | * @throws IOException when fails to write in file | 395 | * @throws IOException when fails to write in file |
372 | */ | 396 | */ |
373 | - public static File generateImplClassFile(File file, YangNode curNode, boolean isAttrPresent) | 397 | + public static File generateImplClassFile(File file, YangNode curNode, boolean isAttrPresent, List<String> imports) |
374 | throws IOException { | 398 | throws IOException { |
375 | 399 | ||
376 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | 400 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
... | @@ -379,20 +403,14 @@ public final class JavaFileGenerator { | ... | @@ -379,20 +403,14 @@ public final class JavaFileGenerator { |
379 | String className = getCapitalCase(javaFileInfo.getJavaName()); | 403 | String className = getCapitalCase(javaFileInfo.getJavaName()); |
380 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 404 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); |
381 | 405 | ||
382 | - initiateJavaFileGeneration(file, className, IMPL_CLASS_MASK, null, path, pluginConfig); | 406 | + initiateJavaFileGeneration(file, IMPL_CLASS_MASK, imports, curNode, className); |
383 | 407 | ||
384 | List<String> methods = new ArrayList<>(); | 408 | List<String> methods = new ArrayList<>(); |
385 | - | 409 | + boolean isAugmentNode = false; |
386 | - TempJavaCodeFragmentFiles javaCodeFragmentFiles = ((TempJavaCodeFragmentFilesContainer) curNode) | 410 | + if (curNode instanceof YangAugment) { |
387 | - .getTempJavaCodeFragmentFiles(); | 411 | + isAugmentNode = true; |
388 | - boolean isAugmentationHolderExtended = isAugmentationHolderExtended( | ||
389 | - javaCodeFragmentFiles.getBeanTempFiles().getJavaExtendsListHolder().getExtendsList()); | ||
390 | - /** | ||
391 | - * Add attribute for augmented info's list. | ||
392 | - */ | ||
393 | - if (isAugmentationHolderExtended) { | ||
394 | - insertDataIntoJavaFile(file, getAugmentedInfoAttribute()); | ||
395 | } | 412 | } |
413 | + | ||
396 | if (isAttrPresent) { | 414 | if (isAttrPresent) { |
397 | /** | 415 | /** |
398 | * Add attribute strings. | 416 | * Add attribute strings. |
... | @@ -401,20 +419,19 @@ public final class JavaFileGenerator { | ... | @@ -401,20 +419,19 @@ public final class JavaFileGenerator { |
401 | insertDataIntoJavaFile(file, | 419 | insertDataIntoJavaFile(file, |
402 | NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, | 420 | NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, |
403 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 421 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
404 | - .getBeanTempFiles())); | 422 | + .getBeanTempFiles(), path)); |
405 | } catch (IOException e) { | 423 | } catch (IOException e) { |
406 | throw new IOException("No data found in temporary java code fragment files for " + className | 424 | throw new IOException("No data found in temporary java code fragment files for " + className |
407 | + " while impl class file generation"); | 425 | + " while impl class file generation"); |
408 | } | 426 | } |
409 | 427 | ||
410 | - insertDataIntoJavaFile(file, NEW_LINE); | ||
411 | try { | 428 | try { |
412 | /** | 429 | /** |
413 | * Getter methods. | 430 | * Getter methods. |
414 | */ | 431 | */ |
415 | methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, | 432 | methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, |
416 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 433 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
417 | - .getBeanTempFiles())); | 434 | + .getBeanTempFiles(), path)); |
418 | 435 | ||
419 | /** | 436 | /** |
420 | * Hash code method. | 437 | * Hash code method. |
... | @@ -422,20 +439,20 @@ public final class JavaFileGenerator { | ... | @@ -422,20 +439,20 @@ public final class JavaFileGenerator { |
422 | methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + | 439 | methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + |
423 | getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, | 440 | getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, |
424 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 441 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
425 | - .getBeanTempFiles()).replace(NEW_LINE, EMPTY_STRING))); | 442 | + .getBeanTempFiles(), path).replace(NEW_LINE, EMPTY_STRING))); |
426 | /** | 443 | /** |
427 | * Equals method. | 444 | * Equals method. |
428 | */ | 445 | */ |
429 | - methods.add(getEqualsMethodClose( | 446 | + methods.add(getEqualsMethodClose(getEqualsMethodOpen(getCapitalCase(DEFAULT) + className) |
430 | - getEqualsMethodOpen(className + IMPL) + getDataFromTempFileHandle(EQUALS_IMPL_MASK, | 447 | + + getDataFromTempFileHandle(EQUALS_IMPL_MASK, |
431 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 448 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
432 | - .getBeanTempFiles()))); | 449 | + .getBeanTempFiles(), path))); |
433 | /** | 450 | /** |
434 | * To string method. | 451 | * To string method. |
435 | */ | 452 | */ |
436 | methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, | 453 | methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, |
437 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 454 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
438 | - .getBeanTempFiles()) | 455 | + .getBeanTempFiles(), path) |
439 | + getToStringMethodClose()); | 456 | + getToStringMethodClose()); |
440 | 457 | ||
441 | } catch (IOException e) { | 458 | } catch (IOException e) { |
... | @@ -450,10 +467,15 @@ public final class JavaFileGenerator { | ... | @@ -450,10 +467,15 @@ public final class JavaFileGenerator { |
450 | /** | 467 | /** |
451 | * Constructor. | 468 | * Constructor. |
452 | */ | 469 | */ |
453 | - String constructor = | 470 | + String constructor = getConstructorStart(className, pluginConfig); |
454 | - getConstructorStart(className, pluginConfig) + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK, | 471 | + if (isAugmentNode) { |
472 | + constructor = constructor + EIGHT_SPACE_INDENTATION + SUPER + OPEN_PARENTHESIS | ||
473 | + + BUILDER.toLowerCase() + OBJECT | ||
474 | + + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; | ||
475 | + } | ||
476 | + constructor = constructor + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK, | ||
455 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 477 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
456 | - .getBeanTempFiles()); | 478 | + .getBeanTempFiles(), path); |
457 | 479 | ||
458 | methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET); | 480 | methods.add(constructor + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET); |
459 | } catch (IOException e) { | 481 | } catch (IOException e) { |
... | @@ -462,21 +484,11 @@ public final class JavaFileGenerator { | ... | @@ -462,21 +484,11 @@ public final class JavaFileGenerator { |
462 | } | 484 | } |
463 | 485 | ||
464 | /** | 486 | /** |
465 | - * Add method for augment info's list. | ||
466 | - */ | ||
467 | - if (isAugmentationHolderExtended) { | ||
468 | - methods.add(getAddAugmentInfoMethodImpl()); | ||
469 | - methods.add(getAugmentInfoListImpl()); | ||
470 | - methods.add(getRemoveAugmentationImpl()); | ||
471 | - } | ||
472 | - | ||
473 | - /** | ||
474 | * Add methods in impl class. | 487 | * Add methods in impl class. |
475 | */ | 488 | */ |
476 | for (String method : methods) { | 489 | for (String method : methods) { |
477 | - insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + method + NEW_LINE); | 490 | + insertDataIntoJavaFile(file, method); |
478 | } | 491 | } |
479 | - insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET + NEW_LINE); | ||
480 | 492 | ||
481 | return validateLineLength(file); | 493 | return validateLineLength(file); |
482 | } | 494 | } |
... | @@ -510,7 +522,7 @@ public final class JavaFileGenerator { | ... | @@ -510,7 +522,7 @@ public final class JavaFileGenerator { |
510 | insertDataIntoJavaFile(file, | 522 | insertDataIntoJavaFile(file, |
511 | NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, | 523 | NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, |
512 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 524 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
513 | - .getTypeTempFiles())); | 525 | + .getTypeTempFiles(), path)); |
514 | } catch (IOException e) { | 526 | } catch (IOException e) { |
515 | throw new IOException("No data found in temporary java code fragment files for " + className | 527 | throw new IOException("No data found in temporary java code fragment files for " + className |
516 | + " while type def class file generation"); | 528 | + " while type def class file generation"); |
... | @@ -528,19 +540,22 @@ public final class JavaFileGenerator { | ... | @@ -528,19 +540,22 @@ public final class JavaFileGenerator { |
528 | * Type constructor. | 540 | * Type constructor. |
529 | */ | 541 | */ |
530 | methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK, | 542 | methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK, |
531 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles())); | 543 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), |
544 | + path)); | ||
532 | 545 | ||
533 | /** | 546 | /** |
534 | * Of method. | 547 | * Of method. |
535 | */ | 548 | */ |
536 | methods.add(getDataFromTempFileHandle(OF_STRING_IMPL_MASK, | 549 | methods.add(getDataFromTempFileHandle(OF_STRING_IMPL_MASK, |
537 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles())); | 550 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), |
551 | + path)); | ||
538 | 552 | ||
539 | /** | 553 | /** |
540 | * Getter method. | 554 | * Getter method. |
541 | */ | 555 | */ |
542 | methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, | 556 | methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, |
543 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles())); | 557 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), |
558 | + path)); | ||
544 | 559 | ||
545 | /** | 560 | /** |
546 | * Hash code method. | 561 | * Hash code method. |
... | @@ -548,7 +563,7 @@ public final class JavaFileGenerator { | ... | @@ -548,7 +563,7 @@ public final class JavaFileGenerator { |
548 | methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + | 563 | methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + |
549 | getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, | 564 | getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, |
550 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 565 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
551 | - .getTypeTempFiles()) | 566 | + .getTypeTempFiles(), path) |
552 | .replace(NEW_LINE, EMPTY_STRING))); | 567 | .replace(NEW_LINE, EMPTY_STRING))); |
553 | 568 | ||
554 | /** | 569 | /** |
... | @@ -556,14 +571,15 @@ public final class JavaFileGenerator { | ... | @@ -556,14 +571,15 @@ public final class JavaFileGenerator { |
556 | */ | 571 | */ |
557 | methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + EMPTY_STRING) | 572 | methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + EMPTY_STRING) |
558 | + getDataFromTempFileHandle(EQUALS_IMPL_MASK, | 573 | + getDataFromTempFileHandle(EQUALS_IMPL_MASK, |
559 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles()))); | 574 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
575 | + .getTypeTempFiles(), path))); | ||
560 | 576 | ||
561 | /** | 577 | /** |
562 | * To string method. | 578 | * To string method. |
563 | */ | 579 | */ |
564 | methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, | 580 | methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, |
565 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles()) | 581 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), |
566 | - + getToStringMethodClose()); | 582 | + path) + getToStringMethodClose()); |
567 | 583 | ||
568 | JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; | 584 | JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; |
569 | /** | 585 | /** |
... | @@ -571,7 +587,8 @@ public final class JavaFileGenerator { | ... | @@ -571,7 +587,8 @@ public final class JavaFileGenerator { |
571 | */ | 587 | */ |
572 | methods.add(getFromStringMethodSignature(className, pluginConfig) | 588 | methods.add(getFromStringMethodSignature(className, pluginConfig) |
573 | + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, javaGeninfo.getTempJavaCodeFragmentFiles() | 589 | + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, javaGeninfo.getTempJavaCodeFragmentFiles() |
574 | - .getTypeTempFiles()) + getFromStringMethodClose()); | 590 | + .getTypeTempFiles(), path) |
591 | + + getFromStringMethodClose()); | ||
575 | 592 | ||
576 | } catch (IOException e) { | 593 | } catch (IOException e) { |
577 | throw new IOException("No data found in temporary java code fragment files for " + className | 594 | throw new IOException("No data found in temporary java code fragment files for " + className |
... | @@ -615,7 +632,7 @@ public final class JavaFileGenerator { | ... | @@ -615,7 +632,7 @@ public final class JavaFileGenerator { |
615 | insertDataIntoJavaFile(file, | 632 | insertDataIntoJavaFile(file, |
616 | NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, | 633 | NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, |
617 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 634 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
618 | - .getTypeTempFiles())); | 635 | + .getTypeTempFiles(), path)); |
619 | } catch (IOException e) { | 636 | } catch (IOException e) { |
620 | throw new IOException("No data found in temporary java code fragment files for " + className | 637 | throw new IOException("No data found in temporary java code fragment files for " + className |
621 | + " while union class file generation"); | 638 | + " while union class file generation"); |
... | @@ -633,19 +650,22 @@ public final class JavaFileGenerator { | ... | @@ -633,19 +650,22 @@ public final class JavaFileGenerator { |
633 | * Type constructor. | 650 | * Type constructor. |
634 | */ | 651 | */ |
635 | methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK, | 652 | methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK, |
636 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles())); | 653 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), |
654 | + path)); | ||
637 | 655 | ||
638 | /** | 656 | /** |
639 | * Of string method. | 657 | * Of string method. |
640 | */ | 658 | */ |
641 | methods.add(getDataFromTempFileHandle(OF_STRING_IMPL_MASK, | 659 | methods.add(getDataFromTempFileHandle(OF_STRING_IMPL_MASK, |
642 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles())); | 660 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), |
661 | + path)); | ||
643 | 662 | ||
644 | /** | 663 | /** |
645 | * Getter method. | 664 | * Getter method. |
646 | */ | 665 | */ |
647 | methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, | 666 | methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, |
648 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles())); | 667 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), |
668 | + path)); | ||
649 | 669 | ||
650 | /** | 670 | /** |
651 | * Hash code method. | 671 | * Hash code method. |
... | @@ -653,7 +673,7 @@ public final class JavaFileGenerator { | ... | @@ -653,7 +673,7 @@ public final class JavaFileGenerator { |
653 | methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + | 673 | methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + |
654 | getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, | 674 | getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, |
655 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 675 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
656 | - .getTypeTempFiles()) | 676 | + .getTypeTempFiles(), path) |
657 | .replace(NEW_LINE, EMPTY_STRING))); | 677 | .replace(NEW_LINE, EMPTY_STRING))); |
658 | 678 | ||
659 | /** | 679 | /** |
... | @@ -661,7 +681,8 @@ public final class JavaFileGenerator { | ... | @@ -661,7 +681,8 @@ public final class JavaFileGenerator { |
661 | */ | 681 | */ |
662 | methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + EMPTY_STRING) | 682 | methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + EMPTY_STRING) |
663 | + getDataFromTempFileHandle(EQUALS_IMPL_MASK, | 683 | + getDataFromTempFileHandle(EQUALS_IMPL_MASK, |
664 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles()))); | 684 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
685 | + .getTypeTempFiles(), path))); | ||
665 | 686 | ||
666 | /** | 687 | /** |
667 | * To string method. | 688 | * To string method. |
... | @@ -669,14 +690,16 @@ public final class JavaFileGenerator { | ... | @@ -669,14 +690,16 @@ public final class JavaFileGenerator { |
669 | methods.add(getToStringMethodOpen() + getOmitNullValueString() + | 690 | methods.add(getToStringMethodOpen() + getOmitNullValueString() + |
670 | getDataFromTempFileHandle(TO_STRING_IMPL_MASK, | 691 | getDataFromTempFileHandle(TO_STRING_IMPL_MASK, |
671 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 692 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
672 | - .getTypeTempFiles()) + getToStringMethodClose()); | 693 | + .getTypeTempFiles(), path) |
694 | + + getToStringMethodClose()); | ||
673 | 695 | ||
674 | /** | 696 | /** |
675 | * From string method. | 697 | * From string method. |
676 | */ | 698 | */ |
677 | methods.add(getFromStringMethodSignature(className, pluginConfig) | 699 | methods.add(getFromStringMethodSignature(className, pluginConfig) |
678 | + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, | 700 | + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, |
679 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles()) | 701 | + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
702 | + .getTypeTempFiles(), path) | ||
680 | + getFromStringMethodClose()); | 703 | + getFromStringMethodClose()); |
681 | 704 | ||
682 | } catch (IOException e) { | 705 | } catch (IOException e) { |
... | @@ -717,7 +740,7 @@ public final class JavaFileGenerator { | ... | @@ -717,7 +740,7 @@ public final class JavaFileGenerator { |
717 | JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; | 740 | JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; |
718 | insertDataIntoJavaFile(file, | 741 | insertDataIntoJavaFile(file, |
719 | trimAtLast(trimAtLast(getDataFromTempFileHandle(ENUM_IMPL_MASK, javaGeninfo | 742 | trimAtLast(trimAtLast(getDataFromTempFileHandle(ENUM_IMPL_MASK, javaGeninfo |
720 | - .getTempJavaCodeFragmentFiles().getEnumerationTempFiles()), COMMA), NEW_LINE) | 743 | + .getTempJavaCodeFragmentFiles().getEnumerationTempFiles(), path), COMMA), NEW_LINE) |
721 | + SEMI_COLAN + NEW_LINE); | 744 | + SEMI_COLAN + NEW_LINE); |
722 | } catch (IOException e) { | 745 | } catch (IOException e) { |
723 | throw new IOException("No data found in temporary java code fragment files for " + getCapitalCase(className) | 746 | throw new IOException("No data found in temporary java code fragment files for " + getCapitalCase(className) |
... | @@ -734,10 +757,10 @@ public final class JavaFileGenerator { | ... | @@ -734,10 +757,10 @@ public final class JavaFileGenerator { |
734 | * Add a constructor for enum. | 757 | * Add a constructor for enum. |
735 | */ | 758 | */ |
736 | insertDataIntoJavaFile(file, getJavaDoc(TYPE_CONSTRUCTOR, className, false, pluginConfig) | 759 | insertDataIntoJavaFile(file, getJavaDoc(TYPE_CONSTRUCTOR, className, false, pluginConfig) |
737 | - + getEnumsConstrcutor(getCapitalCase(className)) + NEW_LINE); | 760 | + + getEnumsConstructor(getCapitalCase(className)) + NEW_LINE); |
738 | 761 | ||
739 | - TempJavaEnumerationFragmentFiles enumFragFiles = | 762 | + TempJavaEnumerationFragmentFiles enumFragFiles = ((TempJavaCodeFragmentFilesContainer) curNode) |
740 | - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 763 | + .getTempJavaCodeFragmentFiles() |
741 | .getEnumerationTempFiles(); | 764 | .getEnumerationTempFiles(); |
742 | insertDataIntoJavaFile(file, getEnumsOfMethod(className, | 765 | insertDataIntoJavaFile(file, getEnumsOfMethod(className, |
743 | enumFragFiles.getJavaAttributeForEnum(pluginConfig), | 766 | enumFragFiles.getJavaAttributeForEnum(pluginConfig), |
... | @@ -755,7 +778,7 @@ public final class JavaFileGenerator { | ... | @@ -755,7 +778,7 @@ public final class JavaFileGenerator { |
755 | insertDataIntoJavaFile(file, getFromStringMethodSignature(getCapitalCase(className), pluginConfig) | 778 | insertDataIntoJavaFile(file, getFromStringMethodSignature(getCapitalCase(className), pluginConfig) |
756 | + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, | 779 | + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, |
757 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 780 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
758 | - .getEnumerationTempFiles()) | 781 | + .getEnumerationTempFiles(), path) |
759 | + getFromStringMethodClose()); | 782 | + getFromStringMethodClose()); |
760 | } catch (IOException e) { | 783 | } catch (IOException e) { |
761 | throw new IOException("No data found in temporary java code fragment files for " + | 784 | throw new IOException("No data found in temporary java code fragment files for " + |
... | @@ -784,6 +807,7 @@ public final class JavaFileGenerator { | ... | @@ -784,6 +807,7 @@ public final class JavaFileGenerator { |
784 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); | 807 | JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
785 | 808 | ||
786 | String className = getCapitalCase(javaFileInfo.getJavaName()) + SERVICE_METHOD_STRING; | 809 | String className = getCapitalCase(javaFileInfo.getJavaName()) + SERVICE_METHOD_STRING; |
810 | + String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | ||
787 | initiateJavaFileGeneration(file, GENERATE_SERVICE_AND_MANAGER, imports, curNode, className); | 811 | initiateJavaFileGeneration(file, GENERATE_SERVICE_AND_MANAGER, imports, curNode, className); |
788 | 812 | ||
789 | List<String> methods = new ArrayList<>(); | 813 | List<String> methods = new ArrayList<>(); |
... | @@ -796,13 +820,13 @@ public final class JavaFileGenerator { | ... | @@ -796,13 +820,13 @@ public final class JavaFileGenerator { |
796 | */ | 820 | */ |
797 | methods.add(getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, | 821 | methods.add(getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, |
798 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 822 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
799 | - .getServiceTempFiles())); | 823 | + .getServiceTempFiles(), path)); |
800 | /** | 824 | /** |
801 | * Setter methods. | 825 | * Setter methods. |
802 | */ | 826 | */ |
803 | methods.add(getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK, | 827 | methods.add(getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK, |
804 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() | 828 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
805 | - .getServiceTempFiles())); | 829 | + .getServiceTempFiles(), path)); |
806 | } | 830 | } |
807 | if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) { | 831 | if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) { |
808 | JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; | 832 | JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; |
... | @@ -810,7 +834,7 @@ public final class JavaFileGenerator { | ... | @@ -810,7 +834,7 @@ public final class JavaFileGenerator { |
810 | * Rpc methods | 834 | * Rpc methods |
811 | */ | 835 | */ |
812 | methods.add(getDataFromTempFileHandle(RPC_INTERFACE_MASK, | 836 | methods.add(getDataFromTempFileHandle(RPC_INTERFACE_MASK, |
813 | - javaGeninfo.getTempJavaCodeFragmentFiles().getServiceTempFiles())); | 837 | + javaGeninfo.getTempJavaCodeFragmentFiles().getServiceTempFiles(), path)); |
814 | } | 838 | } |
815 | } catch (IOException e) { | 839 | } catch (IOException e) { |
816 | throw new IOException("No data found in temporary java code fragment files for " + className | 840 | throw new IOException("No data found in temporary java code fragment files for " + className |
... | @@ -835,20 +859,21 @@ public final class JavaFileGenerator { | ... | @@ -835,20 +859,21 @@ public final class JavaFileGenerator { |
835 | */ | 859 | */ |
836 | public static void generateEventFile(File file, YangNode curNode, List<String> imports) throws IOException { | 860 | public static void generateEventFile(File file, YangNode curNode, List<String> imports) throws IOException { |
837 | 861 | ||
838 | - String className = | 862 | + String className = getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()) |
839 | - getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()) | ||
840 | + EVENT_STRING; | 863 | + EVENT_STRING; |
841 | 864 | ||
842 | TempJavaServiceFragmentFiles tempFiles = ((TempJavaCodeFragmentFilesContainer) curNode) | 865 | TempJavaServiceFragmentFiles tempFiles = ((TempJavaCodeFragmentFilesContainer) curNode) |
843 | .getTempJavaCodeFragmentFiles().getServiceTempFiles(); | 866 | .getTempJavaCodeFragmentFiles().getServiceTempFiles(); |
844 | 867 | ||
868 | + String path = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getBaseCodeGenPath() | ||
869 | + + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackageFilePath(); | ||
845 | initiateJavaFileGeneration(file, GENERATE_EVENT_CLASS, imports, curNode, className); | 870 | initiateJavaFileGeneration(file, GENERATE_EVENT_CLASS, imports, curNode, className); |
846 | try { | 871 | try { |
847 | insertDataIntoJavaFile(file, NEW_LINE + getEventEnumTypeStart() + | 872 | insertDataIntoJavaFile(file, NEW_LINE + getEventEnumTypeStart() + |
848 | - trimAtLast(getDataFromTempFileHandle(EVENT_ENUM_MASK, tempFiles), COMMA) | 873 | + trimAtLast(getDataFromTempFileHandle(EVENT_ENUM_MASK, tempFiles, path), COMMA) |
849 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE); | 874 | + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE); |
850 | 875 | ||
851 | - insertDataIntoJavaFile(file, getDataFromTempFileHandle(EVENT_METHOD_MASK, tempFiles)); | 876 | + insertDataIntoJavaFile(file, getDataFromTempFileHandle(EVENT_METHOD_MASK, tempFiles, path)); |
852 | 877 | ||
853 | } catch (IOException e) { | 878 | } catch (IOException e) { |
854 | throw new IOException("No data found in temporary java code fragment files for " + className | 879 | throw new IOException("No data found in temporary java code fragment files for " + className |
... | @@ -870,8 +895,7 @@ public final class JavaFileGenerator { | ... | @@ -870,8 +895,7 @@ public final class JavaFileGenerator { |
870 | public static void generateEventListenerFile(File file, YangNode curNode, List<String> imports) | 895 | public static void generateEventListenerFile(File file, YangNode curNode, List<String> imports) |
871 | throws IOException { | 896 | throws IOException { |
872 | 897 | ||
873 | - String className = | 898 | + String className = getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()) |
874 | - getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()) | ||
875 | + EVENT_LISTENER_STRING; | 899 | + EVENT_LISTENER_STRING; |
876 | 900 | ||
877 | initiateJavaFileGeneration(file, GENERATE_EVENT_LISTENER_INTERFACE, imports, curNode, className); | 901 | initiateJavaFileGeneration(file, GENERATE_EVENT_LISTENER_INTERFACE, imports, curNode, className); |
... | @@ -894,16 +918,18 @@ public final class JavaFileGenerator { | ... | @@ -894,16 +918,18 @@ public final class JavaFileGenerator { |
894 | 918 | ||
895 | initiateJavaFileGeneration(file, GENERATE_EVENT_SUBJECT_CLASS, null, curNode, className); | 919 | initiateJavaFileGeneration(file, GENERATE_EVENT_SUBJECT_CLASS, null, curNode, className); |
896 | 920 | ||
921 | + String path = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getBaseCodeGenPath() | ||
922 | + + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackageFilePath(); | ||
897 | TempJavaServiceFragmentFiles tempFiles = ((TempJavaCodeFragmentFilesContainer) curNode) | 923 | TempJavaServiceFragmentFiles tempFiles = ((TempJavaCodeFragmentFilesContainer) curNode) |
898 | .getTempJavaCodeFragmentFiles().getServiceTempFiles(); | 924 | .getTempJavaCodeFragmentFiles().getServiceTempFiles(); |
899 | 925 | ||
900 | insertDataIntoJavaFile(file, NEW_LINE); | 926 | insertDataIntoJavaFile(file, NEW_LINE); |
901 | try { | 927 | try { |
902 | - insertDataIntoJavaFile(file, getDataFromTempFileHandle(EVENT_SUBJECT_ATTRIBUTE_MASK, tempFiles)); | 928 | + insertDataIntoJavaFile(file, getDataFromTempFileHandle(EVENT_SUBJECT_ATTRIBUTE_MASK, tempFiles, path)); |
903 | 929 | ||
904 | - insertDataIntoJavaFile(file, getDataFromTempFileHandle(EVENT_SUBJECT_GETTER_MASK, tempFiles)); | 930 | + insertDataIntoJavaFile(file, getDataFromTempFileHandle(EVENT_SUBJECT_GETTER_MASK, tempFiles, path)); |
905 | 931 | ||
906 | - insertDataIntoJavaFile(file, getDataFromTempFileHandle(EVENT_SUBJECT_SETTER_MASK, tempFiles)); | 932 | + insertDataIntoJavaFile(file, getDataFromTempFileHandle(EVENT_SUBJECT_SETTER_MASK, tempFiles, path)); |
907 | 933 | ||
908 | } catch (IOException e) { | 934 | } catch (IOException e) { |
909 | throw new IOException("No data found in temporary java code fragment files for " + className | 935 | throw new IOException("No data found in temporary java code fragment files for " + className | ... | ... |
... | @@ -20,6 +20,7 @@ import java.io.File; | ... | @@ -20,6 +20,7 @@ import java.io.File; |
20 | import java.io.IOException; | 20 | import java.io.IOException; |
21 | import java.util.List; | 21 | import java.util.List; |
22 | 22 | ||
23 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
23 | import org.onosproject.yangutils.datamodel.YangNode; | 24 | import org.onosproject.yangutils.datamodel.YangNode; |
24 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 25 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 26 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
... | @@ -39,13 +40,14 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -39,13 +40,14 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
39 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | 40 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; |
40 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | 41 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; |
41 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 42 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
43 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; | ||
42 | 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; |
43 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; | 45 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; |
44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; | 46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
45 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; | ||
46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; | 47 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; |
47 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; | 48 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; | 49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; |
50 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.AUGMENTE_CLASS_CONSTRUCTOR_MASK; | ||
49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; | 51 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; |
50 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; | 52 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; |
51 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; | 53 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; |
... | @@ -66,26 +68,16 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. | ... | @@ -66,26 +68,16 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. |
66 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; | 68 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; |
67 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; | 69 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; |
68 | import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; | 70 | import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; |
69 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; | 71 | +import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
70 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | ||
71 | -import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | ||
72 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | 72 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
73 | -import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION; | 73 | +import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; |
74 | -import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | ||
75 | -import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | ||
76 | -import static org.onosproject.yangutils.utils.UtilConstants.IMMEDIATE; | ||
77 | -import static org.onosproject.yangutils.utils.UtilConstants.INT; | ||
78 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 74 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
79 | -import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; | ||
80 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE; | 75 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE; |
81 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 76 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
82 | -import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; | ||
83 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE; | 77 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE; |
84 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 78 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
85 | -import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION; | ||
86 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 79 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
87 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 80 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
88 | -import static org.onosproject.yangutils.utils.UtilConstants.TRUE; | ||
89 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_CLASS; | 81 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_CLASS; |
90 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_INTERFACE; | 82 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_INTERFACE; |
91 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_CLASS; | 83 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_CLASS; |
... | @@ -97,6 +89,9 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INT | ... | @@ -97,6 +89,9 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INT |
97 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_INTERFACE; | 89 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_INTERFACE; |
98 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_MANAGER; | 90 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_MANAGER; |
99 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | 91 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
92 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
93 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
94 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; | ||
100 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; | 95 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
101 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.parsePkg; | 96 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.parsePkg; |
102 | 97 | ||
... | @@ -130,11 +125,12 @@ public final class JavaFileGeneratorUtils { | ... | @@ -130,11 +125,12 @@ public final class JavaFileGeneratorUtils { |
130 | * | 125 | * |
131 | * @param generatedTempFiles temporary file types | 126 | * @param generatedTempFiles temporary file types |
132 | * @param tempJavaFragmentFiles temp java fragment files | 127 | * @param tempJavaFragmentFiles temp java fragment files |
128 | + * @param absolutePath absolute path | ||
133 | * @return data stored in temporary files | 129 | * @return data stored in temporary files |
134 | * @throws IOException when failed to get the data from temporary file handle | 130 | * @throws IOException when failed to get the data from temporary file handle |
135 | */ | 131 | */ |
136 | public static String getDataFromTempFileHandle(int generatedTempFiles, | 132 | public static String getDataFromTempFileHandle(int generatedTempFiles, |
137 | - TempJavaFragmentFiles tempJavaFragmentFiles) | 133 | + TempJavaFragmentFiles tempJavaFragmentFiles, String absolutePath) |
138 | throws IOException { | 134 | throws IOException { |
139 | 135 | ||
140 | TempJavaTypeFragmentFiles typeFragmentFiles = null; | 136 | TempJavaTypeFragmentFiles typeFragmentFiles = null; |
... | @@ -156,49 +152,64 @@ public final class JavaFileGeneratorUtils { | ... | @@ -156,49 +152,64 @@ public final class JavaFileGeneratorUtils { |
156 | 152 | ||
157 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { | 153 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { |
158 | return tempJavaFragmentFiles | 154 | return tempJavaFragmentFiles |
159 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAttributesTempFileHandle()); | 155 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAttributesTempFileHandle(), |
156 | + absolutePath); | ||
160 | } else if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) { | 157 | } else if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) { |
161 | return tempJavaFragmentFiles | 158 | return tempJavaFragmentFiles |
162 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getGetterInterfaceTempFileHandle()); | 159 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getGetterInterfaceTempFileHandle(), |
160 | + absolutePath); | ||
163 | } else if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) { | 161 | } else if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) { |
164 | return tempJavaFragmentFiles | 162 | return tempJavaFragmentFiles |
165 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSetterInterfaceTempFileHandle()); | 163 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSetterInterfaceTempFileHandle(), |
164 | + absolutePath); | ||
166 | } else if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) { | 165 | } else if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) { |
167 | return tempJavaFragmentFiles | 166 | return tempJavaFragmentFiles |
168 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getGetterImplTempFileHandle()); | 167 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getGetterImplTempFileHandle(), |
168 | + absolutePath); | ||
169 | } else if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) { | 169 | } else if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) { |
170 | return tempJavaFragmentFiles | 170 | return tempJavaFragmentFiles |
171 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSetterImplTempFileHandle()); | 171 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSetterImplTempFileHandle(), |
172 | + absolutePath); | ||
172 | } else if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) { | 173 | } else if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) { |
173 | if (beanFragmentFiles == null) { | 174 | if (beanFragmentFiles == null) { |
174 | throw new TranslatorException("Required constructor info is missing."); | 175 | throw new TranslatorException("Required constructor info is missing."); |
175 | } | 176 | } |
176 | return beanFragmentFiles | 177 | return beanFragmentFiles |
177 | - .getTemporaryDataFromFileHandle(beanFragmentFiles.getConstructorImplTempFileHandle()); | 178 | + .getTemporaryDataFromFileHandle(beanFragmentFiles.getConstructorImplTempFileHandle(), |
179 | + absolutePath); | ||
178 | } else if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) { | 180 | } else if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) { |
179 | return tempJavaFragmentFiles | 181 | return tempJavaFragmentFiles |
180 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getHashCodeImplTempFileHandle()); | 182 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getHashCodeImplTempFileHandle(), |
183 | + absolutePath); | ||
181 | } else if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) { | 184 | } else if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) { |
182 | return tempJavaFragmentFiles | 185 | return tempJavaFragmentFiles |
183 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getEqualsImplTempFileHandle()); | 186 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getEqualsImplTempFileHandle(), |
187 | + absolutePath); | ||
184 | } else if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) { | 188 | } else if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) { |
185 | return tempJavaFragmentFiles | 189 | return tempJavaFragmentFiles |
186 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getToStringImplTempFileHandle()); | 190 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getToStringImplTempFileHandle(), |
191 | + absolutePath); | ||
192 | + } else if ((generatedTempFiles & AUGMENTE_CLASS_CONSTRUCTOR_MASK) != 0) { | ||
193 | + return tempJavaFragmentFiles | ||
194 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAugmentConstructorImplTempFileHandle(), | ||
195 | + absolutePath); | ||
187 | } else if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) { | 196 | } else if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) { |
188 | if (typeFragmentFiles == null) { | 197 | if (typeFragmentFiles == null) { |
189 | throw new TranslatorException("Required of string implementation info is missing."); | 198 | throw new TranslatorException("Required of string implementation info is missing."); |
190 | } | 199 | } |
191 | return typeFragmentFiles | 200 | return typeFragmentFiles |
192 | - .getTemporaryDataFromFileHandle(typeFragmentFiles.getOfStringImplTempFileHandle()); | 201 | + .getTemporaryDataFromFileHandle(typeFragmentFiles.getOfStringImplTempFileHandle(), absolutePath); |
193 | } else if ((generatedTempFiles & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { | 202 | } else if ((generatedTempFiles & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
194 | if (typeFragmentFiles == null) { | 203 | if (typeFragmentFiles == null) { |
195 | throw new TranslatorException("Required constructor implementation info is missing."); | 204 | throw new TranslatorException("Required constructor implementation info is missing."); |
196 | } | 205 | } |
197 | return typeFragmentFiles | 206 | return typeFragmentFiles |
198 | - .getTemporaryDataFromFileHandle(typeFragmentFiles.getConstructorForTypeTempFileHandle()); | 207 | + .getTemporaryDataFromFileHandle(typeFragmentFiles.getConstructorForTypeTempFileHandle(), |
208 | + absolutePath); | ||
199 | } else if ((generatedTempFiles & FROM_STRING_IMPL_MASK) != 0) { | 209 | } else if ((generatedTempFiles & FROM_STRING_IMPL_MASK) != 0) { |
200 | return tempJavaFragmentFiles | 210 | return tempJavaFragmentFiles |
201 | - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getFromStringImplTempFileHandle()); | 211 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getFromStringImplTempFileHandle(), |
212 | + absolutePath); | ||
202 | } else if ((generatedTempFiles & ENUM_IMPL_MASK) != 0) { | 213 | } else if ((generatedTempFiles & ENUM_IMPL_MASK) != 0) { |
203 | if (!(tempJavaFragmentFiles instanceof TempJavaEnumerationFragmentFiles)) { | 214 | if (!(tempJavaFragmentFiles instanceof TempJavaEnumerationFragmentFiles)) { |
204 | throw new TranslatorException("Required enum info is missing."); | 215 | throw new TranslatorException("Required enum info is missing."); |
... | @@ -206,49 +217,56 @@ public final class JavaFileGeneratorUtils { | ... | @@ -206,49 +217,56 @@ public final class JavaFileGeneratorUtils { |
206 | TempJavaEnumerationFragmentFiles enumFragmentFiles = | 217 | TempJavaEnumerationFragmentFiles enumFragmentFiles = |
207 | (TempJavaEnumerationFragmentFiles) tempJavaFragmentFiles; | 218 | (TempJavaEnumerationFragmentFiles) tempJavaFragmentFiles; |
208 | return enumFragmentFiles | 219 | return enumFragmentFiles |
209 | - .getTemporaryDataFromFileHandle(enumFragmentFiles.getEnumClassTempFileHandle()); | 220 | + .getTemporaryDataFromFileHandle(enumFragmentFiles.getEnumClassTempFileHandle(), absolutePath); |
210 | } else if ((generatedTempFiles & RPC_INTERFACE_MASK) != 0) { | 221 | } else if ((generatedTempFiles & RPC_INTERFACE_MASK) != 0) { |
211 | if (serviceFragmentFiles == null) { | 222 | if (serviceFragmentFiles == null) { |
212 | throw new TranslatorException("Required rpc interface info is missing."); | 223 | throw new TranslatorException("Required rpc interface info is missing."); |
213 | } | 224 | } |
214 | return serviceFragmentFiles | 225 | return serviceFragmentFiles |
215 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getRpcInterfaceTempFileHandle()); | 226 | + .getTemporaryDataFromFileHandle(serviceFragmentFiles.getRpcInterfaceTempFileHandle(), |
227 | + absolutePath); | ||
216 | } else if ((generatedTempFiles & RPC_IMPL_MASK) != 0) { | 228 | } else if ((generatedTempFiles & RPC_IMPL_MASK) != 0) { |
217 | if (serviceFragmentFiles == null) { | 229 | if (serviceFragmentFiles == null) { |
218 | throw new TranslatorException("Required rpc implementation info is missing."); | 230 | throw new TranslatorException("Required rpc implementation info is missing."); |
219 | } | 231 | } |
220 | return serviceFragmentFiles | 232 | return serviceFragmentFiles |
221 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getRpcImplTempFileHandle()); | 233 | + .getTemporaryDataFromFileHandle(serviceFragmentFiles.getRpcImplTempFileHandle(), |
234 | + absolutePath); | ||
222 | } else if ((generatedTempFiles & EVENT_ENUM_MASK) != 0) { | 235 | } else if ((generatedTempFiles & EVENT_ENUM_MASK) != 0) { |
223 | if (serviceFragmentFiles == null) { | 236 | if (serviceFragmentFiles == null) { |
224 | throw new TranslatorException("Required rpc implementation info is missing."); | 237 | throw new TranslatorException("Required rpc implementation info is missing."); |
225 | } | 238 | } |
226 | return serviceFragmentFiles | 239 | return serviceFragmentFiles |
227 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventEnumTempFileHandle()); | 240 | + .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventEnumTempFileHandle(), |
241 | + absolutePath); | ||
228 | } else if ((generatedTempFiles & EVENT_METHOD_MASK) != 0) { | 242 | } else if ((generatedTempFiles & EVENT_METHOD_MASK) != 0) { |
229 | if (serviceFragmentFiles == null) { | 243 | if (serviceFragmentFiles == null) { |
230 | throw new TranslatorException("Required rpc implementation info is missing."); | 244 | throw new TranslatorException("Required rpc implementation info is missing."); |
231 | } | 245 | } |
232 | return serviceFragmentFiles | 246 | return serviceFragmentFiles |
233 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventMethodTempFileHandle()); | 247 | + .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventMethodTempFileHandle(), |
248 | + absolutePath); | ||
234 | } else if ((generatedTempFiles & EVENT_SUBJECT_GETTER_MASK) != 0) { | 249 | } else if ((generatedTempFiles & EVENT_SUBJECT_GETTER_MASK) != 0) { |
235 | if (serviceFragmentFiles == null) { | 250 | if (serviceFragmentFiles == null) { |
236 | throw new TranslatorException("Required rpc implementation info is missing."); | 251 | throw new TranslatorException("Required rpc implementation info is missing."); |
237 | } | 252 | } |
238 | return serviceFragmentFiles | 253 | return serviceFragmentFiles |
239 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectGetterTempFileHandle()); | 254 | + .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectGetterTempFileHandle(), |
255 | + absolutePath); | ||
240 | } else if ((generatedTempFiles & EVENT_SUBJECT_SETTER_MASK) != 0) { | 256 | } else if ((generatedTempFiles & EVENT_SUBJECT_SETTER_MASK) != 0) { |
241 | if (serviceFragmentFiles == null) { | 257 | if (serviceFragmentFiles == null) { |
242 | throw new TranslatorException("Required rpc implementation info is missing."); | 258 | throw new TranslatorException("Required rpc implementation info is missing."); |
243 | } | 259 | } |
244 | return serviceFragmentFiles | 260 | return serviceFragmentFiles |
245 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectSetterTempFileHandle()); | 261 | + .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectSetterTempFileHandle(), |
262 | + absolutePath); | ||
246 | } else if ((generatedTempFiles & EVENT_SUBJECT_ATTRIBUTE_MASK) != 0) { | 263 | } else if ((generatedTempFiles & EVENT_SUBJECT_ATTRIBUTE_MASK) != 0) { |
247 | if (serviceFragmentFiles == null) { | 264 | if (serviceFragmentFiles == null) { |
248 | throw new TranslatorException("Required rpc implementation info is missing."); | 265 | throw new TranslatorException("Required rpc implementation info is missing."); |
249 | } | 266 | } |
250 | return serviceFragmentFiles | 267 | return serviceFragmentFiles |
251 | - .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectAttributeTempFileHandle()); | 268 | + .getTemporaryDataFromFileHandle(serviceFragmentFiles.getEventSubjectAttributeTempFileHandle(), |
269 | + absolutePath); | ||
252 | } | 270 | } |
253 | return null; | 271 | return null; |
254 | } | 272 | } |
... | @@ -291,12 +309,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -291,12 +309,7 @@ public final class JavaFileGeneratorUtils { |
291 | throws IOException { | 309 | throws IOException { |
292 | 310 | ||
293 | try { | 311 | try { |
294 | - if (file.exists()) { | ||
295 | - throw new IOException(file.getName() + " is reused due to YANG naming"); | ||
296 | - } | ||
297 | - | ||
298 | file.createNewFile(); | 312 | file.createNewFile(); |
299 | - | ||
300 | appendContents(file, genType, imports, curNode, className); | 313 | appendContents(file, genType, imports, curNode, className); |
301 | } catch (IOException e) { | 314 | } catch (IOException e) { |
302 | throw new IOException("Failed to create " + file.getName() + " class file."); | 315 | throw new IOException("Failed to create " + file.getName() + " class file."); |
... | @@ -322,6 +335,10 @@ public final class JavaFileGeneratorUtils { | ... | @@ -322,6 +335,10 @@ public final class JavaFileGeneratorUtils { |
322 | String name = javaFileInfo.getJavaName(); | 335 | String name = javaFileInfo.getJavaName(); |
323 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); | 336 | String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); |
324 | 337 | ||
338 | + YangNode augmentedNode = null; | ||
339 | + if (curNode instanceof YangAugment) { | ||
340 | + augmentedNode = ((YangAugment) curNode).getAugmentedNode(); | ||
341 | + } | ||
325 | String pkgString = null; | 342 | String pkgString = null; |
326 | if (genType == GENERATE_EVENT_CLASS | 343 | if (genType == GENERATE_EVENT_CLASS |
327 | || genType == GENERATE_EVENT_LISTENER_INTERFACE | 344 | || genType == GENERATE_EVENT_LISTENER_INTERFACE |
... | @@ -332,9 +349,23 @@ public final class JavaFileGeneratorUtils { | ... | @@ -332,9 +349,23 @@ public final class JavaFileGeneratorUtils { |
332 | } | 349 | } |
333 | switch (genType) { | 350 | switch (genType) { |
334 | case INTERFACE_MASK: | 351 | case INTERFACE_MASK: |
352 | + if (augmentedNode != null) { | ||
353 | + appendHeaderContents(file, pkgString, importsList, augmentedNode); | ||
354 | + } else { | ||
335 | appendHeaderContents(file, pkgString, importsList); | 355 | appendHeaderContents(file, pkgString, importsList); |
356 | + } | ||
336 | write(file, genType, INTERFACE, curNode, className); | 357 | write(file, genType, INTERFACE, curNode, className); |
337 | break; | 358 | break; |
359 | + case IMPL_CLASS_MASK: | ||
360 | + appendHeaderContents(file, pkgString, importsList); | ||
361 | + write(file, genType, IMPL_CLASS, curNode, className); | ||
362 | + break; | ||
363 | + case BUILDER_CLASS_MASK: | ||
364 | + write(file, genType, BUILDER_CLASS, curNode, className); | ||
365 | + break; | ||
366 | + case BUILDER_INTERFACE_MASK: | ||
367 | + write(file, genType, BUILDER_INTERFACE, curNode, className); | ||
368 | + break; | ||
338 | case GENERATE_SERVICE_AND_MANAGER: | 369 | case GENERATE_SERVICE_AND_MANAGER: |
339 | appendHeaderContents(file, pkgString, importsList); | 370 | appendHeaderContents(file, pkgString, importsList); |
340 | write(file, genType, RPC_INTERFACE, curNode, className); | 371 | write(file, genType, RPC_INTERFACE, curNode, className); |
... | @@ -379,20 +410,10 @@ public final class JavaFileGeneratorUtils { | ... | @@ -379,20 +410,10 @@ public final class JavaFileGeneratorUtils { |
379 | String pkgString = parsePackageString(pkg, importsList); | 410 | String pkgString = parsePackageString(pkg, importsList); |
380 | 411 | ||
381 | switch (genType) { | 412 | switch (genType) { |
382 | - case IMPL_CLASS_MASK: | ||
383 | - write(file, fileName, genType, IMPL_CLASS, pluginConfig); | ||
384 | - break; | ||
385 | - case BUILDER_INTERFACE_MASK: | ||
386 | - write(file, fileName, genType, BUILDER_INTERFACE, pluginConfig); | ||
387 | - break; | ||
388 | case GENERATE_TYPEDEF_CLASS: | 413 | case GENERATE_TYPEDEF_CLASS: |
389 | appendHeaderContents(file, pkgString, importsList); | 414 | appendHeaderContents(file, pkgString, importsList); |
390 | write(file, fileName, genType, IMPL_CLASS, pluginConfig); | 415 | write(file, fileName, genType, IMPL_CLASS, pluginConfig); |
391 | break; | 416 | break; |
392 | - case BUILDER_CLASS_MASK: | ||
393 | - appendHeaderContents(file, pkgString, importsList); | ||
394 | - write(file, fileName, genType, BUILDER_CLASS, pluginConfig); | ||
395 | - break; | ||
396 | case GENERATE_UNION_CLASS: | 417 | case GENERATE_UNION_CLASS: |
397 | appendHeaderContents(file, pkgString, importsList); | 418 | appendHeaderContents(file, pkgString, importsList); |
398 | write(file, fileName, genType, IMPL_CLASS, pluginConfig); | 419 | write(file, fileName, genType, IMPL_CLASS, pluginConfig); |
... | @@ -428,7 +449,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -428,7 +449,7 @@ public final class JavaFileGeneratorUtils { |
428 | } | 449 | } |
429 | 450 | ||
430 | /** | 451 | /** |
431 | - * Appends other contents to interface, builder and typedef classes. | 452 | + * Appends other contents to interface, impl and typedef classes. |
432 | * for example : ONOS copyright, imports and package. | 453 | * for example : ONOS copyright, imports and package. |
433 | * | 454 | * |
434 | * @param file generated file | 455 | * @param file generated file |
... | @@ -456,6 +477,39 @@ public final class JavaFileGeneratorUtils { | ... | @@ -456,6 +477,39 @@ public final class JavaFileGeneratorUtils { |
456 | } | 477 | } |
457 | 478 | ||
458 | /** | 479 | /** |
480 | + * Appends other contents to interface and impl classes when augmented node is not null. | ||
481 | + * for example : ONOS copyright, imports and package. | ||
482 | + * | ||
483 | + * @param file generated file | ||
484 | + * @param pkg generated package | ||
485 | + * @param augmentedNode augmented node | ||
486 | + * @param importsList list of imports | ||
487 | + * @throws IOException when fails to append contents | ||
488 | + */ | ||
489 | + private static void appendHeaderContents(File file, String pkg, List<String> importsList, YangNode augmentedNode) | ||
490 | + throws IOException { | ||
491 | + | ||
492 | + insertDataIntoJavaFile(file, CopyrightHeader.getCopyrightHeader()); | ||
493 | + insertDataIntoJavaFile(file, pkg); | ||
494 | + | ||
495 | + /* | ||
496 | + * TODO: add the file header using | ||
497 | + * JavaCodeSnippetGen.getFileHeaderComment | ||
498 | + */ | ||
499 | + | ||
500 | + if (importsList != null) { | ||
501 | + insertDataIntoJavaFile(file, NEW_LINE); | ||
502 | + for (String imports : importsList) { | ||
503 | + if (!imports.contains(getCapitalCase(DEFAULT) + getCapitalCase(getCamelCase(augmentedNode.getName(), | ||
504 | + null))) | ||
505 | + && !imports.contains(getCapitalCase(getCamelCase(augmentedNode.getName(), null)) + BUILDER)) { | ||
506 | + insertDataIntoJavaFile(file, imports); | ||
507 | + } | ||
508 | + } | ||
509 | + } | ||
510 | + } | ||
511 | + | ||
512 | + /** | ||
459 | * Writes data to the specific generated file. | 513 | * Writes data to the specific generated file. |
460 | * | 514 | * |
461 | * @param file generated file | 515 | * @param file generated file |
... | @@ -472,7 +526,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -472,7 +526,7 @@ public final class JavaFileGeneratorUtils { |
472 | if ((genType & GENERATE_SERVICE_AND_MANAGER) != 0) { | 526 | if ((genType & GENERATE_SERVICE_AND_MANAGER) != 0) { |
473 | if (!fileName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) { | 527 | if (!fileName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) { |
474 | insertDataIntoJavaFile(file, getJavaDoc(RPC_MANAGER, fileName, false, pluginConfig)); | 528 | insertDataIntoJavaFile(file, getJavaDoc(RPC_MANAGER, fileName, false, pluginConfig)); |
475 | - insertDataIntoJavaFile(file, addComponentString()); | 529 | + insertDataIntoJavaFile(file, JavaCodeSnippetGen.addComponentString()); |
476 | } else { | 530 | } else { |
477 | insertDataIntoJavaFile(file, getJavaDoc(javaDocType, fileName, false, pluginConfig)); | 531 | insertDataIntoJavaFile(file, getJavaDoc(javaDocType, fileName, false, pluginConfig)); |
478 | } | 532 | } |
... | @@ -499,24 +553,4 @@ public final class JavaFileGeneratorUtils { | ... | @@ -499,24 +553,4 @@ public final class JavaFileGeneratorUtils { |
499 | insertDataIntoJavaFile(file, generateClassDefinition(genType, fileName)); | 553 | insertDataIntoJavaFile(file, generateClassDefinition(genType, fileName)); |
500 | } | 554 | } |
501 | 555 | ||
502 | - /** | ||
503 | - * Returns integer attribute for enum's class to get the values. | ||
504 | - * | ||
505 | - * @param className enum's class name | ||
506 | - * @return enum's attribute | ||
507 | - */ | ||
508 | - public static String getEnumsValueAttribute(String className) { | ||
509 | - return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + INT + SPACE + getSmallCase(className) | ||
510 | - + SEMI_COLAN + NEW_LINE; | ||
511 | - } | ||
512 | - | ||
513 | - /** | ||
514 | - * Returns component string. | ||
515 | - * | ||
516 | - * @return component string | ||
517 | - */ | ||
518 | - public static String addComponentString() { | ||
519 | - return NEW_LINE + COMPONENT_ANNOTATION + SPACE + OPEN_PARENTHESIS + IMMEDIATE + SPACE | ||
520 | - + EQUAL + SPACE + TRUE + CLOSE_PARENTHESIS + NEW_LINE + SERVICE_ANNOTATION; | ||
521 | - } | ||
522 | } | 556 | } | ... | ... |
... | @@ -54,11 +54,8 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirP | ... | @@ -54,11 +54,8 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirP |
54 | */ | 54 | */ |
55 | public final class JavaIdentifierSyntax { | 55 | public final class JavaIdentifierSyntax { |
56 | 56 | ||
57 | - private static final int MAX_MONTHS = 12; | ||
58 | - private static final int MAX_DAYS = 31; | ||
59 | private static final int INDEX_ZERO = 0; | 57 | private static final int INDEX_ZERO = 0; |
60 | private static final int INDEX_ONE = 1; | 58 | private static final int INDEX_ONE = 1; |
61 | - private static final int INDEX_TWO = 2; | ||
62 | private static final int VALUE_CHECK = 10; | 59 | private static final int VALUE_CHECK = 10; |
63 | private static final String ZERO = "0"; | 60 | private static final String ZERO = "0"; |
64 | private static final String DATE_FORMAT = "yyyy-MM-dd"; | 61 | private static final String DATE_FORMAT = "yyyy-MM-dd"; | ... | ... |
... | @@ -32,10 +32,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; | ... | @@ -32,10 +32,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; |
32 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION; | 32 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION; |
33 | import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; | 33 | import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; |
34 | import static org.onosproject.yangutils.utils.UtilConstants.AND; | 34 | import static org.onosproject.yangutils.utils.UtilConstants.AND; |
35 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION; | ||
36 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; | ||
37 | -import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; | ||
38 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL; | 35 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL; |
36 | +import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; | ||
39 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; |
40 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER; |
41 | import static org.onosproject.yangutils.utils.UtilConstants.BUILD; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.BUILD; |
... | @@ -45,7 +43,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER; | ... | @@ -45,7 +43,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER; |
45 | import static org.onosproject.yangutils.utils.UtilConstants.CASE; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.CASE; |
46 | import static org.onosproject.yangutils.utils.UtilConstants.CATCH; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.CATCH; |
47 | import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING; | 45 | import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING; |
48 | -import static org.onosproject.yangutils.utils.UtilConstants.CLEAR; | ||
49 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | 46 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; |
50 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | 47 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
51 | import static org.onosproject.yangutils.utils.UtilConstants.COLAN; | 48 | import static org.onosproject.yangutils.utils.UtilConstants.COLAN; |
... | @@ -72,7 +69,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_M | ... | @@ -72,7 +69,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_M |
72 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; | 69 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; |
73 | import static org.onosproject.yangutils.utils.UtilConstants.HASH_CODE_STRING; | 70 | import static org.onosproject.yangutils.utils.UtilConstants.HASH_CODE_STRING; |
74 | import static org.onosproject.yangutils.utils.UtilConstants.IF; | 71 | import static org.onosproject.yangutils.utils.UtilConstants.IF; |
75 | -import static org.onosproject.yangutils.utils.UtilConstants.IMPL; | ||
76 | import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; | 72 | import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; |
77 | import static org.onosproject.yangutils.utils.UtilConstants.INT; | 73 | import static org.onosproject.yangutils.utils.UtilConstants.INT; |
78 | import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; | 74 | import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; |
... | @@ -122,7 +118,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTA | ... | @@ -122,7 +118,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTA |
122 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; | 118 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; |
123 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; | 119 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
124 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO; | 120 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO; |
125 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
126 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD; | 121 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD; |
127 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR; | 122 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR; |
128 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR; | 123 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR; |
... | @@ -132,6 +127,8 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MAN | ... | @@ -132,6 +127,8 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MAN |
132 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; | 127 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; |
133 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD; | 128 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD; |
134 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; | 129 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; |
130 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForTypeConstructor; | ||
131 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
135 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | 132 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
136 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 133 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
137 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | 134 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
... | @@ -515,39 +512,34 @@ public final class MethodsGenerator { | ... | @@ -515,39 +512,34 @@ public final class MethodsGenerator { |
515 | public static String getConstructorStart(String yangName, YangPluginConfig pluginConfig) { | 512 | public static String getConstructorStart(String yangName, YangPluginConfig pluginConfig) { |
516 | 513 | ||
517 | String javadoc = getConstructorString(yangName, pluginConfig); | 514 | String javadoc = getConstructorString(yangName, pluginConfig); |
518 | - String constructor = | 515 | + String constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + getCapitalCase(DEFAULT) + yangName + |
519 | - FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + IMPL + OPEN_PARENTHESIS + yangName | 516 | + OPEN_PARENTHESIS + yangName + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT |
520 | - + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE | 517 | + + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; |
521 | - + OPEN_CURLY_BRACKET | ||
522 | - + NEW_LINE; | ||
523 | return javadoc + constructor; | 518 | return javadoc + constructor; |
524 | } | 519 | } |
525 | 520 | ||
526 | /** | 521 | /** |
527 | * Returns the constructor strings for class file. | 522 | * Returns the constructor strings for class file. |
528 | * | 523 | * |
529 | - * @param yangName name of the class | ||
530 | * @param attr attribute info | 524 | * @param attr attribute info |
531 | * @param generatedJavaFiles generated java files | 525 | * @param generatedJavaFiles generated java files |
532 | * @param pluginConfig plugin configurations | 526 | * @param pluginConfig plugin configurations |
533 | * @return constructor for class | 527 | * @return constructor for class |
534 | */ | 528 | */ |
535 | - public static String getConstructor(String yangName, JavaAttributeInfo attr, int generatedJavaFiles, | 529 | + public static String getConstructor(JavaAttributeInfo attr, int generatedJavaFiles, |
536 | YangPluginConfig pluginConfig) { | 530 | YangPluginConfig pluginConfig) { |
537 | 531 | ||
538 | String attributeName = attr.getAttributeName(); | 532 | String attributeName = attr.getAttributeName(); |
539 | String constructor; | 533 | String constructor; |
540 | 534 | ||
541 | if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { | 535 | if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { |
542 | - constructor = | 536 | + constructor = EIGHT_SPACE_INDENTATION + THIS + PERIOD |
543 | - EIGHT_SPACE_INDENTATION + THIS + PERIOD | ||
544 | + getCamelCase(attributeName, pluginConfig.getConflictResolver()) + SPACE + EQUAL | 537 | + getCamelCase(attributeName, pluginConfig.getConflictResolver()) + SPACE + EQUAL |
545 | + SPACE + BUILDER.toLowerCase() + OBJECT + PERIOD + GET_METHOD_PREFIX | 538 | + SPACE + BUILDER.toLowerCase() + OBJECT + PERIOD + GET_METHOD_PREFIX |
546 | + getCapitalCase(getCamelCase(attributeName, pluginConfig.getConflictResolver())) | 539 | + getCapitalCase(getCamelCase(attributeName, pluginConfig.getConflictResolver())) |
547 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; | 540 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; |
548 | } else { | 541 | } else { |
549 | - constructor = | 542 | + constructor = EIGHT_SPACE_INDENTATION + THIS + PERIOD |
550 | - EIGHT_SPACE_INDENTATION + THIS + PERIOD | ||
551 | + getCamelCase(attributeName, pluginConfig.getConflictResolver()) + SPACE + EQUAL | 543 | + getCamelCase(attributeName, pluginConfig.getConflictResolver()) + SPACE + EQUAL |
552 | + SPACE + BUILDER.toLowerCase() + OBJECT + PERIOD | 544 | + SPACE + BUILDER.toLowerCase() + OBJECT + PERIOD |
553 | + getCamelCase(attributeName, pluginConfig.getConflictResolver()) + | 545 | + getCamelCase(attributeName, pluginConfig.getConflictResolver()) + |
... | @@ -593,8 +585,7 @@ public final class MethodsGenerator { | ... | @@ -593,8 +585,7 @@ public final class MethodsGenerator { |
593 | inputName = inputName + SPACE + RPC_INPUT_VAR_NAME; | 585 | inputName = inputName + SPACE + RPC_INPUT_VAR_NAME; |
594 | } | 586 | } |
595 | 587 | ||
596 | - String method = | 588 | + String method = getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + outputName + SPACE + rpcName |
597 | - getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + outputName + SPACE + rpcName | ||
598 | + OPEN_PARENTHESIS + inputName + CLOSE_PARENTHESIS + SPACE | 589 | + OPEN_PARENTHESIS + inputName + CLOSE_PARENTHESIS + SPACE |
599 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + YANG_UTILS_TODO + NEW_LINE; | 590 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + YANG_UTILS_TODO + NEW_LINE; |
600 | if (!outputName.contentEquals(VOID)) { | 591 | if (!outputName.contentEquals(VOID)) { |
... | @@ -614,9 +605,9 @@ public final class MethodsGenerator { | ... | @@ -614,9 +605,9 @@ public final class MethodsGenerator { |
614 | */ | 605 | */ |
615 | public static String getBuild(String yangName) { | 606 | public static String getBuild(String yangName) { |
616 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + SPACE + BUILD + OPEN_PARENTHESIS + CLOSE_PARENTHESIS | 607 | return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + SPACE + BUILD + OPEN_PARENTHESIS + CLOSE_PARENTHESIS |
617 | - + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE + NEW + SPACE | 608 | + + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + RETURN + SPACE + NEW + SPACE + |
618 | - + yangName + IMPL + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE | 609 | + getCapitalCase(DEFAULT) + yangName + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS + SEMI_COLAN |
619 | - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | 610 | + + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
620 | } | 611 | } |
621 | 612 | ||
622 | /** | 613 | /** |
... | @@ -950,59 +941,12 @@ public final class MethodsGenerator { | ... | @@ -950,59 +941,12 @@ public final class MethodsGenerator { |
950 | } | 941 | } |
951 | 942 | ||
952 | /** | 943 | /** |
953 | - * Returns implementation of add augmentation method of AugmentationHolder class. | ||
954 | - * | ||
955 | - * @return implementation of add augmentation method of AugmentationHolder class | ||
956 | - */ | ||
957 | - public static String getAddAugmentInfoMethodImpl() { | ||
958 | - String method = FOUR_SPACE_INDENTATION; | ||
959 | - method = method + getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + ADD_STRING | ||
960 | - + AUGMENTATION + OPEN_PARENTHESIS + AUGMENTED_INFO + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE | ||
961 | - + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + GET_METHOD_PREFIX + AUGMENTED_INFO + LIST | ||
962 | - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + ADD_STRING + OPEN_PARENTHESIS + VALUE | ||
963 | - + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | ||
964 | - | ||
965 | - return method; | ||
966 | - } | ||
967 | - | ||
968 | - /** | ||
969 | - * Returns implementation of get augment info list method of AugmentationHolder class. | ||
970 | - * | ||
971 | - * @return implementation of get augment info list method of AugmentationHolder class | ||
972 | - */ | ||
973 | - public static String getAugmentInfoListImpl() { | ||
974 | - | ||
975 | - String method = FOUR_SPACE_INDENTATION; | ||
976 | - method = method + getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + LIST + DIAMOND_OPEN_BRACKET | ||
977 | - + AUGMENTED_INFO + DIAMOND_CLOSE_BRACKET + SPACE + GET_METHOD_PREFIX + AUGMENTED_INFO + LIST | ||
978 | - + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION | ||
979 | - + RETURN + SPACE + getSmallCase(AUGMENTED_INFO) + LIST + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION | ||
980 | - + CLOSE_CURLY_BRACKET; | ||
981 | - return method; | ||
982 | - } | ||
983 | - | ||
984 | - /** | ||
985 | - * Returns implementation of remove augmentation method of AugmentationHolder class. | ||
986 | - * | ||
987 | - * @return implementation of remove augmentation method of AugmentationHolder class | ||
988 | - */ | ||
989 | - public static String getRemoveAugmentationImpl() { | ||
990 | - String method = FOUR_SPACE_INDENTATION; | ||
991 | - method = method + getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + "remove" | ||
992 | - + AUGMENTATION + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE | ||
993 | - + EIGHT_SPACE_INDENTATION + GET_METHOD_PREFIX + AUGMENTED_INFO + LIST + OPEN_PARENTHESIS | ||
994 | - + CLOSE_PARENTHESIS + PERIOD + CLEAR + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE | ||
995 | - + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | ||
996 | - return method; | ||
997 | - } | ||
998 | - | ||
999 | - /** | ||
1000 | * Returns enum's constructor. | 944 | * Returns enum's constructor. |
1001 | * | 945 | * |
1002 | * @param className enum's class name | 946 | * @param className enum's class name |
1003 | * @return enum's constructor | 947 | * @return enum's constructor |
1004 | */ | 948 | */ |
1005 | - public static String getEnumsConstrcutor(String className) { | 949 | + public static String getEnumsConstructor(String className) { |
1006 | return FOUR_SPACE_INDENTATION + className + OPEN_PARENTHESIS + INT + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE | 950 | return FOUR_SPACE_INDENTATION + className + OPEN_PARENTHESIS + INT + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE |
1007 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(className) + SPACE + EQUAL | 951 | + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + getSmallCase(className) + SPACE + EQUAL |
1008 | + SPACE + VALUE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; | 952 | + SPACE + VALUE + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; |
... | @@ -1118,4 +1062,38 @@ public final class MethodsGenerator { | ... | @@ -1118,4 +1062,38 @@ public final class MethodsGenerator { |
1118 | throw new TranslatorException("given data type is not supported."); | 1062 | throw new TranslatorException("given data type is not supported."); |
1119 | } | 1063 | } |
1120 | } | 1064 | } |
1065 | + | ||
1066 | + /** | ||
1067 | + * Returns copy constructor for augmented class. | ||
1068 | + * | ||
1069 | + * @param yangName augmente class name | ||
1070 | + * @param augmentName augmented class name | ||
1071 | + * @return copy constructor for augmented class | ||
1072 | + */ | ||
1073 | + public static String getAugmentedNodesConstructorStart(String yangName, | ||
1074 | + String augmentName) { | ||
1075 | + | ||
1076 | + String javadoc = generateForTypeConstructor(yangName); | ||
1077 | + String constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + yangName + BUILDER + OPEN_PARENTHESIS | ||
1078 | + + augmentName + PERIOD + augmentName + BUILDER + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE | ||
1079 | + + OPEN_CURLY_BRACKET + NEW_LINE; | ||
1080 | + return javadoc + constructor; | ||
1081 | + | ||
1082 | + } | ||
1083 | + | ||
1084 | + /** | ||
1085 | + * Returns the constructor strings for class file. | ||
1086 | + * | ||
1087 | + * @param attr attribute info | ||
1088 | + * @param pluginConfig plugin configurations | ||
1089 | + * @return constructor for class | ||
1090 | + */ | ||
1091 | + public static String getAugmentedConstructor(JavaAttributeInfo attr, YangPluginConfig pluginConfig) { | ||
1092 | + | ||
1093 | + String attributeName = getCamelCase(attr.getAttributeName(), pluginConfig.getConflictResolver()); | ||
1094 | + | ||
1095 | + return EIGHT_SPACE_INDENTATION + THIS + PERIOD + attributeName + OPEN_PARENTHESIS | ||
1096 | + + VALUE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS | ||
1097 | + + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; | ||
1098 | + } | ||
1121 | } | 1099 | } | ... | ... |
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.utils; | ||
18 | - | ||
19 | -import java.io.File; | ||
20 | -import java.io.IOException; | ||
21 | -import java.util.List; | ||
22 | -import org.onosproject.yangutils.datamodel.YangNode; | ||
23 | -import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | ||
24 | -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | ||
25 | -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | ||
26 | -import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; | ||
27 | - | ||
28 | -import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION_IMPORT; | ||
29 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION_HOLDER; | ||
30 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; | ||
31 | -import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION_IMPORT; | ||
32 | -import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE_ANNOTATION_IMPORT; | ||
33 | -import static org.onosproject.yangutils.utils.UtilConstants.ENUM; | ||
34 | -import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | ||
35 | -import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; | ||
36 | -import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_FACTORY_IMPORT; | ||
37 | -import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT; | ||
38 | -import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | ||
39 | -import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; | ||
40 | -import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; | ||
41 | -import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_IMPORT; | ||
42 | -import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | ||
43 | -import static org.onosproject.yangutils.utils.UtilConstants.TYPE; | ||
44 | -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; | ||
45 | -import static java.util.Collections.sort; | ||
46 | - | ||
47 | -/** | ||
48 | - * Represents utilities for temporary java code fragments. | ||
49 | - */ | ||
50 | -public final class TempJavaCodeFragmentFilesUtils { | ||
51 | - | ||
52 | - /** | ||
53 | - * Creates a private instance of temporary java code fragment utils. | ||
54 | - */ | ||
55 | - private TempJavaCodeFragmentFilesUtils() { | ||
56 | - } | ||
57 | - | ||
58 | - /** | ||
59 | - * Adds import for AugmentationHolders class. | ||
60 | - * | ||
61 | - * @param curNode current YANG node | ||
62 | - * @param imports list of imports | ||
63 | - * @param operation add or delete import | ||
64 | - */ | ||
65 | - public static void addAugmentationHoldersImport(YangNode curNode, List<String> imports, boolean operation) { | ||
66 | - String thisImport = getTempJavaFragement(curNode).getJavaImportData().getAugmentationHolderImport(); | ||
67 | - performOperationOnImports(imports, thisImport, operation); | ||
68 | - } | ||
69 | - | ||
70 | - /** | ||
71 | - * Adds import for AugmentedInfo class. | ||
72 | - * | ||
73 | - * @param curNode current YANG node | ||
74 | - * @param imports list of imports | ||
75 | - * @param operation add or delete import | ||
76 | - */ | ||
77 | - public static void addAugmentedInfoImport(YangNode curNode, List<String> imports, boolean operation) { | ||
78 | - String thisImport = getTempJavaFragement(curNode).getJavaImportData().getAugmentedInfoImport(); | ||
79 | - performOperationOnImports(imports, thisImport, operation); | ||
80 | - } | ||
81 | - | ||
82 | - /** | ||
83 | - * Returns temp java fragment. | ||
84 | - * | ||
85 | - * @param curNode current YANG node | ||
86 | - * @return temp java fragments | ||
87 | - */ | ||
88 | - public static TempJavaFragmentFiles getTempJavaFragement(YangNode curNode) { | ||
89 | - TempJavaCodeFragmentFiles container = ((TempJavaCodeFragmentFilesContainer) curNode) | ||
90 | - .getTempJavaCodeFragmentFiles(); | ||
91 | - if (container.getBeanTempFiles() != null) { | ||
92 | - return container.getBeanTempFiles(); | ||
93 | - } | ||
94 | - if (container.getServiceTempFiles() != null) { | ||
95 | - return container.getServiceTempFiles(); | ||
96 | - } | ||
97 | - | ||
98 | - return null; | ||
99 | - } | ||
100 | - | ||
101 | - /** | ||
102 | - * Adds import for array list. | ||
103 | - * | ||
104 | - * @param curNode current YANG node | ||
105 | - * @param imports list of imports | ||
106 | - * @param operation add or delete import | ||
107 | - */ | ||
108 | - public static void addArrayListImport(YangNode curNode, List<String> imports, boolean operation) { | ||
109 | - String arrayListImport = getTempJavaFragement(curNode).getJavaImportData().getImportForArrayList(); | ||
110 | - String listImport = getTempJavaFragement(curNode).getJavaImportData().getImportForList(); | ||
111 | - performOperationOnImports(imports, arrayListImport, operation); | ||
112 | - if (!imports.contains(listImport)) { | ||
113 | - /** | ||
114 | - * List can be there because of attribute also , so no need to remove it and operation will | ||
115 | - * always be add(true). | ||
116 | - */ | ||
117 | - performOperationOnImports(imports, listImport, true); | ||
118 | - } | ||
119 | - } | ||
120 | - | ||
121 | - /** | ||
122 | - * Adds listener's imports. | ||
123 | - * | ||
124 | - * @param curNode currentYangNode. | ||
125 | - * @param imports import list | ||
126 | - * @param operation add or remove | ||
127 | - * @param classInfo class info to be added to import list | ||
128 | - */ | ||
129 | - public static void addListnersImport(YangNode curNode, List<String> imports, boolean operation, | ||
130 | - String classInfo) { | ||
131 | - String thisImport = ""; | ||
132 | - if (classInfo.equals(LISTENER_SERVICE)) { | ||
133 | - thisImport = getTempJavaFragement(curNode).getJavaImportData().getListenerServiceImport(); | ||
134 | - performOperationOnImports(imports, thisImport, operation); | ||
135 | - } else { | ||
136 | - thisImport = getTempJavaFragement(curNode).getJavaImportData().getListenerRegistryImport(); | ||
137 | - performOperationOnImports(imports, thisImport, operation); | ||
138 | - } | ||
139 | - } | ||
140 | - | ||
141 | - /** | ||
142 | - * Adds annotations imports. | ||
143 | - * | ||
144 | - * @param imports list if imports | ||
145 | - * @param operation to add or to delete | ||
146 | - */ | ||
147 | - public static void addAnnotationsImports(List<String> imports, boolean operation) { | ||
148 | - if (operation) { | ||
149 | - imports.add(ACTIVATE_ANNOTATION_IMPORT); | ||
150 | - imports.add(DEACTIVATE_ANNOTATION_IMPORT); | ||
151 | - imports.add(COMPONENT_ANNOTATION_IMPORT); | ||
152 | - imports.add(SERVICE_ANNOTATION_IMPORT); | ||
153 | - imports.add(LOGGER_FACTORY_IMPORT); | ||
154 | - imports.add(LOGGER_IMPORT); | ||
155 | - } else { | ||
156 | - imports.remove(ACTIVATE_ANNOTATION_IMPORT); | ||
157 | - imports.remove(DEACTIVATE_ANNOTATION_IMPORT); | ||
158 | - imports.remove(COMPONENT_ANNOTATION_IMPORT); | ||
159 | - imports.remove(SERVICE_ANNOTATION_IMPORT); | ||
160 | - imports.remove(LOGGER_FACTORY_IMPORT); | ||
161 | - imports.remove(LOGGER_IMPORT); | ||
162 | - } | ||
163 | - sortImports(imports); | ||
164 | - } | ||
165 | - | ||
166 | - /** | ||
167 | - * Performs given operations on import list. | ||
168 | - * | ||
169 | - * @param imports list of imports | ||
170 | - * @param curImport current import | ||
171 | - * @param operation add or remove | ||
172 | - * @return import list | ||
173 | - */ | ||
174 | - private static List<String> performOperationOnImports(List<String> imports, String curImport, | ||
175 | - boolean operation) { | ||
176 | - if (operation) { | ||
177 | - imports.add(curImport); | ||
178 | - } else { | ||
179 | - imports.remove(curImport); | ||
180 | - } | ||
181 | - sortImports(imports); | ||
182 | - return imports; | ||
183 | - } | ||
184 | - | ||
185 | - /** | ||
186 | - * Returns true if AugmentationHolder class needs to be extended. | ||
187 | - * | ||
188 | - * @param extendsList list of classes need to be extended | ||
189 | - * @return true or false | ||
190 | - */ | ||
191 | - public static boolean isAugmentationHolderExtended(List<JavaQualifiedTypeInfo> extendsList) { | ||
192 | - for (JavaQualifiedTypeInfo info : extendsList) { | ||
193 | - return info.getClassInfo().equals(AUGMENTATION_HOLDER); | ||
194 | - } | ||
195 | - return false; | ||
196 | - } | ||
197 | - | ||
198 | - /** | ||
199 | - * Returns true if AugmentedInfo class needs to be extended. | ||
200 | - * | ||
201 | - * @param extendsList list of classes need to be extended | ||
202 | - * @return true or false | ||
203 | - */ | ||
204 | - public static boolean isAugmentedInfoExtended(List<JavaQualifiedTypeInfo> extendsList) { | ||
205 | - for (JavaQualifiedTypeInfo info : extendsList) { | ||
206 | - return info.getClassInfo().equals(AUGMENTED_INFO); | ||
207 | - } | ||
208 | - return false; | ||
209 | - } | ||
210 | - | ||
211 | - /** | ||
212 | - * Closes the file handle for temporary file. | ||
213 | - * | ||
214 | - * @param file file to be closed | ||
215 | - * @param toBeDeleted flag to indicate if file needs to be deleted | ||
216 | - * @throws IOException when failed to close the file handle | ||
217 | - */ | ||
218 | - public static void closeFile(File file, boolean toBeDeleted) | ||
219 | - throws IOException { | ||
220 | - | ||
221 | - if (file != null) { | ||
222 | - updateFileHandle(file, null, true); | ||
223 | - if (toBeDeleted) { | ||
224 | - file.delete(); | ||
225 | - } | ||
226 | - } | ||
227 | - } | ||
228 | - | ||
229 | - /** | ||
230 | - * Returns sorted import list. | ||
231 | - * | ||
232 | - * @param imports import list | ||
233 | - * @return sorted import list | ||
234 | - */ | ||
235 | - public static List<String> sortImports(List<String> imports) { | ||
236 | - sort(imports); | ||
237 | - return imports; | ||
238 | - } | ||
239 | - | ||
240 | - /** | ||
241 | - * Returns event enum start. | ||
242 | - * | ||
243 | - * @return event enum start | ||
244 | - */ | ||
245 | - public static String getEventEnumTypeStart() { | ||
246 | - return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + ENUM + SPACE + TYPE + SPACE + OPEN_CURLY_BRACKET | ||
247 | - + NEW_LINE; | ||
248 | - } | ||
249 | -} |
... | @@ -607,6 +607,11 @@ public final class UtilConstants { | ... | @@ -607,6 +607,11 @@ public final class UtilConstants { |
607 | public static final String CATCH = "catch"; | 607 | public static final String CATCH = "catch"; |
608 | 608 | ||
609 | /** | 609 | /** |
610 | + * Static attribute for super syntax. | ||
611 | + */ | ||
612 | + public static final String SUPER = "super"; | ||
613 | + | ||
614 | + /** | ||
610 | * Static attribute for eight space indentation. | 615 | * Static attribute for eight space indentation. |
611 | */ | 616 | */ |
612 | public static final String EIGHT_SPACE_INDENTATION = FOUR_SPACE_INDENTATION + FOUR_SPACE_INDENTATION; | 617 | public static final String EIGHT_SPACE_INDENTATION = FOUR_SPACE_INDENTATION + FOUR_SPACE_INDENTATION; | ... | ... |
... | @@ -123,4 +123,22 @@ public final class FileSystemUtil { | ... | @@ -123,4 +123,22 @@ public final class FileSystemUtil { |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | + | ||
127 | + /** | ||
128 | + * Closes the file handle for temporary file. | ||
129 | + * | ||
130 | + * @param file file to be closed | ||
131 | + * @param toBeDeleted flag to indicate if file needs to be deleted | ||
132 | + * @throws IOException when failed to close the file handle | ||
133 | + */ | ||
134 | + public static void closeFile(File file, boolean toBeDeleted) | ||
135 | + throws IOException { | ||
136 | + | ||
137 | + if (file != null) { | ||
138 | + updateFileHandle(file, null, true); | ||
139 | + if (toBeDeleted) { | ||
140 | + file.delete(); | ||
141 | + } | ||
142 | + } | ||
143 | + } | ||
126 | } | 144 | } | ... | ... |
... | @@ -590,7 +590,7 @@ public final class JavaDocGen { | ... | @@ -590,7 +590,7 @@ public final class JavaDocGen { |
590 | * @param attribute attribute string | 590 | * @param attribute attribute string |
591 | * @return javaDocs for type constructor | 591 | * @return javaDocs for type constructor |
592 | */ | 592 | */ |
593 | - private static String generateForTypeConstructor(String attribute) { | 593 | + public static String generateForTypeConstructor(String attribute) { |
594 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR | 594 | return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR |
595 | + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION | 595 | + attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION |
596 | + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE | 596 | + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE | ... | ... |
... | @@ -28,11 +28,11 @@ import java.util.LinkedList; | ... | @@ -28,11 +28,11 @@ import java.util.LinkedList; |
28 | import java.util.List; | 28 | import java.util.List; |
29 | import java.util.Stack; | 29 | import java.util.Stack; |
30 | import java.util.regex.Pattern; | 30 | import java.util.regex.Pattern; |
31 | + | ||
31 | import org.apache.commons.io.FileUtils; | 32 | import org.apache.commons.io.FileUtils; |
32 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 33 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
33 | 34 | ||
34 | import static org.onosproject.yangutils.utils.UtilConstants.COLAN; | 35 | import static org.onosproject.yangutils.utils.UtilConstants.COLAN; |
35 | -import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | ||
36 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 36 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
37 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; |
38 | import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; |
... | @@ -213,34 +213,16 @@ public final class YangIoUtils { | ... | @@ -213,34 +213,16 @@ public final class YangIoUtils { |
213 | * Removes extra char from the string. | 213 | * Removes extra char from the string. |
214 | * | 214 | * |
215 | * @param valueString string to be trimmed | 215 | * @param valueString string to be trimmed |
216 | - * @param removealStirng extra chars | 216 | + * @param removalStirng extra chars |
217 | * @return new string | 217 | * @return new string |
218 | */ | 218 | */ |
219 | - public static String trimAtLast(String valueString, String removealStirng) { | 219 | + public static String trimAtLast(String valueString, String removalStirng) { |
220 | StringBuilder stringBuilder = new StringBuilder(valueString); | 220 | StringBuilder stringBuilder = new StringBuilder(valueString); |
221 | - int index = valueString.lastIndexOf(removealStirng); | 221 | + int index = valueString.lastIndexOf(removalStirng); |
222 | + if (index != -1) { | ||
222 | stringBuilder.deleteCharAt(index); | 223 | stringBuilder.deleteCharAt(index); |
223 | - return stringBuilder.toString(); | ||
224 | - } | ||
225 | - | ||
226 | - /** | ||
227 | - * Returns new parted string. | ||
228 | - * | ||
229 | - * @param partString string to be parted | ||
230 | - * @return parted string | ||
231 | - */ | ||
232 | - public static String partString(String partString) { | ||
233 | - String[] strArray = partString.split(COMMA); | ||
234 | - String newString = EMPTY_STRING; | ||
235 | - for (int i = 0; i < strArray.length; i++) { | ||
236 | - if (i % 4 != 0 || i == 0) { | ||
237 | - newString = newString + strArray[i] + COMMA; | ||
238 | - } else { | ||
239 | - newString = newString + NEW_LINE + TWELVE_SPACE_INDENTATION | ||
240 | - + strArray[i] + COMMA; | ||
241 | } | 224 | } |
242 | - } | 225 | + return stringBuilder.toString(); |
243 | - return trimAtLast(newString, COMMA); | ||
244 | } | 226 | } |
245 | 227 | ||
246 | /** | 228 | /** | ... | ... |
... | @@ -27,6 +27,11 @@ public final class YangPluginConfig { | ... | @@ -27,6 +27,11 @@ public final class YangPluginConfig { |
27 | private String codeGenDir; | 27 | private String codeGenDir; |
28 | 28 | ||
29 | /** | 29 | /** |
30 | + * Contains the code generation directory. | ||
31 | + */ | ||
32 | + private String managerCodeGenDir; | ||
33 | + | ||
34 | + /** | ||
30 | * Contains information of naming conflicts that can be resolved. | 35 | * Contains information of naming conflicts that can be resolved. |
31 | */ | 36 | */ |
32 | private YangToJavaNamingConflictUtil conflictResolver; | 37 | private YangToJavaNamingConflictUtil conflictResolver; |
... | @@ -72,4 +77,22 @@ public final class YangPluginConfig { | ... | @@ -72,4 +77,22 @@ public final class YangPluginConfig { |
72 | public YangToJavaNamingConflictUtil getConflictResolver() { | 77 | public YangToJavaNamingConflictUtil getConflictResolver() { |
73 | return conflictResolver; | 78 | return conflictResolver; |
74 | } | 79 | } |
80 | + | ||
81 | + /** | ||
82 | + * Returns manager's code generation directory. | ||
83 | + * | ||
84 | + * @return manager's code generation directory | ||
85 | + */ | ||
86 | + public String getManagerCodeGenDir() { | ||
87 | + return managerCodeGenDir; | ||
88 | + } | ||
89 | + | ||
90 | + /** | ||
91 | + * Sets manager's code generation directory. | ||
92 | + * | ||
93 | + * @param moduleCodeGenDir manager's code generation directory | ||
94 | + */ | ||
95 | + public void setManagerCodeGenDir(String moduleCodeGenDir) { | ||
96 | + this.managerCodeGenDir = moduleCodeGenDir; | ||
97 | + } | ||
75 | } | 98 | } | ... | ... |
... | @@ -16,16 +16,16 @@ | ... | @@ -16,16 +16,16 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.ietfyang; | 17 | package org.onosproject.yangutils.ietfyang; |
18 | 18 | ||
19 | +import java.io.IOException; | ||
20 | + | ||
19 | import org.apache.maven.plugin.MojoExecutionException; | 21 | import org.apache.maven.plugin.MojoExecutionException; |
20 | import org.junit.Test; | 22 | import org.junit.Test; |
21 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; | 23 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; |
22 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
23 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 25 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
24 | import org.onosproject.yangutils.plugin.manager.YangUtilManager; | 26 | import org.onosproject.yangutils.plugin.manager.YangUtilManager; |
25 | -import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
26 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | 27 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
27 | - | 28 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
28 | -import java.io.IOException; | ||
29 | 29 | ||
30 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 30 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; |
31 | 31 | ||
... | @@ -54,6 +54,7 @@ public class IetfYangFileTest { | ... | @@ -54,6 +54,7 @@ public class IetfYangFileTest { |
54 | String userDir = System.getProperty("user.dir"); | 54 | String userDir = System.getProperty("user.dir"); |
55 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 55 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
56 | yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/"); | 56 | yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/"); |
57 | + yangPluginConfig.setManagerCodeGenDir("target/ietfyang/l3vpnservice/"); | ||
57 | 58 | ||
58 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 59 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); |
59 | 60 | ... | ... |
... | @@ -20,12 +20,12 @@ import java.io.IOException; | ... | @@ -20,12 +20,12 @@ import java.io.IOException; |
20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
21 | 21 | ||
22 | import org.junit.Test; | 22 | import org.junit.Test; |
23 | -import org.onosproject.yangutils.datamodel.YangNode; | 23 | +import org.onosproject.yangutils.datamodel.YangAtomicPath; |
24 | -import org.onosproject.yangutils.datamodel.YangModule; | ||
25 | import org.onosproject.yangutils.datamodel.YangAugment; | 24 | import org.onosproject.yangutils.datamodel.YangAugment; |
26 | -import org.onosproject.yangutils.datamodel.YangLeaf; | ||
27 | -import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
28 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | 25 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; |
26 | +import org.onosproject.yangutils.datamodel.YangLeaf; | ||
27 | +import org.onosproject.yangutils.datamodel.YangModule; | ||
28 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
29 | import org.onosproject.yangutils.datamodel.YangNodeType; | 29 | import org.onosproject.yangutils.datamodel.YangNodeType; |
30 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 30 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
31 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 31 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
... | @@ -48,16 +48,16 @@ public class AugmentListenerTest { | ... | @@ -48,16 +48,16 @@ public class AugmentListenerTest { |
48 | 48 | ||
49 | YangNode node = manager.getDataModel("src/test/resources/ValidAugmentStatement.yang"); | 49 | YangNode node = manager.getDataModel("src/test/resources/ValidAugmentStatement.yang"); |
50 | 50 | ||
51 | - assertThat((node instanceof YangModule), is(true)); | 51 | + assertThat(node instanceof YangModule, is(true)); |
52 | assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); | 52 | assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); |
53 | YangModule yangNode = (YangModule) node; | 53 | YangModule yangNode = (YangModule) node; |
54 | assertThat(yangNode.getName(), is("Test")); | 54 | assertThat(yangNode.getName(), is("Test")); |
55 | 55 | ||
56 | YangAugment yangAugment = (YangAugment) yangNode.getChild(); | 56 | YangAugment yangAugment = (YangAugment) yangNode.getChild(); |
57 | - ListIterator<YangNodeIdentifier> nodeIdentifierIterator = yangAugment.getTargetNode().listIterator(); | 57 | + ListIterator<YangAtomicPath> absPathIterator = yangAugment.getTargetNode().listIterator(); |
58 | - YangNodeIdentifier yangNodeIdentifier = nodeIdentifierIterator.next(); | 58 | + YangAtomicPath absPathIdentifier = absPathIterator.next(); |
59 | - assertThat(yangNodeIdentifier.getPrefix(), is("if")); | 59 | + assertThat(absPathIdentifier.getNodeIdentifier().getPrefix(), is("if")); |
60 | - assertThat(yangNodeIdentifier.getName(), is("interfaces")); | 60 | + assertThat(absPathIdentifier.getNodeIdentifier().getName(), is("interfaces")); |
61 | 61 | ||
62 | ListIterator<YangLeaf> leafIterator = yangAugment.getListOfLeaf().listIterator(); | 62 | ListIterator<YangLeaf> leafIterator = yangAugment.getListOfLeaf().listIterator(); |
63 | YangLeaf leafInfo = leafIterator.next(); | 63 | YangLeaf leafInfo = leafIterator.next(); | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.plugin.manager; | ||
18 | + | ||
19 | +import java.io.IOException; | ||
20 | + | ||
21 | +import org.apache.maven.plugin.MojoExecutionException; | ||
22 | +import org.junit.Test; | ||
23 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
24 | +import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | ||
25 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
26 | + | ||
27 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test case for augment translator. | ||
31 | + */ | ||
32 | +public class AugmentTranslatorTest { | ||
33 | + | ||
34 | + private final YangUtilManager utilManager = new YangUtilManager(); | ||
35 | + | ||
36 | + /** | ||
37 | + * Checks augment translation should not result in any exception. | ||
38 | + * | ||
39 | + * @throws MojoExecutionException | ||
40 | + */ | ||
41 | + @Test | ||
42 | + public void processAugmentTranslator() throws IOException, ParserException, MojoExecutionException { | ||
43 | + | ||
44 | + String searchDir = "src/test/resources/augmentTranslator"; | ||
45 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | ||
46 | + utilManager.parseYangFileInfoSet(); | ||
47 | + utilManager.createYangNodeSet(); | ||
48 | + utilManager.resolveDependenciesUsingLinker(); | ||
49 | + | ||
50 | + YangPluginConfig yangPluginConfig = new YangPluginConfig(); | ||
51 | + yangPluginConfig.setCodeGenDir("target/augmentTranslator/"); | ||
52 | + yangPluginConfig.setManagerCodeGenDir("target/augmentTranslator/"); | ||
53 | + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | ||
54 | + | ||
55 | + deleteDirectory("target/augmentTranslator/"); | ||
56 | + } | ||
57 | + | ||
58 | +} |
... | @@ -44,6 +44,7 @@ public final class ChoiceCaseTranslatorTest { | ... | @@ -44,6 +44,7 @@ public final class ChoiceCaseTranslatorTest { |
44 | 44 | ||
45 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 45 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
46 | yangPluginConfig.setCodeGenDir("target/ChoiceCaseTestGenFile/"); | 46 | yangPluginConfig.setCodeGenDir("target/ChoiceCaseTestGenFile/"); |
47 | + yangPluginConfig.setManagerCodeGenDir("target/ChoiceCaseTestGenFile/"); | ||
47 | 48 | ||
48 | generateJavaCode(node, yangPluginConfig); | 49 | generateJavaCode(node, yangPluginConfig); |
49 | 50 | ... | ... |
... | @@ -45,6 +45,7 @@ public final class EnumTranslatorTest { | ... | @@ -45,6 +45,7 @@ public final class EnumTranslatorTest { |
45 | 45 | ||
46 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 46 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
47 | yangPluginConfig.setCodeGenDir("target/EnumTestGenFile/"); | 47 | yangPluginConfig.setCodeGenDir("target/EnumTestGenFile/"); |
48 | + yangPluginConfig.setManagerCodeGenDir("target/EnumTestGenFile/"); | ||
48 | 49 | ||
49 | generateJavaCode(node, yangPluginConfig); | 50 | generateJavaCode(node, yangPluginConfig); |
50 | 51 | ... | ... |
... | @@ -19,6 +19,7 @@ package org.onosproject.yangutils.plugin.manager; | ... | @@ -19,6 +19,7 @@ package org.onosproject.yangutils.plugin.manager; |
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | import java.util.Iterator; | 20 | import java.util.Iterator; |
21 | import java.util.ListIterator; | 21 | import java.util.ListIterator; |
22 | + | ||
22 | import org.apache.maven.plugin.MojoExecutionException; | 23 | import org.apache.maven.plugin.MojoExecutionException; |
23 | import org.junit.Rule; | 24 | import org.junit.Rule; |
24 | import org.junit.Test; | 25 | import org.junit.Test; |
... | @@ -171,7 +172,7 @@ public class InterFileLinkingTest { | ... | @@ -171,7 +172,7 @@ public class InterFileLinkingTest { |
171 | } | 172 | } |
172 | 173 | ||
173 | // Check whether the data model tree returned is of type module. | 174 | // Check whether the data model tree returned is of type module. |
174 | - assertThat((selfNode instanceof YangModule), is(true)); | 175 | + assertThat(selfNode instanceof YangModule, is(true)); |
175 | 176 | ||
176 | // Check whether the node type is set properly to module. | 177 | // Check whether the node type is set properly to module. |
177 | assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE)); | 178 | assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE)); |
... | @@ -184,7 +185,7 @@ public class InterFileLinkingTest { | ... | @@ -184,7 +185,7 @@ public class InterFileLinkingTest { |
184 | YangLeaf leafInfo; | 185 | YangLeaf leafInfo; |
185 | 186 | ||
186 | // Check whether grouping is the sibling of module's child. | 187 | // Check whether grouping is the sibling of module's child. |
187 | - assertThat((refNode.getChild() instanceof YangGrouping), is(true)); | 188 | + assertThat(refNode.getChild() instanceof YangGrouping, is(true)); |
188 | 189 | ||
189 | YangGrouping grouping = (YangGrouping) refNode.getChild(); | 190 | YangGrouping grouping = (YangGrouping) refNode.getChild(); |
190 | leafIterator = grouping.getListOfLeaf().listIterator(); | 191 | leafIterator = grouping.getListOfLeaf().listIterator(); |
... | @@ -196,7 +197,7 @@ public class InterFileLinkingTest { | ... | @@ -196,7 +197,7 @@ public class InterFileLinkingTest { |
196 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 197 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
197 | 198 | ||
198 | // Check whether uses is module's child. | 199 | // Check whether uses is module's child. |
199 | - assertThat((yangNode.getChild() instanceof YangUses), is(true)); | 200 | + assertThat(yangNode.getChild() instanceof YangUses, is(true)); |
200 | YangUses uses = (YangUses) yangNode.getChild(); | 201 | YangUses uses = (YangUses) yangNode.getChild(); |
201 | 202 | ||
202 | // Check whether uses get resolved. | 203 | // Check whether uses get resolved. |
... | @@ -317,7 +318,7 @@ public class InterFileLinkingTest { | ... | @@ -317,7 +318,7 @@ public class InterFileLinkingTest { |
317 | } | 318 | } |
318 | 319 | ||
319 | // Check whether the data model tree returned is of type module. | 320 | // Check whether the data model tree returned is of type module. |
320 | - assertThat((selfNode instanceof YangModule), is(true)); | 321 | + assertThat(selfNode instanceof YangModule, is(true)); |
321 | 322 | ||
322 | // Check whether the node type is set properly to module. | 323 | // Check whether the node type is set properly to module. |
323 | assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE)); | 324 | assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE)); |
... | @@ -330,7 +331,7 @@ public class InterFileLinkingTest { | ... | @@ -330,7 +331,7 @@ public class InterFileLinkingTest { |
330 | YangLeaf leafInfo; | 331 | YangLeaf leafInfo; |
331 | 332 | ||
332 | // Check whether grouping is the sibling of module's child. | 333 | // Check whether grouping is the sibling of module's child. |
333 | - assertThat((refNode.getChild() instanceof YangGrouping), is(true)); | 334 | + assertThat(refNode.getChild() instanceof YangGrouping, is(true)); |
334 | 335 | ||
335 | YangGrouping grouping = (YangGrouping) refNode.getChild(); | 336 | YangGrouping grouping = (YangGrouping) refNode.getChild(); |
336 | leafIterator = grouping.getListOfLeaf().listIterator(); | 337 | leafIterator = grouping.getListOfLeaf().listIterator(); |
... | @@ -342,7 +343,7 @@ public class InterFileLinkingTest { | ... | @@ -342,7 +343,7 @@ public class InterFileLinkingTest { |
342 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 343 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
343 | 344 | ||
344 | // Check whether uses is module's child. | 345 | // Check whether uses is module's child. |
345 | - assertThat((yangNode.getChild() instanceof YangUses), is(true)); | 346 | + assertThat(yangNode.getChild() instanceof YangUses, is(true)); |
346 | YangUses uses = (YangUses) yangNode.getChild(); | 347 | YangUses uses = (YangUses) yangNode.getChild(); |
347 | 348 | ||
348 | // Check whether uses get resolved. | 349 | // Check whether uses get resolved. |
... | @@ -637,13 +638,13 @@ public class InterFileLinkingTest { | ... | @@ -637,13 +638,13 @@ public class InterFileLinkingTest { |
637 | utilManager.parseYangFileInfoSet(); | 638 | utilManager.parseYangFileInfoSet(); |
638 | utilManager.resolveDependenciesUsingLinker(); | 639 | utilManager.resolveDependenciesUsingLinker(); |
639 | 640 | ||
640 | - String userDir = System.getProperty("user.dir"); | ||
641 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 641 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
642 | yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/"); | 642 | yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/"); |
643 | + yangPluginConfig.setManagerCodeGenDir("target/interfilewithusesreferringtype/"); | ||
643 | 644 | ||
644 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 645 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); |
645 | 646 | ||
646 | - deleteDirectory(userDir + "/target/interfilewithusesreferringtype/"); | 647 | + deleteDirectory("target/interfilewithusesreferringtype/"); |
647 | 648 | ||
648 | } | 649 | } |
649 | 650 | ||
... | @@ -659,17 +660,16 @@ public class InterFileLinkingTest { | ... | @@ -659,17 +660,16 @@ public class InterFileLinkingTest { |
659 | utilManager.parseYangFileInfoSet(); | 660 | utilManager.parseYangFileInfoSet(); |
660 | utilManager.resolveDependenciesUsingLinker(); | 661 | utilManager.resolveDependenciesUsingLinker(); |
661 | 662 | ||
662 | - String userDir = System.getProperty("user.dir"); | ||
663 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 663 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
664 | yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); | 664 | yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); |
665 | + yangPluginConfig.setManagerCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); | ||
665 | 666 | ||
666 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 667 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); |
667 | 668 | ||
668 | - deleteDirectory(userDir + "/target/file1UsesFile2TypeDefFile3Type/"); | 669 | + deleteDirectory("target/file1UsesFile2TypeDefFile3Type/"); |
669 | 670 | ||
670 | } | 671 | } |
671 | 672 | ||
672 | - | ||
673 | /** | 673 | /** |
674 | * Checks hierarchical intra with inter file type linking. | 674 | * Checks hierarchical intra with inter file type linking. |
675 | */ | 675 | */ |
... | @@ -682,17 +682,16 @@ public class InterFileLinkingTest { | ... | @@ -682,17 +682,16 @@ public class InterFileLinkingTest { |
682 | utilManager.parseYangFileInfoSet(); | 682 | utilManager.parseYangFileInfoSet(); |
683 | utilManager.resolveDependenciesUsingLinker(); | 683 | utilManager.resolveDependenciesUsingLinker(); |
684 | 684 | ||
685 | - String userDir = System.getProperty("user.dir"); | ||
686 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 685 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
687 | yangPluginConfig.setCodeGenDir("target/interfileietf/"); | 686 | yangPluginConfig.setCodeGenDir("target/interfileietf/"); |
687 | + yangPluginConfig.setManagerCodeGenDir("target/interfileietf/"); | ||
688 | 688 | ||
689 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 689 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); |
690 | 690 | ||
691 | - deleteDirectory(userDir + "/target/interfileietf/"); | 691 | + deleteDirectory("target/interfileietf/"); |
692 | 692 | ||
693 | } | 693 | } |
694 | 694 | ||
695 | - | ||
696 | /** | 695 | /** |
697 | * Checks hierarchical intra with inter file type linking. | 696 | * Checks hierarchical intra with inter file type linking. |
698 | */ | 697 | */ |
... | @@ -705,17 +704,16 @@ public class InterFileLinkingTest { | ... | @@ -705,17 +704,16 @@ public class InterFileLinkingTest { |
705 | utilManager.parseYangFileInfoSet(); | 704 | utilManager.parseYangFileInfoSet(); |
706 | utilManager.resolveDependenciesUsingLinker(); | 705 | utilManager.resolveDependenciesUsingLinker(); |
707 | 706 | ||
708 | - String userDir = System.getProperty("user.dir"); | ||
709 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 707 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
710 | yangPluginConfig.setCodeGenDir("target/usesInContainer/"); | 708 | yangPluginConfig.setCodeGenDir("target/usesInContainer/"); |
709 | + yangPluginConfig.setManagerCodeGenDir("target/usesInContainer/"); | ||
711 | 710 | ||
712 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 711 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); |
713 | 712 | ||
714 | - deleteDirectory(userDir + "/target/usesInContainer/"); | 713 | + deleteDirectory("target/usesInContainer/"); |
715 | 714 | ||
716 | } | 715 | } |
717 | 716 | ||
718 | - | ||
719 | /** | 717 | /** |
720 | * Checks hierarchical intra with inter file type linking. | 718 | * Checks hierarchical intra with inter file type linking. |
721 | */ | 719 | */ |
... | @@ -728,13 +726,13 @@ public class InterFileLinkingTest { | ... | @@ -728,13 +726,13 @@ public class InterFileLinkingTest { |
728 | utilManager.parseYangFileInfoSet(); | 726 | utilManager.parseYangFileInfoSet(); |
729 | utilManager.resolveDependenciesUsingLinker(); | 727 | utilManager.resolveDependenciesUsingLinker(); |
730 | 728 | ||
731 | - String userDir = System.getProperty("user.dir"); | ||
732 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 729 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
733 | yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/"); | 730 | yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/"); |
731 | + yangPluginConfig.setManagerCodeGenDir("target/groupingNodeSameAsModule/"); | ||
734 | 732 | ||
735 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 733 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); |
736 | 734 | ||
737 | - deleteDirectory(userDir + "/target/groupingNodeSameAsModule/"); | 735 | + deleteDirectory("target/groupingNodeSameAsModule/"); |
738 | 736 | ||
739 | } | 737 | } |
740 | 738 | ||
... | @@ -846,7 +844,7 @@ public class InterFileLinkingTest { | ... | @@ -846,7 +844,7 @@ public class InterFileLinkingTest { |
846 | 844 | ||
847 | thrown.expect(LinkerException.class); | 845 | thrown.expect(LinkerException.class); |
848 | thrown.expectMessage( | 846 | thrown.expectMessage( |
849 | - "YANG file error: Unable to find base leaf/leaf-list for given leafref"); | 847 | + "YANG file error: Unable to find base leaf/leaf-list for given leafref networks"); |
850 | String searchDir = "src/test/resources/interfileleafrefwithinvaliddestinationnode"; | 848 | String searchDir = "src/test/resources/interfileleafrefwithinvaliddestinationnode"; |
851 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 849 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
852 | utilManager.parseYangFileInfoSet(); | 850 | utilManager.parseYangFileInfoSet(); | ... | ... |
... | @@ -44,7 +44,7 @@ import static org.hamcrest.core.Is.is; | ... | @@ -44,7 +44,7 @@ import static org.hamcrest.core.Is.is; |
44 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED; | 44 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED; |
45 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING; | 45 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING; |
46 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; | 46 | import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; |
47 | -import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.deSerializeDataModel; | 47 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.deSerializeDataModel; |
48 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.parseJarFile; | 48 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.parseJarFile; |
49 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.serializeDataModel; | 49 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.serializeDataModel; |
50 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 50 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
... | @@ -189,6 +189,7 @@ public class InterJarLinkerTest { | ... | @@ -189,6 +189,7 @@ public class InterJarLinkerTest { |
189 | 189 | ||
190 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 190 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
191 | yangPluginConfig.setCodeGenDir(TARGET); | 191 | yangPluginConfig.setCodeGenDir(TARGET); |
192 | + yangPluginConfig.setManagerCodeGenDir(TARGET); | ||
192 | 193 | ||
193 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | 194 | utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); |
194 | 195 | ||
... | @@ -205,7 +206,7 @@ public class InterJarLinkerTest { | ... | @@ -205,7 +206,7 @@ public class InterJarLinkerTest { |
205 | File folder = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_FOLDER); | 206 | File folder = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_FOLDER); |
206 | File file = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_MANAGER); | 207 | File file = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_MANAGER); |
207 | assertThat(true, is(folder.exists())); | 208 | assertThat(true, is(folder.exists())); |
208 | - assertThat(true, is(file.exists())); | 209 | + assertThat(false, is(file.exists())); |
209 | } | 210 | } |
210 | 211 | ||
211 | /** | 212 | /** | ... | ... |
... | @@ -16,11 +16,17 @@ | ... | @@ -16,11 +16,17 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.plugin.manager; | 17 | package org.onosproject.yangutils.plugin.manager; |
18 | 18 | ||
19 | +import java.io.IOException; | ||
20 | +import java.util.Iterator; | ||
21 | +import java.util.List; | ||
22 | +import java.util.ListIterator; | ||
23 | + | ||
19 | import org.junit.Rule; | 24 | import org.junit.Rule; |
20 | import org.junit.Test; | 25 | import org.junit.Test; |
21 | import org.junit.rules.ExpectedException; | 26 | import org.junit.rules.ExpectedException; |
22 | import org.onosproject.yangutils.datamodel.YangAtomicPath; | 27 | import org.onosproject.yangutils.datamodel.YangAtomicPath; |
23 | import org.onosproject.yangutils.datamodel.YangContainer; | 28 | import org.onosproject.yangutils.datamodel.YangContainer; |
29 | +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
24 | import org.onosproject.yangutils.datamodel.YangInput; | 30 | import org.onosproject.yangutils.datamodel.YangInput; |
25 | import org.onosproject.yangutils.datamodel.YangLeaf; | 31 | import org.onosproject.yangutils.datamodel.YangLeaf; |
26 | import org.onosproject.yangutils.datamodel.YangLeafList; | 32 | import org.onosproject.yangutils.datamodel.YangLeafList; |
... | @@ -34,16 +40,10 @@ import org.onosproject.yangutils.datamodel.YangPathOperator; | ... | @@ -34,16 +40,10 @@ import org.onosproject.yangutils.datamodel.YangPathOperator; |
34 | import org.onosproject.yangutils.datamodel.YangPathPredicate; | 40 | import org.onosproject.yangutils.datamodel.YangPathPredicate; |
35 | import org.onosproject.yangutils.datamodel.YangRelativePath; | 41 | import org.onosproject.yangutils.datamodel.YangRelativePath; |
36 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | 42 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; |
37 | -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
38 | import org.onosproject.yangutils.linker.exceptions.LinkerException; | 43 | import org.onosproject.yangutils.linker.exceptions.LinkerException; |
39 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 44 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
40 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 45 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
41 | 46 | ||
42 | -import java.io.IOException; | ||
43 | -import java.util.Iterator; | ||
44 | -import java.util.List; | ||
45 | -import java.util.ListIterator; | ||
46 | - | ||
47 | import static org.hamcrest.MatcherAssert.assertThat; | 47 | import static org.hamcrest.MatcherAssert.assertThat; |
48 | import static org.hamcrest.core.Is.is; | 48 | import static org.hamcrest.core.Is.is; |
49 | import static org.hamcrest.core.IsNull.nullValue; | 49 | import static org.hamcrest.core.IsNull.nullValue; | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.plugin.manager; | ||
18 | + | ||
19 | +import java.io.File; | ||
20 | +import java.io.IOException; | ||
21 | + | ||
22 | +import org.apache.maven.plugin.MojoExecutionException; | ||
23 | +import org.junit.Test; | ||
24 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
25 | +import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | ||
26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
27 | + | ||
28 | +import static org.hamcrest.core.Is.is; | ||
29 | +import static org.junit.Assert.assertThat; | ||
30 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ||
31 | + | ||
32 | +/** | ||
33 | + * Unit test case to test code generation for root nodes. | ||
34 | + */ | ||
35 | +public class ManagerCodeGeneratorTest { | ||
36 | + | ||
37 | + private final YangUtilManager utilManager = new YangUtilManager(); | ||
38 | + | ||
39 | + /** | ||
40 | + * Checks manager translation should not result in any exception. | ||
41 | + * | ||
42 | + * @throws MojoExecutionException | ||
43 | + */ | ||
44 | + @Test | ||
45 | + public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException { | ||
46 | + | ||
47 | + String searchDir = "src/test/resources/manager"; | ||
48 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | ||
49 | + utilManager.parseYangFileInfoSet(); | ||
50 | + utilManager.createYangNodeSet(); | ||
51 | + utilManager.resolveDependenciesUsingLinker(); | ||
52 | + | ||
53 | + YangPluginConfig yangPluginConfig = new YangPluginConfig(); | ||
54 | + yangPluginConfig.setCodeGenDir("target/manager/"); | ||
55 | + yangPluginConfig.setManagerCodeGenDir("target/manager/"); | ||
56 | + | ||
57 | + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | ||
58 | + String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java"; | ||
59 | + String file2 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test6Manager.java"; | ||
60 | + String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java"; | ||
61 | + File manager = new File(file1); | ||
62 | + assertThat(false, is(manager.exists())); | ||
63 | + | ||
64 | + File manager2 = new File(file2); | ||
65 | + assertThat(false, is(manager2.exists())); | ||
66 | + | ||
67 | + File manager3 = new File(file3); | ||
68 | + assertThat(true, is(manager3.exists())); | ||
69 | + | ||
70 | + deleteDirectory("target/manager/"); | ||
71 | + } | ||
72 | + | ||
73 | + /** | ||
74 | + * Checks manager translation in different package should not result in any exception. | ||
75 | + * | ||
76 | + * @throws MojoExecutionException | ||
77 | + */ | ||
78 | + @Test | ||
79 | + public void processManagerInDifferentPackageTranslator() throws IOException, ParserException, | ||
80 | + MojoExecutionException { | ||
81 | + | ||
82 | + String searchDir = "src/test/resources/manager"; | ||
83 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | ||
84 | + utilManager.parseYangFileInfoSet(); | ||
85 | + utilManager.createYangNodeSet(); | ||
86 | + utilManager.resolveDependenciesUsingLinker(); | ||
87 | + | ||
88 | + YangPluginConfig yangPluginConfig = new YangPluginConfig(); | ||
89 | + yangPluginConfig.setCodeGenDir("target/manager/"); | ||
90 | + yangPluginConfig.setManagerCodeGenDir("target/manager1/"); | ||
91 | + | ||
92 | + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); | ||
93 | + String file3 = "target/manager1/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java"; | ||
94 | + | ||
95 | + File manager3 = new File(file3); | ||
96 | + assertThat(true, is(manager3.exists())); | ||
97 | + | ||
98 | + deleteDirectory("target/manager/"); | ||
99 | + deleteDirectory("target/manager1/"); | ||
100 | + } | ||
101 | +} |
... | @@ -38,13 +38,14 @@ public final class NotificationTranslatorTest { | ... | @@ -38,13 +38,14 @@ public final class NotificationTranslatorTest { |
38 | * Checks union translation should not result in any exception. | 38 | * Checks union translation should not result in any exception. |
39 | */ | 39 | */ |
40 | @Test | 40 | @Test |
41 | - public void processUnionTranslator() | 41 | + public void processNotificationTranslator() |
42 | throws IOException, ParserException { | 42 | throws IOException, ParserException { |
43 | 43 | ||
44 | YangNode node = manager.getDataModel("src/test/resources/NotificationTest.yang"); | 44 | YangNode node = manager.getDataModel("src/test/resources/NotificationTest.yang"); |
45 | 45 | ||
46 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 46 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
47 | yangPluginConfig.setCodeGenDir("target/NotificationTest/"); | 47 | yangPluginConfig.setCodeGenDir("target/NotificationTest/"); |
48 | + yangPluginConfig.setManagerCodeGenDir("target/NotificationTest1/"); | ||
48 | 49 | ||
49 | generateJavaCode(node, yangPluginConfig); | 50 | generateJavaCode(node, yangPluginConfig); |
50 | 51 | ... | ... |
utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/RpcTranslatorTest.java
... | @@ -45,6 +45,7 @@ public final class RpcTranslatorTest { | ... | @@ -45,6 +45,7 @@ public final class RpcTranslatorTest { |
45 | 45 | ||
46 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 46 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
47 | yangPluginConfig.setCodeGenDir("target/RpcTestGenFile/"); | 47 | yangPluginConfig.setCodeGenDir("target/RpcTestGenFile/"); |
48 | + yangPluginConfig.setManagerCodeGenDir("target/RpcTestGenFile/"); | ||
48 | 49 | ||
49 | generateJavaCode(node, yangPluginConfig); | 50 | generateJavaCode(node, yangPluginConfig); |
50 | 51 | ... | ... |
... | @@ -45,6 +45,7 @@ public final class UnionTranslatorTest { | ... | @@ -45,6 +45,7 @@ public final class UnionTranslatorTest { |
45 | 45 | ||
46 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); | 46 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
47 | yangPluginConfig.setCodeGenDir("target/UnionTestGenFile/"); | 47 | yangPluginConfig.setCodeGenDir("target/UnionTestGenFile/"); |
48 | + yangPluginConfig.setManagerCodeGenDir("target/UnionTestGenFile/"); | ||
48 | 49 | ||
49 | generateJavaCode(node, yangPluginConfig); | 50 | generateJavaCode(node, yangPluginConfig); |
50 | 51 | ... | ... |
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 | + | ||
1 | package org.onosproject.yangutils.plugin.manager; | 17 | package org.onosproject.yangutils.plugin.manager; |
2 | 18 | ||
3 | import java.io.File; | 19 | import java.io.File; |
... | @@ -11,7 +27,7 @@ import org.sonatype.plexus.build.incremental.DefaultBuildContext; | ... | @@ -11,7 +27,7 @@ import org.sonatype.plexus.build.incremental.DefaultBuildContext; |
11 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; | 27 | import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; |
12 | 28 | ||
13 | /** | 29 | /** |
14 | - * Created by root1 on 16/6/16. | 30 | + * Unit test case for YANG plugin utils. |
15 | */ | 31 | */ |
16 | public class YangPluginUtilsTest { | 32 | public class YangPluginUtilsTest { |
17 | 33 | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
5 | + * use this file except in compliance with the License. You may obtain a copy of | ||
6 | + * 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, WITHOUT | ||
12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
13 | + * License for the specific language governing permissions and limitations under | ||
14 | + * the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.plugin.manager; | ||
18 | + | ||
19 | +import java.io.IOException; | ||
20 | +import java.util.List; | ||
21 | + | ||
22 | +import org.apache.maven.plugin.MojoExecutionException; | ||
23 | +import org.junit.Test; | ||
24 | +import org.onosproject.yangutils.datamodel.ResolvableType; | ||
25 | +import org.onosproject.yangutils.datamodel.YangAugment; | ||
26 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
27 | +import org.onosproject.yangutils.datamodel.YangReferenceResolver; | ||
28 | +import org.onosproject.yangutils.datamodel.YangResolutionInfo; | ||
29 | +import org.onosproject.yangutils.linker.impl.YangLinkerManager; | ||
30 | +import org.onosproject.yangutils.linker.impl.YangXpathLinker; | ||
31 | +import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | ||
32 | + | ||
33 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
34 | +import static org.hamcrest.core.Is.is; | ||
35 | + | ||
36 | +/** | ||
37 | + * Unit test cases for x-path linker. | ||
38 | + */ | ||
39 | +public class YangXpathLinkerTest { | ||
40 | + | ||
41 | + private YangUtilManager utilManager = new YangUtilManager(); | ||
42 | + private YangXpathLinker linker = new YangXpathLinker(); | ||
43 | + private YangLinkerManager linkerManager = new YangLinkerManager(); | ||
44 | + private static final String INTRA_FILE_PATH = "src/test/resources/xPathLinker/IntraFile/"; | ||
45 | + private static final String INTER_FILE_PATH = "src/test/resources/xPathLinker/InterFile/"; | ||
46 | + | ||
47 | + /** | ||
48 | + * Unit test case for intra file linking for single level container. | ||
49 | + * | ||
50 | + * @throws IOException when fails to do IO operations | ||
51 | + * @throws MojoExecutionException | ||
52 | + */ | ||
53 | + @Test | ||
54 | + public void processIntraFileLinkingSingleLevel() throws IOException, MojoExecutionException { | ||
55 | + | ||
56 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingle/")); | ||
57 | + utilManager.parseYangFileInfoSet(); | ||
58 | + utilManager.createYangNodeSet(); | ||
59 | + utilManager.resolveDependenciesUsingLinker(); | ||
60 | + | ||
61 | + YangNode targetNode = null; | ||
62 | + String targetNodeName = null; | ||
63 | + | ||
64 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
65 | + YangReferenceResolver ref = (YangReferenceResolver) node; | ||
66 | + List<YangResolutionInfo> infos = ref.getUnresolvedResolutionList(ResolvableType.YANG_AUGMENT); | ||
67 | + YangResolutionInfo info = infos.get(0); | ||
68 | + | ||
69 | + YangAugment augment = (YangAugment) info.getEntityToResolveInfo().getEntityToResolve(); | ||
70 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
71 | + .getName(); | ||
72 | + targetNode = augment.getAugmentedNode(); | ||
73 | + | ||
74 | + } | ||
75 | + | ||
76 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
77 | + } | ||
78 | + | ||
79 | + /** | ||
80 | + * Unit test case for intra file linking for multiple level container. | ||
81 | + * | ||
82 | + * @throws IOException when fails to do IO operations | ||
83 | + */ | ||
84 | + @Test | ||
85 | + public void processIntraFileLinkingMultipleLevel() throws IOException { | ||
86 | + | ||
87 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMulti/")); | ||
88 | + utilManager.parseYangFileInfoSet(); | ||
89 | + utilManager.createYangNodeSet(); | ||
90 | + | ||
91 | + YangNode targetNode = null; | ||
92 | + String targetNodeName = null; | ||
93 | + | ||
94 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
95 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
96 | + | ||
97 | + for (YangAugment augment : augments) { | ||
98 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
99 | + .getName(); | ||
100 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
101 | + } | ||
102 | + } | ||
103 | + | ||
104 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * Unit test case for intra file linking for single level augment. | ||
109 | + * | ||
110 | + * @throws IOException when fails to do IO operations | ||
111 | + */ | ||
112 | + @Test | ||
113 | + public void processIntraFileLinkingInAugmentSingleLevel() throws IOException { | ||
114 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleAugment/")); | ||
115 | + utilManager.parseYangFileInfoSet(); | ||
116 | + utilManager.createYangNodeSet(); | ||
117 | + | ||
118 | + YangNode targetNode = null; | ||
119 | + String targetNodeName = null; | ||
120 | + | ||
121 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
122 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
123 | + | ||
124 | + for (YangAugment augment : augments) { | ||
125 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
126 | + .getName(); | ||
127 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
128 | + } | ||
129 | + } | ||
130 | + | ||
131 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
132 | + } | ||
133 | + | ||
134 | + /** | ||
135 | + * Unit test case for intra file linking for multiple level augment. | ||
136 | + * | ||
137 | + * @throws IOException when fails to do IO operations | ||
138 | + */ | ||
139 | + @Test | ||
140 | + public void processIntraFileLinkingInAugmentMultiLevel() throws IOException { | ||
141 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiAugment/")); | ||
142 | + utilManager.parseYangFileInfoSet(); | ||
143 | + utilManager.createYangNodeSet(); | ||
144 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
145 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
146 | + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | ||
147 | + linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | ||
148 | + | ||
149 | + YangNode targetNode = null; | ||
150 | + String targetNodeName = null; | ||
151 | + | ||
152 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
153 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
154 | + | ||
155 | + for (YangAugment augment : augments) { | ||
156 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
157 | + .getName(); | ||
158 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
159 | + } | ||
160 | + } | ||
161 | + | ||
162 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
163 | + | ||
164 | + } | ||
165 | + | ||
166 | + /** | ||
167 | + * Unit test case for intra file linking for multiple level submodule. | ||
168 | + * | ||
169 | + * @throws IOException when fails to do IO operations | ||
170 | + */ | ||
171 | + @Test | ||
172 | + public void processIntraFileLinkingInSubModuleSingleLevel() throws IOException { | ||
173 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleSubModule/")); | ||
174 | + utilManager.parseYangFileInfoSet(); | ||
175 | + utilManager.createYangNodeSet(); | ||
176 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
177 | + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | ||
178 | + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | ||
179 | + | ||
180 | + YangNode targetNode = null; | ||
181 | + String targetNodeName = null; | ||
182 | + | ||
183 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
184 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
185 | + | ||
186 | + for (YangAugment augment : augments) { | ||
187 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
188 | + .getName(); | ||
189 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
190 | + } | ||
191 | + } | ||
192 | + | ||
193 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
194 | + } | ||
195 | + | ||
196 | + /** | ||
197 | + * Unit test case for intra file linking for multiple level submodule. | ||
198 | + * | ||
199 | + * @throws IOException when fails to do IO operations | ||
200 | + */ | ||
201 | + @Test | ||
202 | + public void processIntraFileLinkingInSubModuleMultiLevel() throws IOException { | ||
203 | + | ||
204 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiSubModule/")); | ||
205 | + utilManager.parseYangFileInfoSet(); | ||
206 | + utilManager.createYangNodeSet(); | ||
207 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
208 | + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | ||
209 | + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | ||
210 | + | ||
211 | + YangNode targetNode = null; | ||
212 | + String targetNodeName = null; | ||
213 | + | ||
214 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
215 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
216 | + | ||
217 | + for (YangAugment augment : augments) { | ||
218 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
219 | + .getName(); | ||
220 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
221 | + } | ||
222 | + } | ||
223 | + | ||
224 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
225 | + } | ||
226 | + | ||
227 | + /** | ||
228 | + * Unit test case for intra file linking for single level uses. | ||
229 | + * | ||
230 | + * @throws IOException when fails to do IO operations | ||
231 | + */ | ||
232 | + @Test | ||
233 | + public void processIntraFileLinkingInUsesSingleLevel() throws IOException { | ||
234 | + | ||
235 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/")); | ||
236 | + utilManager.parseYangFileInfoSet(); | ||
237 | + utilManager.createYangNodeSet(); | ||
238 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
239 | + linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | ||
240 | + | ||
241 | + YangNode targetNode = null; | ||
242 | + String targetNodeName = null; | ||
243 | + | ||
244 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
245 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
246 | + | ||
247 | + for (YangAugment augment : augments) { | ||
248 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
249 | + .getName(); | ||
250 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
251 | + } | ||
252 | + } | ||
253 | + | ||
254 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
255 | + } | ||
256 | + | ||
257 | + /** | ||
258 | + * Unit test case for intra file linking for multi level uses. | ||
259 | + * | ||
260 | + * @throws IOException when fails to do IO operations | ||
261 | + */ | ||
262 | + @Test | ||
263 | + public void processIntraFileLinkingInUsesMultiLevel() throws IOException { | ||
264 | + | ||
265 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/")); | ||
266 | + utilManager.parseYangFileInfoSet(); | ||
267 | + utilManager.createYangNodeSet(); | ||
268 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
269 | + linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | ||
270 | + | ||
271 | + YangNode targetNode = null; | ||
272 | + String targetNodeName = null; | ||
273 | + | ||
274 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
275 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
276 | + | ||
277 | + for (YangAugment augment : augments) { | ||
278 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
279 | + .getName(); | ||
280 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
281 | + } | ||
282 | + } | ||
283 | + | ||
284 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
285 | + } | ||
286 | + | ||
287 | + /** | ||
288 | + * Unit test case for inter file linking for single level container. | ||
289 | + * | ||
290 | + * @throws IOException when fails to do IO operations | ||
291 | + */ | ||
292 | + @Test | ||
293 | + public void processInterFileLinkingSingleLevel() throws IOException { | ||
294 | + | ||
295 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingle/")); | ||
296 | + utilManager.parseYangFileInfoSet(); | ||
297 | + utilManager.createYangNodeSet(); | ||
298 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
299 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
300 | + | ||
301 | + YangNode targetNode = null; | ||
302 | + String targetNodeName = null; | ||
303 | + | ||
304 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
305 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
306 | + | ||
307 | + for (YangAugment augment : augments) { | ||
308 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
309 | + .getName(); | ||
310 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
311 | + } | ||
312 | + } | ||
313 | + | ||
314 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
315 | + } | ||
316 | + | ||
317 | + /** | ||
318 | + * Unit test case for inter file linking for multi level container. | ||
319 | + * | ||
320 | + * @throws IOException when fails to do IO operations | ||
321 | + */ | ||
322 | + @Test | ||
323 | + public void processInterFileLinkingMultipleLevel() throws IOException { | ||
324 | + | ||
325 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMulti/")); | ||
326 | + utilManager.parseYangFileInfoSet(); | ||
327 | + utilManager.createYangNodeSet(); | ||
328 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
329 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
330 | + | ||
331 | + YangNode targetNode = null; | ||
332 | + String targetNodeName = null; | ||
333 | + | ||
334 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
335 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
336 | + | ||
337 | + for (YangAugment augment : augments) { | ||
338 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
339 | + .getName(); | ||
340 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
341 | + } | ||
342 | + } | ||
343 | + | ||
344 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
345 | + } | ||
346 | + | ||
347 | + /** | ||
348 | + * Unit test case for inter file linking for single level augment. | ||
349 | + * | ||
350 | + * @throws IOException when fails to do IO operations | ||
351 | + */ | ||
352 | + @Test | ||
353 | + public void processInterFileLinkingInAugmentSingleLevel() throws IOException { | ||
354 | + | ||
355 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleAugment/")); | ||
356 | + utilManager.parseYangFileInfoSet(); | ||
357 | + utilManager.createYangNodeSet(); | ||
358 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
359 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
360 | + | ||
361 | + YangNode targetNode = null; | ||
362 | + String targetNodeName = null; | ||
363 | + | ||
364 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
365 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
366 | + | ||
367 | + for (YangAugment augment : augments) { | ||
368 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
369 | + .getName(); | ||
370 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
371 | + } | ||
372 | + } | ||
373 | + | ||
374 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
375 | + } | ||
376 | + | ||
377 | + /** | ||
378 | + * Unit test case for inter file linking for multi level augment. | ||
379 | + * | ||
380 | + * @throws IOException when fails to do IO operations | ||
381 | + */ | ||
382 | + @Test | ||
383 | + public void processInterFileLinkingInAugmentMultiLevel() throws IOException { | ||
384 | + | ||
385 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiAugment/")); | ||
386 | + utilManager.parseYangFileInfoSet(); | ||
387 | + utilManager.createYangNodeSet(); | ||
388 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
389 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
390 | + | ||
391 | + YangNode targetNode = null; | ||
392 | + String targetNodeName = null; | ||
393 | + | ||
394 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
395 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
396 | + | ||
397 | + for (YangAugment augment : augments) { | ||
398 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
399 | + .getName(); | ||
400 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
401 | + } | ||
402 | + } | ||
403 | + | ||
404 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
405 | + } | ||
406 | + | ||
407 | + /** | ||
408 | + * Unit test case for multipler inter file linking for single level augment. | ||
409 | + * | ||
410 | + * @throws IOException when fails to do IO operations | ||
411 | + */ | ||
412 | + @Test | ||
413 | + public void processMultiInterFileLinkingInAugmentSingleLevel() throws IOException { | ||
414 | + | ||
415 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiFileAugment/")); | ||
416 | + utilManager.parseYangFileInfoSet(); | ||
417 | + utilManager.createYangNodeSet(); | ||
418 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
419 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
420 | + | ||
421 | + YangNode targetNode = null; | ||
422 | + String targetNodeName = null; | ||
423 | + | ||
424 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
425 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
426 | + | ||
427 | + for (YangAugment augment : augments) { | ||
428 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
429 | + .getName(); | ||
430 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
431 | + } | ||
432 | + } | ||
433 | + | ||
434 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
435 | + } | ||
436 | + | ||
437 | + /** | ||
438 | + * Unit test case for multiple inter file linking for multi level augment. | ||
439 | + * | ||
440 | + * @throws IOException when fails to do IO operations | ||
441 | + */ | ||
442 | + @Test | ||
443 | + public void processMultiInterFileLinkingInAugmentMultiLevel() throws IOException { | ||
444 | + | ||
445 | + utilManager | ||
446 | + .createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiFileAugmentMulti/")); | ||
447 | + utilManager.parseYangFileInfoSet(); | ||
448 | + utilManager.createYangNodeSet(); | ||
449 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
450 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
451 | + | ||
452 | + YangNode targetNode = null; | ||
453 | + String targetNodeName = null; | ||
454 | + | ||
455 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
456 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
457 | + | ||
458 | + for (YangAugment augment : augments) { | ||
459 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
460 | + .getName(); | ||
461 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
462 | + } | ||
463 | + } | ||
464 | + | ||
465 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
466 | + } | ||
467 | + | ||
468 | + /** | ||
469 | + * Unit test case for inter file linking for single level submodule. | ||
470 | + * | ||
471 | + * @throws IOException when fails to do IO operations | ||
472 | + */ | ||
473 | + @Test | ||
474 | + public void processInterFileLinkingInSubModuleSingleLevel() throws IOException { | ||
475 | + | ||
476 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleSubModule/")); | ||
477 | + utilManager.parseYangFileInfoSet(); | ||
478 | + utilManager.createYangNodeSet(); | ||
479 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
480 | + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | ||
481 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
482 | + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | ||
483 | + | ||
484 | + YangNode targetNode = null; | ||
485 | + String targetNodeName = null; | ||
486 | + | ||
487 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
488 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
489 | + | ||
490 | + for (YangAugment augment : augments) { | ||
491 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
492 | + .getName(); | ||
493 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
494 | + } | ||
495 | + } | ||
496 | + | ||
497 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
498 | + } | ||
499 | + | ||
500 | + /** | ||
501 | + * Unit test case for inter file linking for multi level submodule. | ||
502 | + * | ||
503 | + * @throws IOException when fails to do IO operations | ||
504 | + */ | ||
505 | + @Test | ||
506 | + public void processInterFileLinkingInSubModuleMultiLevel() throws IOException { | ||
507 | + | ||
508 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiSubModule/")); | ||
509 | + utilManager.parseYangFileInfoSet(); | ||
510 | + utilManager.createYangNodeSet(); | ||
511 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
512 | + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); | ||
513 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
514 | + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | ||
515 | + linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | ||
516 | + YangNode targetNode = null; | ||
517 | + String targetNodeName = null; | ||
518 | + | ||
519 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
520 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
521 | + | ||
522 | + for (YangAugment augment : augments) { | ||
523 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
524 | + .getName(); | ||
525 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
526 | + } | ||
527 | + } | ||
528 | + | ||
529 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
530 | + } | ||
531 | + | ||
532 | + /** | ||
533 | + * Unit test case for inter file linking for multi level uses inside augment. | ||
534 | + * | ||
535 | + * @throws IOException when fails to do IO operations | ||
536 | + */ | ||
537 | + @Test | ||
538 | + public void processInterFileLinkingInUsesInAugment() throws IOException { | ||
539 | + | ||
540 | + /* FIXME: when uses cloning is done test it. | ||
541 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleUses/")); | ||
542 | + utilManager.parseYangFileInfoSet(); | ||
543 | + utilManager.createYangNodeSet(); | ||
544 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
545 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
546 | + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | ||
547 | + linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | ||
548 | + | ||
549 | + YangNode targetNode = null; | ||
550 | + String targetNodeName = null; | ||
551 | + | ||
552 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
553 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
554 | + | ||
555 | + for (YangAugment augment : augments) { | ||
556 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1) | ||
557 | + .getNodeIdentifier().getName(); | ||
558 | + targetNode = linker.processXpathLinking(augment.getTargetNode(), node); | ||
559 | + } | ||
560 | + } | ||
561 | + | ||
562 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
563 | + */ | ||
564 | + } | ||
565 | + | ||
566 | + /** | ||
567 | + * Unit test case for inter file linking for multi level uses. | ||
568 | + * | ||
569 | + * @throws IOException when fails to do IO operations | ||
570 | + */ | ||
571 | + @Test | ||
572 | + public void processInterFileLinkingInUsesMultiLevel() throws IOException { | ||
573 | + | ||
574 | + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/")); | ||
575 | + utilManager.parseYangFileInfoSet(); | ||
576 | + utilManager.createYangNodeSet(); | ||
577 | + linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); | ||
578 | + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); | ||
579 | + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); | ||
580 | + linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); | ||
581 | + | ||
582 | + YangNode targetNode = null; | ||
583 | + String targetNodeName = null; | ||
584 | + | ||
585 | + for (YangNode node : utilManager.getYangNodeSet()) { | ||
586 | + List<YangAugment> augments = linker.getListOfYangAugment(node); | ||
587 | + | ||
588 | + for (YangAugment augment : augments) { | ||
589 | + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() | ||
590 | + .getName(); | ||
591 | + targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); | ||
592 | + } | ||
593 | + } | ||
594 | + | ||
595 | + assertThat(true, is(targetNode.getName().equals(targetNodeName))); | ||
596 | + } | ||
597 | + | ||
598 | +} |
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.utils; | ||
18 | - | ||
19 | -import java.lang.reflect.Constructor; | ||
20 | -import java.lang.reflect.InvocationTargetException; | ||
21 | - | ||
22 | -import org.junit.Test; | ||
23 | - | ||
24 | -import static org.hamcrest.core.Is.is; | ||
25 | -import static org.hamcrest.core.IsNot.not; | ||
26 | -import static org.junit.Assert.assertThat; | ||
27 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; | ||
28 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; | ||
29 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; | ||
30 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; | ||
31 | -import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; | ||
32 | - | ||
33 | -/** | ||
34 | - * Unit tests for class definition generator for generated files. | ||
35 | - */ | ||
36 | -public final class ClassDefinitionGeneratorTest { | ||
37 | - | ||
38 | - private static final String CLASS_NAME = "TestClass"; | ||
39 | - private static final String INTERFACE_CLASS_DEF = "public interface TestClass {\n"; | ||
40 | - private static final String BULDER_INTERFACE_CLASS_DEF = "interface TestClassBuilder {\n\n"; | ||
41 | - private static final String BUILDER_CLASS_DEF = "public class TestClassBuilder implements " | ||
42 | - + "TestClass.TestClassBuilder {\n"; | ||
43 | - private static final String IMPL_CLASS_DEF = "public final class TestClassImpl implements TestClass {\n"; | ||
44 | - private static final String TYPE_DEF_CLASS_DEF = "public final class TestClass {\n"; | ||
45 | - | ||
46 | - /** | ||
47 | - * Unit test for private constructor. | ||
48 | - * | ||
49 | - * @throws SecurityException if any security violation is observed | ||
50 | - * @throws NoSuchMethodException if when the method is not found | ||
51 | - * @throws IllegalArgumentException if there is illegal argument found | ||
52 | - * @throws InstantiationException if instantiation is provoked for the private constructor | ||
53 | - * @throws IllegalAccessException if instance is provoked or a method is provoked | ||
54 | - * @throws InvocationTargetException when an exception occurs by the method or constructor | ||
55 | - */ | ||
56 | - @Test | ||
57 | - public void callPrivateConstructors() | ||
58 | - throws SecurityException, NoSuchMethodException, IllegalArgumentException, | ||
59 | - InstantiationException, IllegalAccessException, InvocationTargetException { | ||
60 | - | ||
61 | - Class<?>[] classesToConstruct = {ClassDefinitionGenerator.class }; | ||
62 | - for (Class<?> clazz : classesToConstruct) { | ||
63 | - Constructor<?> constructor = clazz.getDeclaredConstructor(); | ||
64 | - constructor.setAccessible(true); | ||
65 | - assertThat(null, not(constructor.newInstance())); | ||
66 | - } | ||
67 | - } | ||
68 | - | ||
69 | - /** | ||
70 | - * Unit test for builder class definition. | ||
71 | - */ | ||
72 | - @Test | ||
73 | - public void generateBuilderClassDefinitionTest() { | ||
74 | - String builderClassDefinition = generateClassDefinition(BUILDER_CLASS_MASK, CLASS_NAME); | ||
75 | - assertThat(true, is(builderClassDefinition.equals(BUILDER_CLASS_DEF))); | ||
76 | - } | ||
77 | - | ||
78 | - /** | ||
79 | - * Unit test for builder interface definition. | ||
80 | - */ | ||
81 | - @Test | ||
82 | - public void generateBuilderInterfaceDefinitionTest() { | ||
83 | - String builderInterfaceDefinition = generateClassDefinition(BUILDER_INTERFACE_MASK, CLASS_NAME); | ||
84 | - assertThat(true, is(builderInterfaceDefinition.equals(BULDER_INTERFACE_CLASS_DEF))); | ||
85 | - } | ||
86 | - | ||
87 | - /** | ||
88 | - * Unit test for impl class definition. | ||
89 | - */ | ||
90 | - @Test | ||
91 | - public void generateImplDefinitionTest() { | ||
92 | - String implDefinition = generateClassDefinition(IMPL_CLASS_MASK, CLASS_NAME); | ||
93 | - assertThat(true, is(implDefinition.equals(IMPL_CLASS_DEF))); | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * Unit test for interface definition. | ||
98 | - */ | ||
99 | - @Test | ||
100 | - public void generateinterfaceDefinitionTest() { | ||
101 | - // TODO: need to add this test case. | ||
102 | - } | ||
103 | - | ||
104 | - /** | ||
105 | - * Unit test for typedef generated type. | ||
106 | - */ | ||
107 | - @Test | ||
108 | - public void generateTypeDefTest() { | ||
109 | - String typeDef = generateClassDefinition(GENERATE_TYPEDEF_CLASS, CLASS_NAME); | ||
110 | - assertThat(true, is(typeDef.equals(TYPE_DEF_CLASS_DEF))); | ||
111 | - } | ||
112 | -} |
... | @@ -30,7 +30,6 @@ import static org.hamcrest.core.IsNot.not; | ... | @@ -30,7 +30,6 @@ import static org.hamcrest.core.IsNot.not; |
30 | import static org.junit.Assert.assertThat; | 30 | import static org.junit.Assert.assertThat; |
31 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING; | 31 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING; |
32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
33 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
34 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuild; | 33 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuild; |
35 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildForInterface; | 34 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildForInterface; |
36 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getCheckNotNull; | 35 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getCheckNotNull; |
... | @@ -58,7 +57,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | ... | @@ -58,7 +57,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; |
58 | import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING; | 57 | import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING; |
59 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 58 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
60 | import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX; | 59 | import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX; |
61 | -import static org.onosproject.yangutils.utils.UtilConstants.IMPL; | ||
62 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; | 60 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; |
63 | import static org.onosproject.yangutils.utils.UtilConstants.NEW; | 61 | import static org.onosproject.yangutils.utils.UtilConstants.NEW; |
64 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 62 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
... | @@ -83,6 +81,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.THIS; | ... | @@ -83,6 +81,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.THIS; |
83 | import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; | 81 | import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; |
84 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; | 82 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; |
85 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; | 83 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
84 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
86 | 85 | ||
87 | /** | 86 | /** |
88 | * Unit tests for generated methods from the file type. | 87 | * Unit tests for generated methods from the file type. |
... | @@ -107,7 +106,7 @@ public final class MethodsGeneratorTest { | ... | @@ -107,7 +106,7 @@ public final class MethodsGeneratorTest { |
107 | throws SecurityException, NoSuchMethodException, IllegalArgumentException, | 106 | throws SecurityException, NoSuchMethodException, IllegalArgumentException, |
108 | InstantiationException, IllegalAccessException, InvocationTargetException { | 107 | InstantiationException, IllegalAccessException, InvocationTargetException { |
109 | 108 | ||
110 | - Class<?>[] classesToConstruct = {MethodsGenerator.class }; | 109 | + Class<?>[] classesToConstruct = {MethodsGenerator.class}; |
111 | for (Class<?> clazz : classesToConstruct) { | 110 | for (Class<?> clazz : classesToConstruct) { |
112 | Constructor<?> constructor = clazz.getDeclaredConstructor(); | 111 | Constructor<?> constructor = clazz.getDeclaredConstructor(); |
113 | constructor.setAccessible(true); | 112 | constructor.setAccessible(true); |
... | @@ -135,7 +134,7 @@ public final class MethodsGeneratorTest { | ... | @@ -135,7 +134,7 @@ public final class MethodsGeneratorTest { |
135 | String method = getBuild(CLASS_NAME); | 134 | String method = getBuild(CLASS_NAME); |
136 | assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_NAME + SPACE + BUILD | 135 | assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_NAME + SPACE + BUILD |
137 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION | 136 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION |
138 | - + RETURN + SPACE + NEW + SPACE + CLASS_NAME + IMPL + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS | 137 | + + RETURN + SPACE + NEW + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS |
139 | + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET))); | 138 | + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET))); |
140 | 139 | ||
141 | } | 140 | } |
... | @@ -167,7 +166,7 @@ public final class MethodsGeneratorTest { | ... | @@ -167,7 +166,7 @@ public final class MethodsGeneratorTest { |
167 | public void getConstructorTest() { | 166 | public void getConstructorTest() { |
168 | JavaAttributeInfo testAttr = getTestAttribute(); | 167 | JavaAttributeInfo testAttr = getTestAttribute(); |
169 | YangPluginConfig pluginConfig = new YangPluginConfig(); | 168 | YangPluginConfig pluginConfig = new YangPluginConfig(); |
170 | - String method = getConstructor(CLASS_NAME, testAttr, GENERATE_SERVICE_AND_MANAGER, pluginConfig); | 169 | + String method = getConstructor(testAttr, GENERATE_SERVICE_AND_MANAGER, pluginConfig); |
171 | assertThat(true, is(method.contains(THIS + PERIOD + CLASS_NAME + SPACE + EQUAL + SPACE + "builder" + OBJECT | 170 | assertThat(true, is(method.contains(THIS + PERIOD + CLASS_NAME + SPACE + EQUAL + SPACE + "builder" + OBJECT |
172 | + PERIOD + GET_METHOD_PREFIX + "Testname" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN))); | 171 | + PERIOD + GET_METHOD_PREFIX + "Testname" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN))); |
173 | } | 172 | } |
... | @@ -179,7 +178,7 @@ public final class MethodsGeneratorTest { | ... | @@ -179,7 +178,7 @@ public final class MethodsGeneratorTest { |
179 | public void getConstructorStartTest() { | 178 | public void getConstructorStartTest() { |
180 | YangPluginConfig pluginConfig = new YangPluginConfig(); | 179 | YangPluginConfig pluginConfig = new YangPluginConfig(); |
181 | String method = getConstructorStart(CLASS_NAME, pluginConfig); | 180 | String method = getConstructorStart(CLASS_NAME, pluginConfig); |
182 | - assertThat(true, is(method.contains(PUBLIC + SPACE + CLASS_NAME + IMPL + OPEN_PARENTHESIS + CLASS_NAME | 181 | + assertThat(true, is(method.contains(PUBLIC + SPACE + "Default" + CLASS_NAME + OPEN_PARENTHESIS + CLASS_NAME |
183 | + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE | 182 | + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE |
184 | + OPEN_CURLY_BRACKET + NEW_LINE))); | 183 | + OPEN_CURLY_BRACKET + NEW_LINE))); |
185 | } | 184 | } | ... | ... |
1 | +module test { | ||
2 | + namespace "test:test"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + | ||
6 | + import test1{ | ||
7 | + prefix test1; | ||
8 | + } | ||
9 | + | ||
10 | + import test2{ | ||
11 | + prefix test2; | ||
12 | + } | ||
13 | + | ||
14 | + include acme-types; | ||
15 | + | ||
16 | + organization ""; | ||
17 | + contact ""; | ||
18 | + | ||
19 | + description | ||
20 | + "Defines basic service types for L3VPN service."; | ||
21 | + | ||
22 | + revision "2015-12-16" { | ||
23 | + reference ""; | ||
24 | + } | ||
25 | + | ||
26 | + container cont1 { | ||
27 | + container cont2 { | ||
28 | + leaf leaf { | ||
29 | + type int32; | ||
30 | + } | ||
31 | + } | ||
32 | + } | ||
33 | + | ||
34 | + | ||
35 | + augment /cont3 { | ||
36 | + leaf leaf1 { | ||
37 | + type int32; | ||
38 | + } | ||
39 | + } | ||
40 | + | ||
41 | + augment /cont1/cont2 { | ||
42 | + leaf leaf2 { | ||
43 | + type int32; | ||
44 | + } | ||
45 | + } | ||
46 | + | ||
47 | + augment /test1:cont1/test1:cont2 { | ||
48 | + leaf a { | ||
49 | + type int32; | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + augment /test1:cont1/test1:cont2/test1:cont1s/test1:cont1s { | ||
54 | + leaf a { | ||
55 | + type int32; | ||
56 | + } | ||
57 | + } | ||
58 | + | ||
59 | + augment /test1:cont1/test1:cont2/test1:cont1s/test1:cont1s/test2:aa { | ||
60 | + leaf a { | ||
61 | + type int32; | ||
62 | + } | ||
63 | + container aa { | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | +} | ||
68 | + |
1 | +module test1 { | ||
2 | + namespace "test1:test1"; | ||
3 | + prefix test1 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + container cont2 { | ||
17 | + } | ||
18 | + } | ||
19 | + | ||
20 | + augment /cont1/cont2 { | ||
21 | + leaf leaf4 { | ||
22 | + type int32; | ||
23 | + } | ||
24 | + container cont1s { | ||
25 | + container cont1s { | ||
26 | + } | ||
27 | + } | ||
28 | + } | ||
29 | +} | ||
30 | + |
1 | +module test2 { | ||
2 | + namespace "test2:test2"; | ||
3 | + prefix test2 ; | ||
4 | + | ||
5 | + import test1{ | ||
6 | + prefix test1; | ||
7 | + } | ||
8 | + organization ""; | ||
9 | + contact ""; | ||
10 | + | ||
11 | + description | ||
12 | + "Defines basic service types for L3VPN service."; | ||
13 | + | ||
14 | + revision "2015-12-16" { | ||
15 | + reference ""; | ||
16 | + } | ||
17 | + | ||
18 | + | ||
19 | + augment /test1:cont1/test1:cont2/test1:cont1s/test1:cont1s { | ||
20 | + leaf leaf5 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + container aa { | ||
24 | + } | ||
25 | + } | ||
26 | +} |
1 | +submodule acme-types { | ||
2 | + | ||
3 | + belongs-to "test" { | ||
4 | + prefix "test"; | ||
5 | + } | ||
6 | + import test1{ | ||
7 | + prefix test1; | ||
8 | + } | ||
9 | + organization ""; | ||
10 | + contact ""; | ||
11 | + | ||
12 | + description | ||
13 | + "Defines basic service types for L3VPN service."; | ||
14 | + | ||
15 | + revision "2015-12-16" { | ||
16 | + reference ""; | ||
17 | + } | ||
18 | + | ||
19 | + container cont3 { | ||
20 | + } | ||
21 | +} |
... | @@ -1723,8 +1723,9 @@ | ... | @@ -1723,8 +1723,9 @@ |
1723 | uses tet:te-link-state-derived; | 1723 | uses tet:te-link-state-derived; |
1724 | } | 1724 | } |
1725 | 1725 | ||
1726 | + /* | ||
1726 | augment "/te-link-event/te-link-attributes/underlay" { | 1727 | augment "/te-link-event/te-link-attributes/underlay" { |
1727 | description "Add state attributes to te-link underlay."; | 1728 | description "Add state attributes to te-link underlay."; |
1728 | uses te-link-state-underlay-attributes; | 1729 | uses te-link-state-underlay-attributes; |
1729 | - } | 1730 | + } */ |
1730 | } | 1731 | } | ... | ... |
1 | +module test { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test1{ | ||
6 | + prefix test1; | ||
7 | + } | ||
8 | + | ||
9 | + organization ""; | ||
10 | + contact ""; | ||
11 | + | ||
12 | + description | ||
13 | + "Defines basic service types for L3VPN service."; | ||
14 | + | ||
15 | + revision "2015-12-16" { | ||
16 | + reference ""; | ||
17 | + } | ||
18 | + | ||
19 | + augment /test1:cont1/test1:cont2 { | ||
20 | + leaf a { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | +} | ||
25 | + |
1 | +module test1 { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test1 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + container cont2 { | ||
20 | + leaf leaf1 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | + } | ||
25 | +} | ||
26 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiAugment/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test1{ | ||
6 | + prefix test1; | ||
7 | + } | ||
8 | + | ||
9 | + organization ""; | ||
10 | + contact ""; | ||
11 | + | ||
12 | + description | ||
13 | + "Defines basic service types for L3VPN service."; | ||
14 | + | ||
15 | + revision "2015-12-16" { | ||
16 | + reference ""; | ||
17 | + } | ||
18 | + | ||
19 | + augment /test1:cont1/test1:cont2/test1:cont2 { | ||
20 | + leaf a { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | +} | ||
25 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiAugment/test1.yang
0 → 100644
1 | +module test1 { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test1 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + } | ||
20 | + | ||
21 | + augment /cont1 { | ||
22 | + container cont2 { | ||
23 | + leaf leaf1 { | ||
24 | + type int32; | ||
25 | + } | ||
26 | + container cont2 { | ||
27 | + leaf leaf1 { | ||
28 | + type int32; | ||
29 | + } | ||
30 | + } | ||
31 | + } | ||
32 | + } | ||
33 | +} | ||
34 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test1{ | ||
6 | + prefix test1; | ||
7 | + } | ||
8 | + | ||
9 | + import test2{ | ||
10 | + prefix test2; | ||
11 | + } | ||
12 | + | ||
13 | + organization ""; | ||
14 | + contact ""; | ||
15 | + | ||
16 | + description | ||
17 | + "Defines basic service types for L3VPN service."; | ||
18 | + | ||
19 | + revision "2015-12-16" { | ||
20 | + reference ""; | ||
21 | + } | ||
22 | + | ||
23 | + augment /test2:cont1/test2:cont2/test1:cont2 { | ||
24 | + leaf a { | ||
25 | + type int32; | ||
26 | + } | ||
27 | + } | ||
28 | +} | ||
29 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test1.yang
0 → 100644
1 | +module test1 { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test1 ; | ||
4 | + | ||
5 | + import test2{ | ||
6 | + prefix test2; | ||
7 | + } | ||
8 | + | ||
9 | + organization ""; | ||
10 | + contact ""; | ||
11 | + | ||
12 | + description | ||
13 | + "Defines basic service types for L3VPN service."; | ||
14 | + | ||
15 | + revision "2015-12-16" { | ||
16 | + reference ""; | ||
17 | + } | ||
18 | + | ||
19 | + | ||
20 | + container cont1 { | ||
21 | + leaf leaf1 { | ||
22 | + type int32; | ||
23 | + } | ||
24 | + } | ||
25 | + | ||
26 | + augment /cont1 { | ||
27 | + container cont2 { | ||
28 | + leaf leaf1 { | ||
29 | + type int32; | ||
30 | + } | ||
31 | + container cont2 { | ||
32 | + leaf leaf1 { | ||
33 | + type int32; | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | + augment /test2:cont1/test2:cont2 { | ||
40 | + leaf a { | ||
41 | + type int32; | ||
42 | + } | ||
43 | + | ||
44 | + container cont2 { | ||
45 | + leaf leaf1 { | ||
46 | + type int32; | ||
47 | + } | ||
48 | + } | ||
49 | + } | ||
50 | +} | ||
51 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiFileAugment/test2.yang
0 → 100644
1 | +module test2 { | ||
2 | + namespace "xpath:inter:multi"; | ||
3 | + prefix test2 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + container cont2 { | ||
20 | + leaf leaf1 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | + } | ||
25 | +} | ||
26 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiFileAugmentMulti/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test1{ | ||
6 | + prefix test1; | ||
7 | + } | ||
8 | + | ||
9 | + import test2{ | ||
10 | + prefix test2; | ||
11 | + } | ||
12 | + | ||
13 | + organization ""; | ||
14 | + contact ""; | ||
15 | + | ||
16 | + description | ||
17 | + "Defines basic service types for L3VPN service."; | ||
18 | + | ||
19 | + revision "2015-12-16" { | ||
20 | + reference ""; | ||
21 | + } | ||
22 | + | ||
23 | + augment /test2:cont1/test2:cont2/test2:cont3/test1:cont2 { | ||
24 | + leaf a { | ||
25 | + type int32; | ||
26 | + } | ||
27 | + } | ||
28 | +} | ||
29 | + |
1 | +module test1 { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test1 ; | ||
4 | + | ||
5 | + import test2{ | ||
6 | + prefix test2; | ||
7 | + } | ||
8 | + | ||
9 | + organization ""; | ||
10 | + contact ""; | ||
11 | + | ||
12 | + description | ||
13 | + "Defines basic service types for L3VPN service."; | ||
14 | + | ||
15 | + revision "2015-12-16" { | ||
16 | + reference ""; | ||
17 | + } | ||
18 | + | ||
19 | + | ||
20 | + container cont1 { | ||
21 | + leaf leaf1 { | ||
22 | + type int32; | ||
23 | + } | ||
24 | + } | ||
25 | + | ||
26 | + augment /cont1 { | ||
27 | + container cont2 { | ||
28 | + leaf leaf1 { | ||
29 | + type int32; | ||
30 | + } | ||
31 | + container cont2 { | ||
32 | + leaf leaf1 { | ||
33 | + type int32; | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | + augment /test2:cont1/test2:cont2/test2:cont3 { | ||
40 | + leaf a { | ||
41 | + type int32; | ||
42 | + } | ||
43 | + | ||
44 | + container cont2 { | ||
45 | + leaf leaf1 { | ||
46 | + type int32; | ||
47 | + } | ||
48 | + } | ||
49 | + } | ||
50 | +} | ||
51 | + |
1 | +module test2 { | ||
2 | + namespace "xpath:inter:multi"; | ||
3 | + prefix test2 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + container cont2 { | ||
20 | + leaf leaf1 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | + } | ||
25 | + | ||
26 | + augment /cont1/cont2 { | ||
27 | + container cont3 { | ||
28 | + leaf a { | ||
29 | + type string; | ||
30 | + } | ||
31 | + } | ||
32 | + } | ||
33 | +} | ||
34 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test2 { | ||
6 | + prefix test2; | ||
7 | + } | ||
8 | + | ||
9 | + include test1; | ||
10 | + | ||
11 | + organization ""; | ||
12 | + contact ""; | ||
13 | + | ||
14 | + description | ||
15 | + "Defines basic service types for L3VPN service."; | ||
16 | + | ||
17 | + revision "2015-12-16" { | ||
18 | + reference ""; | ||
19 | + } | ||
20 | + | ||
21 | + augment /test2:cont1/test2:cont2/cont2 { | ||
22 | + leaf a { | ||
23 | + type int32; | ||
24 | + } | ||
25 | + } | ||
26 | + | ||
27 | + augment /cont2/cont3/cont4 { | ||
28 | + leaf a { | ||
29 | + type int32; | ||
30 | + } | ||
31 | + } | ||
32 | +} | ||
33 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test1.yang
0 → 100644
1 | +submodule test1 { | ||
2 | + | ||
3 | + belongs-to test { | ||
4 | + prefix test; | ||
5 | + } | ||
6 | + | ||
7 | + import test2 { | ||
8 | + prefix test2; | ||
9 | + } | ||
10 | + organization ""; | ||
11 | + contact ""; | ||
12 | + | ||
13 | + description | ||
14 | + "Defines basic service types for L3VPN service."; | ||
15 | + | ||
16 | + revision "2015-12-16" { | ||
17 | + reference ""; | ||
18 | + } | ||
19 | + | ||
20 | + container cont2 { | ||
21 | + leaf leaf1 { | ||
22 | + type int32; | ||
23 | + } | ||
24 | + container cont3 { | ||
25 | + leaf leaf1 { | ||
26 | + type int32; | ||
27 | + } | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | + augment /cont2/cont3 { | ||
32 | + container cont4 { | ||
33 | + leaf leaf1 { | ||
34 | + type int32; | ||
35 | + } | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | + augment /test2:cont1/test2:cont2 { | ||
40 | + leaf a { | ||
41 | + type int32; | ||
42 | + } | ||
43 | + container cont2 { | ||
44 | + leaf leaf1 { | ||
45 | + type int32; | ||
46 | + } | ||
47 | + } | ||
48 | + } | ||
49 | +} | ||
50 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiSubModule/test2.yang
0 → 100644
1 | +module test2 { | ||
2 | + namespace "xpath:inter:multi"; | ||
3 | + prefix test2 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + container cont2 { | ||
20 | + leaf leaf1 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | + } | ||
25 | +} | ||
26 | + |
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test2 { | ||
6 | + prefix test2; | ||
7 | + } | ||
8 | + | ||
9 | + organization ""; | ||
10 | + contact ""; | ||
11 | + | ||
12 | + description | ||
13 | + "Defines basic service types for L3VPN service."; | ||
14 | + | ||
15 | + revision "2015-12-16" { | ||
16 | + reference ""; | ||
17 | + } | ||
18 | + | ||
19 | + container cont2 { | ||
20 | + leaf a { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + uses test2:group1; | ||
24 | + } | ||
25 | + | ||
26 | + augment /cont2/group1/cont1/cont2 { | ||
27 | + leaf a { | ||
28 | + type int32; | ||
29 | + } | ||
30 | + } | ||
31 | +} | ||
32 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterMultiUses/test2.yang
0 → 100644
1 | +module test2 { | ||
2 | + namespace "xpath:inter:multi"; | ||
3 | + prefix test2 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + grouping group1 { | ||
16 | + container cont1 { | ||
17 | + leaf leaf1 { | ||
18 | + type int32; | ||
19 | + } | ||
20 | + container cont2 { | ||
21 | + leaf leaf1 { | ||
22 | + type int32; | ||
23 | + } | ||
24 | + } | ||
25 | + } | ||
26 | + } | ||
27 | +} | ||
28 | + |
1 | +module test { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test1{ | ||
6 | + prefix test1; | ||
7 | + } | ||
8 | + | ||
9 | + organization ""; | ||
10 | + contact ""; | ||
11 | + | ||
12 | + description | ||
13 | + "Defines basic service types for L3VPN service."; | ||
14 | + | ||
15 | + revision "2015-12-16" { | ||
16 | + reference ""; | ||
17 | + } | ||
18 | + | ||
19 | + augment /test1:cont1 { | ||
20 | + leaf a { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | +} | ||
25 | + |
1 | +module test1 { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test1 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + } | ||
20 | +} | ||
21 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterSingleAugment/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test1{ | ||
6 | + prefix test1; | ||
7 | + } | ||
8 | + | ||
9 | + organization ""; | ||
10 | + contact ""; | ||
11 | + | ||
12 | + description | ||
13 | + "Defines basic service types for L3VPN service."; | ||
14 | + | ||
15 | + revision "2015-12-16" { | ||
16 | + reference ""; | ||
17 | + } | ||
18 | + | ||
19 | + augment /test1:cont1/test1:cont2 { | ||
20 | + leaf a { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | +} | ||
25 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterSingleAugment/test1.yang
0 → 100644
1 | +module test1 { | ||
2 | + namespace "xpath:inter:single"; | ||
3 | + prefix test1 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + } | ||
20 | + | ||
21 | + augment /cont1 { | ||
22 | + container cont2 { | ||
23 | + leaf leaf1 { | ||
24 | + type int32; | ||
25 | + } | ||
26 | + } | ||
27 | + } | ||
28 | +} | ||
29 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test2 { | ||
6 | + prefix test2; | ||
7 | + } | ||
8 | + | ||
9 | + include test1; | ||
10 | + | ||
11 | + organization ""; | ||
12 | + contact ""; | ||
13 | + | ||
14 | + description | ||
15 | + "Defines basic service types for L3VPN service."; | ||
16 | + | ||
17 | + revision "2015-12-16" { | ||
18 | + reference ""; | ||
19 | + } | ||
20 | + | ||
21 | + augment /test2:cont1/test2:cont2/cont2 { | ||
22 | + leaf a { | ||
23 | + type int32; | ||
24 | + } | ||
25 | + } | ||
26 | +} | ||
27 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test1.yang
0 → 100644
1 | +submodule test1 { | ||
2 | + | ||
3 | + belongs-to test { | ||
4 | + prefix test; | ||
5 | + } | ||
6 | + | ||
7 | + import test2 { | ||
8 | + prefix test2; | ||
9 | + } | ||
10 | + organization ""; | ||
11 | + contact ""; | ||
12 | + | ||
13 | + description | ||
14 | + "Defines basic service types for L3VPN service."; | ||
15 | + | ||
16 | + revision "2015-12-16" { | ||
17 | + reference ""; | ||
18 | + } | ||
19 | + | ||
20 | + augment /test2:cont1/test2:cont2 { | ||
21 | + leaf a { | ||
22 | + type int32; | ||
23 | + } | ||
24 | + container cont2 { | ||
25 | + leaf leaf1 { | ||
26 | + type int32; | ||
27 | + } | ||
28 | + } | ||
29 | + } | ||
30 | +} | ||
31 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterSingleSubModule/test2.yang
0 → 100644
1 | +module test2 { | ||
2 | + namespace "xpath:inter:multi"; | ||
3 | + prefix test2 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + container cont2 { | ||
20 | + leaf leaf1 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | + } | ||
25 | +} | ||
26 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterSingleUses/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + import test2 { | ||
6 | + prefix test2; | ||
7 | + } | ||
8 | + | ||
9 | + include test1; | ||
10 | + | ||
11 | + organization ""; | ||
12 | + contact ""; | ||
13 | + | ||
14 | + description | ||
15 | + "Defines basic service types for L3VPN service."; | ||
16 | + | ||
17 | + revision "2015-12-16" { | ||
18 | + reference ""; | ||
19 | + } | ||
20 | + | ||
21 | + augment /test2:cont1/test2:cont2/cont2 { | ||
22 | + leaf a { | ||
23 | + type int32; | ||
24 | + } | ||
25 | + uses group1; | ||
26 | + } | ||
27 | + | ||
28 | + augment /test2:cont1/test2:cont2/cont2/group1/cont1/cont2 { | ||
29 | + leaf a { | ||
30 | + type int32; | ||
31 | + } | ||
32 | + } | ||
33 | +} | ||
34 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterSingleUses/test1.yang
0 → 100644
1 | +submodule test1 { | ||
2 | + | ||
3 | + belongs-to test { | ||
4 | + prefix test; | ||
5 | + } | ||
6 | + | ||
7 | + import test2 { | ||
8 | + prefix test2; | ||
9 | + } | ||
10 | + organization ""; | ||
11 | + contact ""; | ||
12 | + | ||
13 | + description | ||
14 | + "Defines basic service types for L3VPN service."; | ||
15 | + | ||
16 | + revision "2015-12-16" { | ||
17 | + reference ""; | ||
18 | + } | ||
19 | + | ||
20 | + | ||
21 | + grouping group1 { | ||
22 | + container cont1 { | ||
23 | + container cont2 { | ||
24 | + leaf a { | ||
25 | + type string; | ||
26 | + } | ||
27 | + } | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | + augment /test2:cont1/test2:cont2 { | ||
32 | + leaf a { | ||
33 | + type int32; | ||
34 | + } | ||
35 | + container cont2 { | ||
36 | + leaf leaf1 { | ||
37 | + type int32; | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | +} | ||
42 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/InterFile/InterSingleUses/test2.yang
0 → 100644
1 | +module test2 { | ||
2 | + namespace "xpath:inter:multi"; | ||
3 | + prefix test2 ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + container cont2 { | ||
20 | + leaf leaf1 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + } | ||
24 | + } | ||
25 | +} | ||
26 | + |
1 | +module test { | ||
2 | + namespace "xpath:intra:multi"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + container cont2 { | ||
20 | + leaf leaf2 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + container cont3 { | ||
24 | + leaf leaf3 { | ||
25 | + type int32; | ||
26 | + } | ||
27 | + } | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | + augment /cont1/cont2/cont3 { | ||
32 | + leaf a { | ||
33 | + type int32; | ||
34 | + } | ||
35 | + } | ||
36 | +} | ||
37 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:intra:multi"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + container cont2 { | ||
20 | + leaf leaf2 { | ||
21 | + type int32; | ||
22 | + } | ||
23 | + container cont3 { | ||
24 | + leaf leaf3 { | ||
25 | + type int32; | ||
26 | + } | ||
27 | + } | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | + augment /cont1/cont2/cont3 { | ||
32 | + leaf a { | ||
33 | + type int32; | ||
34 | + } | ||
35 | + container cont4 { | ||
36 | + leaf leaf2 { | ||
37 | + type int32; | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + augment /cont1/cont2/cont3/cont4 { | ||
43 | + leaf a { | ||
44 | + type int32; | ||
45 | + } | ||
46 | + | ||
47 | + container cont5 { | ||
48 | + leaf leaf1 { | ||
49 | + type int32; | ||
50 | + } | ||
51 | + } | ||
52 | + } | ||
53 | +} | ||
54 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:intra:multi"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + include test1; | ||
6 | + organization ""; | ||
7 | + contact ""; | ||
8 | + | ||
9 | + description | ||
10 | + "Defines basic service types for L3VPN service."; | ||
11 | + | ||
12 | + revision "2015-12-16" { | ||
13 | + reference ""; | ||
14 | + } | ||
15 | + | ||
16 | + container cont1 { | ||
17 | + leaf leaf1 { | ||
18 | + type int32; | ||
19 | + } | ||
20 | + } | ||
21 | + | ||
22 | + augment /cont2/cont3 { | ||
23 | + leaf a { | ||
24 | + type int32; | ||
25 | + } | ||
26 | + } | ||
27 | +} | ||
28 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test1.yang
0 → 100644
1 | +submodule test1 { | ||
2 | + | ||
3 | + belongs-to "test" { | ||
4 | + prefix "test"; | ||
5 | + } | ||
6 | + | ||
7 | + organization ""; | ||
8 | + contact ""; | ||
9 | + | ||
10 | + description | ||
11 | + "Defines basic service types for L3VPN service."; | ||
12 | + | ||
13 | + revision "2015-12-16" { | ||
14 | + reference ""; | ||
15 | + } | ||
16 | + | ||
17 | + container cont2 { | ||
18 | + leaf leaf1 { | ||
19 | + type int32; | ||
20 | + } | ||
21 | + container cont3 { | ||
22 | + leaf leaf3 { | ||
23 | + type int32; | ||
24 | + } | ||
25 | + } | ||
26 | + } | ||
27 | +} | ||
28 | + |
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + grouping group1 { | ||
16 | + container cont1 { | ||
17 | + leaf leaf1 { | ||
18 | + type int32; | ||
19 | + } | ||
20 | + container cont3 { | ||
21 | + leaf leaf1 { | ||
22 | + type int32; | ||
23 | + } | ||
24 | + } | ||
25 | + } | ||
26 | + } | ||
27 | + | ||
28 | + container cont2 { | ||
29 | + uses group1; | ||
30 | + } | ||
31 | + | ||
32 | + augment /cont2/group1/cont1/cont3 { | ||
33 | + leaf a { | ||
34 | + type int32; | ||
35 | + } | ||
36 | + } | ||
37 | +} | ||
38 | + |
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + } | ||
20 | + | ||
21 | + augment /cont1 { | ||
22 | + leaf a { | ||
23 | + type int32; | ||
24 | + } | ||
25 | + } | ||
26 | +} | ||
27 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraSingleAugment/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + container cont1 { | ||
16 | + leaf leaf1 { | ||
17 | + type int32; | ||
18 | + } | ||
19 | + } | ||
20 | + | ||
21 | + augment /cont1 { | ||
22 | + leaf a { | ||
23 | + type int32; | ||
24 | + } | ||
25 | + | ||
26 | + container cont2 { | ||
27 | + leaf leaf1 { | ||
28 | + type int32; | ||
29 | + } | ||
30 | + } | ||
31 | + } | ||
32 | + | ||
33 | + augment /cont1/cont2 { | ||
34 | + leaf a { | ||
35 | + type int32; | ||
36 | + } | ||
37 | + } | ||
38 | +} | ||
39 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + include test1; | ||
6 | + organization ""; | ||
7 | + contact ""; | ||
8 | + | ||
9 | + description | ||
10 | + "Defines basic service types for L3VPN service."; | ||
11 | + | ||
12 | + revision "2015-12-16" { | ||
13 | + reference ""; | ||
14 | + } | ||
15 | + | ||
16 | + container cont1 { | ||
17 | + leaf leaf1 { | ||
18 | + type int32; | ||
19 | + } | ||
20 | + } | ||
21 | + | ||
22 | + augment /cont2 { | ||
23 | + leaf a { | ||
24 | + type int32; | ||
25 | + } | ||
26 | + } | ||
27 | +} | ||
28 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test1.yang
0 → 100644
1 | +submodule test1 { | ||
2 | + | ||
3 | + belongs-to test { | ||
4 | + prefix test; | ||
5 | + } | ||
6 | + | ||
7 | + organization ""; | ||
8 | + contact ""; | ||
9 | + | ||
10 | + description | ||
11 | + "Defines basic service types for L3VPN service."; | ||
12 | + | ||
13 | + revision "2015-12-16" { | ||
14 | + reference ""; | ||
15 | + } | ||
16 | + | ||
17 | + container cont2 { | ||
18 | + leaf leaf1 { | ||
19 | + type int32; | ||
20 | + } | ||
21 | + } | ||
22 | +} | ||
23 | + |
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraSingleUses/test.yang
0 → 100644
1 | +module test { | ||
2 | + namespace "xpath:intra:single"; | ||
3 | + prefix test ; | ||
4 | + | ||
5 | + organization ""; | ||
6 | + contact ""; | ||
7 | + | ||
8 | + description | ||
9 | + "Defines basic service types for L3VPN service."; | ||
10 | + | ||
11 | + revision "2015-12-16" { | ||
12 | + reference ""; | ||
13 | + } | ||
14 | + | ||
15 | + grouping group1 { | ||
16 | + container cont1 { | ||
17 | + leaf leaf1 { | ||
18 | + type int32; | ||
19 | + } | ||
20 | + } | ||
21 | + } | ||
22 | + | ||
23 | + container cont2 { | ||
24 | + uses group1; | ||
25 | + } | ||
26 | + | ||
27 | + augment /cont2/group1/cont1 { | ||
28 | + leaf a { | ||
29 | + type int32; | ||
30 | + } | ||
31 | + } | ||
32 | +} | ||
33 | + |
-
Please register or login to post a comment