Committed by
Patrick Liu
[ONOS-4799],[ONOS-4351] Augment inter file linker and Generated Code refactored.
Change-Id: Id1f3ac9c90a632373f51cc75d499c3110216be17
Showing
110 changed files
with
2044 additions
and
664 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,14 +1443,73 @@ public class YangResolutionInfoImpl<T> | ... | @@ -1438,14 +1443,73 @@ 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 | ||
1441 | - // Push the initial entity to resolve in stack. | 1446 | + if (entityToResolve instanceof YangXPathResolver) { |
1442 | - addInPartialResolvedStack(getEntityToResolveInfo()); | 1447 | + //Process x-path linking. |
1448 | + processXPathLinking(getEntityToResolveInfo(), dataModelRootNode); | ||
1449 | + | ||
1450 | + } else { | ||
1443 | 1451 | ||
1444 | - // Inter file linking and resolution. | 1452 | + // Push the initial entity to resolve in stack. |
1445 | - linkInterFileAndResolve(); | 1453 | + addInPartialResolvedStack(getEntityToResolveInfo()); |
1446 | 1454 | ||
1447 | - // Resolve the derived types having leafref. | 1455 | + // Inter file linking and resolution. |
1448 | - addDerivedRefTypeToRefTypeResolutionList(); | 1456 | + linkInterFileAndResolve(); |
1457 | + | ||
1458 | + addDerivedRefTypeToRefTypeResolutionList(); | ||
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 | + } | ||
1449 | } | 1513 | } |
1450 | 1514 | ||
1451 | /** | 1515 | /** | ... | ... |
utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangXpathLinker.java
0 → 100644
This diff is collapsed. Click to expand it.
... | @@ -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 | } |
... | @@ -780,4 +782,4 @@ public final class ListenerUtil { | ... | @@ -780,4 +782,4 @@ public final class ListenerUtil { |
780 | throw parserException; | 782 | throw parserException; |
781 | } | 783 | } |
782 | } | 784 | } |
783 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
785 | +} | ... | ... |
... | @@ -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,8 +161,8 @@ public final class YangPluginUtils { | ... | @@ -188,8 +161,8 @@ 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(); |
195 | List<String> jarPaths = new ArrayList<>(); | 168 | List<String> jarPaths = new ArrayList<>(); |
... | @@ -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()) { | 266 | + try { |
259 | - setCurYangFileInfo(yangFileInfo); | 267 | + yangLinker.resolveDependencies(getYangNodeSet()); |
260 | - try { | 268 | + } catch (LinkerException e) { |
261 | - yangLinker.resolveDependencies(getYangNodeSet()); | 269 | + throw new MojoExecutionException(e.getMessage()); |
262 | - } catch (LinkerException e) { | ||
263 | - throw new MojoExecutionException(e.getMessage()); | ||
264 | - } | ||
265 | } | 270 | } |
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; | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -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 | /** | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -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 { |
157 | - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); | 160 | + if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { |
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 { |
170 | - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); | 172 | + if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { |
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 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -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. |
... | @@ -71,7 +91,7 @@ public final class JavaCodeSnippetGen { | ... | @@ -71,7 +91,7 @@ public final class JavaCodeSnippetGen { |
71 | * | 91 | * |
72 | * @param importInfo import info | 92 | * @param importInfo import info |
73 | * @return the textual java code information corresponding to the import | 93 | * @return the textual java code information corresponding to the import |
74 | - * list | 94 | + * list |
75 | */ | 95 | */ |
76 | public static String getImportText(JavaQualifiedTypeInfo importInfo) { | 96 | public static String getImportText(JavaQualifiedTypeInfo importInfo) { |
77 | return IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN + NEW_LINE; | 97 | return IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN + NEW_LINE; |
... | @@ -81,13 +101,13 @@ public final class JavaCodeSnippetGen { | ... | @@ -81,13 +101,13 @@ public final class JavaCodeSnippetGen { |
81 | * Returns the textual java code for attribute definition in class. | 101 | * Returns the textual java code for attribute definition in class. |
82 | * | 102 | * |
83 | * @param javaAttributeTypePkg Package of the attribute type | 103 | * @param javaAttributeTypePkg Package of the attribute type |
84 | - * @param javaAttributeType java attribute type | 104 | + * @param javaAttributeType java attribute type |
85 | - * @param javaAttributeName name of the attribute | 105 | + * @param javaAttributeName name of the attribute |
86 | - * @param isList is list attribute | 106 | + * @param isList is list attribute |
87 | * @return the textual java code for attribute definition in class | 107 | * @return the textual java code for attribute definition in class |
88 | */ | 108 | */ |
89 | public static String getJavaAttributeDefination(String javaAttributeTypePkg, String javaAttributeType, | 109 | public static String getJavaAttributeDefination(String javaAttributeTypePkg, String javaAttributeType, |
90 | - String javaAttributeName, boolean isList) { | 110 | + String javaAttributeName, boolean isList) { |
91 | 111 | ||
92 | String attributeDefination = PRIVATE + SPACE; | 112 | String attributeDefination = PRIVATE + SPACE; |
93 | 113 | ||
... | @@ -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 | * |
... | @@ -144,8 +153,8 @@ public final class JavaCodeSnippetGen { | ... | @@ -144,8 +153,8 @@ public final class JavaCodeSnippetGen { |
144 | /** | 153 | /** |
145 | * Returns string for enum's attribute. | 154 | * Returns string for enum's attribute. |
146 | * | 155 | * |
147 | - * @param name name of attribute | 156 | + * @param name name of attribute |
148 | - * @param value value of the enum | 157 | + * @param value value of the enum |
149 | * @param pluginConfig plugin configurations | 158 | * @param pluginConfig plugin configurations |
150 | * @return string for enum's attribute | 159 | * @return string for enum's attribute |
151 | */ | 160 | */ |
... | @@ -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 | /** | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
... | @@ -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"; | ... | ... |
This diff is collapsed. Click to expand it.
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; |
... | @@ -212,35 +212,17 @@ public final class YangIoUtils { | ... | @@ -212,35 +212,17 @@ public final class YangIoUtils { |
212 | /** | 212 | /** |
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 | - stringBuilder.deleteCharAt(index); | 222 | + if (index != -1) { |
223 | - return stringBuilder.toString(); | 223 | + stringBuilder.deleteCharAt(index); |
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 | - } | ||
242 | } | 224 | } |
243 | - return trimAtLast(newString, COMMA); | 225 | + return stringBuilder.toString(); |
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 | ... | ... |
This diff is collapsed. Click to expand it.
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 | + |
This diff is collapsed. Click to expand it.
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraMultiAugment/test.yang
0 → 100644
This diff is collapsed. Click to expand it.
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test.yang
0 → 100644
This diff is collapsed. Click to expand it.
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraMultiSubModule/test1.yang
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraSingleAugment/test.yang
0 → 100644
This diff is collapsed. Click to expand it.
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test.yang
0 → 100644
This diff is collapsed. Click to expand it.
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraSingleSubModule/test1.yang
0 → 100644
This diff is collapsed. Click to expand it.
utils/yangutils/plugin/src/test/resources/xPathLinker/IntraFile/IntraSingleUses/test.yang
0 → 100644
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment