Bharat saraswal
Committed by Patrick Liu

[ONOS-4829] Augmented data method generator implmentation.

Change-Id: I0cb68dd10a748e5b66eec0b832574f408a23ba5c
Showing 66 changed files with 1957 additions and 1083 deletions
...@@ -15,8 +15,10 @@ ...@@ -15,8 +15,10 @@
15 */ 15 */
16 package org.onosproject.yangutils.datamodel; 16 package org.onosproject.yangutils.datamodel;
17 17
18 +import java.util.HashMap;
18 import java.util.LinkedList; 19 import java.util.LinkedList;
19 import java.util.List; 20 import java.util.List;
21 +import java.util.Map;
20 22
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 import org.onosproject.yangutils.datamodel.utils.Parsable; 24 import org.onosproject.yangutils.datamodel.utils.Parsable;
...@@ -128,9 +130,13 @@ public class YangAugment ...@@ -128,9 +130,13 @@ public class YangAugment
128 private YangNode augmentedNode; 130 private YangNode augmentedNode;
129 131
130 /** 132 /**
131 - * Status of resolution. If completely resolved enum value is "RESOLVED", 133 + * All resolved nodes in given xPath.
132 - * if not enum value is "UNRESOLVED", in case reference of grouping/typedef 134 + */
133 - * is added to uses/type but it's not resolved value of enum should be 135 + private Map<YangAtomicPath, YangNode> resolveNodeInPath;
136 +
137 + /**
138 + * Status of resolution. If completely resolved enum value is "RESOLVED", if not enum value is "UNRESOLVED", in case
139 + * reference of grouping/typedef is added to uses/type but it's not resolved value of enum should be
134 * "INTRA_FILE_RESOLVED". 140 * "INTRA_FILE_RESOLVED".
135 */ 141 */
136 private ResolvableStatus resolvableStatus; 142 private ResolvableStatus resolvableStatus;
...@@ -150,6 +156,7 @@ public class YangAugment ...@@ -150,6 +156,7 @@ public class YangAugment
150 */ 156 */
151 public YangAugment() { 157 public YangAugment() {
152 super(YangNodeType.AUGMENT_NODE); 158 super(YangNodeType.AUGMENT_NODE);
159 + resolveNodeInPath = new HashMap<>();
153 resolvableStatus = ResolvableStatus.UNRESOLVED; 160 resolvableStatus = ResolvableStatus.UNRESOLVED;
154 } 161 }
155 162
...@@ -411,6 +418,11 @@ public class YangAugment ...@@ -411,6 +418,11 @@ public class YangAugment
411 } 418 }
412 419
413 @Override 420 @Override
421 + public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
422 + this.ifFeatureList = ifFeatureList;
423 + }
424 +
425 + @Override
414 public void addIfFeatureList(YangIfFeature ifFeature) { 426 public void addIfFeatureList(YangIfFeature ifFeature) {
415 if (getIfFeatureList() == null) { 427 if (getIfFeatureList() == null) {
416 setIfFeatureList(new LinkedList<>()); 428 setIfFeatureList(new LinkedList<>());
...@@ -419,11 +431,6 @@ public class YangAugment ...@@ -419,11 +431,6 @@ public class YangAugment
419 } 431 }
420 432
421 @Override 433 @Override
422 - public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
423 - this.ifFeatureList = ifFeatureList;
424 - }
425 -
426 - @Override
427 public ResolvableStatus getResolvableStatus() { 434 public ResolvableStatus getResolvableStatus() {
428 return resolvableStatus; 435 return resolvableStatus;
429 } 436 }
...@@ -438,4 +445,22 @@ public class YangAugment ...@@ -438,4 +445,22 @@ public class YangAugment
438 public void resolve() throws DataModelException { 445 public void resolve() throws DataModelException {
439 // Resolving of target node is being done in XPathLinker. 446 // Resolving of target node is being done in XPathLinker.
440 } 447 }
448 +
449 + /**
450 + * Returns all resolved node in path.
451 + *
452 + * @return all resolved node in path
453 + */
454 + public Map<YangAtomicPath, YangNode> getResolveNodeInPath() {
455 + return resolveNodeInPath;
456 + }
457 +
458 + /**
459 + * Sets all resolved node in path.
460 + *
461 + * @param resolveNodeInPath all resolved node in path
462 + */
463 + public void setResolveNodeInPath(Map<YangAtomicPath, YangNode> resolveNodeInPath) {
464 + this.resolveNodeInPath = resolveNodeInPath;
465 + }
441 } 466 }
......
...@@ -144,7 +144,6 @@ public class YangInput ...@@ -144,7 +144,6 @@ public class YangInput
144 listOfLeaf = leafsList; 144 listOfLeaf = leafsList;
145 } 145 }
146 146
147 -
148 @Override 147 @Override
149 public void addLeaf(YangLeaf leaf) { 148 public void addLeaf(YangLeaf leaf) {
150 getListOfLeaf().add(leaf); 149 getListOfLeaf().add(leaf);
......
...@@ -158,7 +158,6 @@ public class YangOutput ...@@ -158,7 +158,6 @@ public class YangOutput
158 this.listOfLeafList = listOfLeafList; 158 this.listOfLeafList = listOfLeafList;
159 } 159 }
160 160
161 -
162 @Override 161 @Override
163 public void addLeafList(YangLeafList leafList) { 162 public void addLeafList(YangLeafList leafList) {
164 getListOfLeafList().add(leafList); 163 getListOfLeafList().add(leafList);
......
...@@ -349,6 +349,7 @@ public final class DataModelUtils { ...@@ -349,6 +349,7 @@ public final class DataModelUtils {
349 * type info needs to be updated to the cloned new type node. 349 * type info needs to be updated to the cloned new type node.
350 * 350 *
351 * @param leavesHolder cloned leaves holder, for whom the leaves reference needs to be updated 351 * @param leavesHolder cloned leaves holder, for whom the leaves reference needs to be updated
352 + * @throws DataModelException when fails to do data model operations
352 */ 353 */
353 public static void updateClonedLeavesUnionEnumRef(YangLeavesHolder leavesHolder) throws DataModelException { 354 public static void updateClonedLeavesUnionEnumRef(YangLeavesHolder leavesHolder) throws DataModelException {
354 List<YangLeaf> currentListOfLeaves = leavesHolder.getListOfLeaf(); 355 List<YangLeaf> currentListOfLeaves = leavesHolder.getListOfLeaf();
......
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 +/**
20 + * Enum for prefix resolver type when augment has come in path.
21 + */
22 +public enum PrefixResolverType {
23 +
24 + /**
25 + * When prefix changes from inter file to intra file.
26 + */
27 + INTER_TO_INTRA,
28 +
29 + /**
30 + * When prefix changes from intra file to inter file.
31 + */
32 + INTRA_TO_INTER,
33 +
34 + /**
35 + * When prefix changes from one inter file to other inter file.
36 + */
37 + INTER_TO_INTER,
38 +
39 + /**
40 + * When no prefix change occurres.
41 + */
42 + NO_PREFIX_CHANGE_FOR_INTRA,
43 +
44 + /**
45 + * When no prefix change occurres.
46 + */
47 + NO_PREFIX_CHANGE_FOR_INTER
48 +}
...@@ -21,6 +21,7 @@ import java.util.List; ...@@ -21,6 +21,7 @@ import java.util.List;
21 import org.onosproject.yangutils.datamodel.YangAugment; 21 import org.onosproject.yangutils.datamodel.YangAugment;
22 import org.onosproject.yangutils.datamodel.YangAugmentableNode; 22 import org.onosproject.yangutils.datamodel.YangAugmentableNode;
23 import org.onosproject.yangutils.datamodel.YangAugmentedInfo; 23 import org.onosproject.yangutils.datamodel.YangAugmentedInfo;
24 +import org.onosproject.yangutils.datamodel.YangChoice;
24 import org.onosproject.yangutils.datamodel.YangLeaf; 25 import org.onosproject.yangutils.datamodel.YangLeaf;
25 import org.onosproject.yangutils.datamodel.YangLeafList; 26 import org.onosproject.yangutils.datamodel.YangLeafList;
26 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 27 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
...@@ -36,8 +37,7 @@ public final class YangLinkerUtils { ...@@ -36,8 +37,7 @@ public final class YangLinkerUtils {
36 } 37 }
37 38
38 /** 39 /**
39 - * Detects collision between target nodes leaf/leaf-list or child node with 40 + * Detects collision between target nodes leaf/leaf-list or child node with augmented leaf/leaf-list or child node.
40 - * augmented leaf/leaf-list or child node.
41 * 41 *
42 * @param targetNode target node 42 * @param targetNode target node
43 * @param augment augment node 43 * @param augment augment node
...@@ -46,6 +46,14 @@ public final class YangLinkerUtils { ...@@ -46,6 +46,14 @@ public final class YangLinkerUtils {
46 YangNode targetNodesChild = targetNode.getChild(); 46 YangNode targetNodesChild = targetNode.getChild();
47 YangNode augmentsChild = augment.getChild(); 47 YangNode augmentsChild = augment.getChild();
48 YangLeavesHolder augmentsLeavesHolder = augment; 48 YangLeavesHolder augmentsLeavesHolder = augment;
49 + if (targetNode instanceof YangChoice) {
50 + if (augmentsLeavesHolder.getListOfLeaf() != null
51 + || augmentsLeavesHolder.getListOfLeafList() != null) {
52 + throw new LinkerException("target node " + targetNode.getName()
53 + + "is a instance of choice. it can " +
54 + "only be augmented with leaf using a case node.");
55 + }
56 + } else {
49 YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode; 57 YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode;
50 58
51 YangNode parent = targetNode; 59 YangNode parent = targetNode;
...@@ -93,10 +101,11 @@ public final class YangLinkerUtils { ...@@ -93,10 +101,11 @@ public final class YangLinkerUtils {
93 } 101 }
94 } 102 }
95 } 103 }
104 + }
96 105
97 /** 106 /**
98 - * Detects collision between target nodes and its all leaf/leaf-list or child node with 107 + * Detects collision between target nodes and its all leaf/leaf-list or child node with augmented leaf/leaf-list or
99 - * augmented leaf/leaf-list or child node. 108 + * child node.
100 * 109 *
101 * @param targetNode target node 110 * @param targetNode target node
102 * @param augment augment node 111 * @param augment augment node
......
...@@ -32,9 +32,9 @@ import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo; ...@@ -32,9 +32,9 @@ import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo;
32 import org.onosproject.yangutils.datamodel.YangFeature; 32 import org.onosproject.yangutils.datamodel.YangFeature;
33 import org.onosproject.yangutils.datamodel.YangFeatureHolder; 33 import org.onosproject.yangutils.datamodel.YangFeatureHolder;
34 import org.onosproject.yangutils.datamodel.YangGrouping; 34 import org.onosproject.yangutils.datamodel.YangGrouping;
35 -import org.onosproject.yangutils.datamodel.YangIfFeature;
36 import org.onosproject.yangutils.datamodel.YangIdentity; 35 import org.onosproject.yangutils.datamodel.YangIdentity;
37 import org.onosproject.yangutils.datamodel.YangIdentityRef; 36 import org.onosproject.yangutils.datamodel.YangIdentityRef;
37 +import org.onosproject.yangutils.datamodel.YangIfFeature;
38 import org.onosproject.yangutils.datamodel.YangImport; 38 import org.onosproject.yangutils.datamodel.YangImport;
39 import org.onosproject.yangutils.datamodel.YangInclude; 39 import org.onosproject.yangutils.datamodel.YangInclude;
40 import org.onosproject.yangutils.datamodel.YangInput; 40 import org.onosproject.yangutils.datamodel.YangInput;
...@@ -73,16 +73,16 @@ import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNRESOL ...@@ -73,16 +73,16 @@ import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNRESOL
73 import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE; 73 import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE;
74 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; 75 import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.detectCollisionForAugmentedNode;
76 +import static org.onosproject.yangutils.utils.UtilConstants.BASE_LINKER_ERROR;
76 import static org.onosproject.yangutils.utils.UtilConstants.FEATURE_LINKER_ERROR; 77 import static org.onosproject.yangutils.utils.UtilConstants.FEATURE_LINKER_ERROR;
77 import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR; 78 import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR;
79 +import static org.onosproject.yangutils.utils.UtilConstants.IDENTITYREF;
80 +import static org.onosproject.yangutils.utils.UtilConstants.IDENTITYREF_LINKER_ERROR;
78 import static org.onosproject.yangutils.utils.UtilConstants.INPUT; 81 import static org.onosproject.yangutils.utils.UtilConstants.INPUT;
79 import static org.onosproject.yangutils.utils.UtilConstants.LEAFREF; 82 import static org.onosproject.yangutils.utils.UtilConstants.LEAFREF;
80 -import static org.onosproject.yangutils.utils.UtilConstants.IDENTITYREF;
81 import static org.onosproject.yangutils.utils.UtilConstants.LEAFREF_LINKER_ERROR; 83 import static org.onosproject.yangutils.utils.UtilConstants.LEAFREF_LINKER_ERROR;
82 import static org.onosproject.yangutils.utils.UtilConstants.OUTPUT; 84 import static org.onosproject.yangutils.utils.UtilConstants.OUTPUT;
83 import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR; 85 import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR;
84 -import static org.onosproject.yangutils.utils.UtilConstants.IDENTITYREF_LINKER_ERROR;
85 -import static org.onosproject.yangutils.utils.UtilConstants.BASE_LINKER_ERROR;
86 86
87 /** 87 /**
88 * Represents implementation of resolution object which will be resolved by 88 * Represents implementation of resolution object which will be resolved by
...@@ -128,7 +128,6 @@ public class YangResolutionInfoImpl<T> ...@@ -128,7 +128,6 @@ public class YangResolutionInfoImpl<T>
128 */ 128 */
129 @SuppressWarnings("unused") 129 @SuppressWarnings("unused")
130 private YangResolutionInfoImpl() { 130 private YangResolutionInfoImpl() {
131 -
132 } 131 }
133 132
134 /** 133 /**
...@@ -153,7 +152,6 @@ public class YangResolutionInfoImpl<T> ...@@ -153,7 +152,6 @@ public class YangResolutionInfoImpl<T>
153 throws DataModelException { 152 throws DataModelException {
154 153
155 setCurReferenceResolver(dataModelRootNode); 154 setCurReferenceResolver(dataModelRootNode);
156 -
157 /** 155 /**
158 * Current node to resolve, it can be a YANG type, YANG uses or YANG if-feature or 156 * Current node to resolve, it can be a YANG type, YANG uses or YANG if-feature or
159 * YANG leafref or YANG base or YANG identityref. 157 * YANG leafref or YANG base or YANG identityref.
...@@ -173,7 +171,6 @@ public class YangResolutionInfoImpl<T> ...@@ -173,7 +171,6 @@ public class YangResolutionInfoImpl<T>
173 throw new DataModelException("Data Model Exception: Entity to resolved is other than " + 171 throw new DataModelException("Data Model Exception: Entity to resolved is other than " +
174 "type/uses/if-feature/leafref/base/identityref"); 172 "type/uses/if-feature/leafref/base/identityref");
175 } 173 }
176 -
177 // Push the initial entity to resolve in stack. 174 // Push the initial entity to resolve in stack.
178 addInPartialResolvedStack(getEntityToResolveInfo()); 175 addInPartialResolvedStack(getEntityToResolveInfo());
179 176
...@@ -191,7 +188,6 @@ public class YangResolutionInfoImpl<T> ...@@ -191,7 +188,6 @@ public class YangResolutionInfoImpl<T>
191 throws DataModelException { 188 throws DataModelException {
192 189
193 while (getPartialResolvedStack().size() != 0) { 190 while (getPartialResolvedStack().size() != 0) {
194 -
195 /** 191 /**
196 * Current node to resolve, it can be a YANG type or YANG uses or 192 * Current node to resolve, it can be a YANG type or YANG uses or
197 * YANG if-feature or YANG leafref or YANG base or YANG identityref. 193 * YANG if-feature or YANG leafref or YANG base or YANG identityref.
...@@ -1479,6 +1475,7 @@ public class YangResolutionInfoImpl<T> ...@@ -1479,6 +1475,7 @@ public class YangResolutionInfoImpl<T>
1479 detectCollisionForAugmentedNode(targetNode, augment); 1475 detectCollisionForAugmentedNode(targetNode, augment);
1480 ((YangAugmentableNode) targetNode).addAugmentation(augment); 1476 ((YangAugmentableNode) targetNode).addAugmentation(augment);
1481 augment.setAugmentedNode(targetNode); 1477 augment.setAugmentedNode(targetNode);
1478 + augment.setResolveNodeInPath(xPathLinker.getResolvedNodes());
1482 Resolvable resolvable = (Resolvable) entityToResolve; 1479 Resolvable resolvable = (Resolvable) entityToResolve;
1483 resolvable.setResolvableStatus(RESOLVED); 1480 resolvable.setResolvableStatus(RESOLVED);
1484 } else { 1481 } else {
......
...@@ -34,9 +34,14 @@ import org.onosproject.yangutils.datamodel.YangModule; ...@@ -34,9 +34,14 @@ import org.onosproject.yangutils.datamodel.YangModule;
34 import org.onosproject.yangutils.datamodel.YangNode; 34 import org.onosproject.yangutils.datamodel.YangNode;
35 import org.onosproject.yangutils.datamodel.YangNodeIdentifier; 35 import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
36 import org.onosproject.yangutils.datamodel.YangSubModule; 36 import org.onosproject.yangutils.datamodel.YangSubModule;
37 -import org.onosproject.yangutils.datamodel.YangUses;
38 import org.onosproject.yangutils.linker.exceptions.LinkerException; 37 import org.onosproject.yangutils.linker.exceptions.LinkerException;
39 38
39 +import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTER;
40 +import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTRA;
41 +import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTRA_TO_INTER;
42 +import static org.onosproject.yangutils.linker.impl.PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTER;
43 +import static org.onosproject.yangutils.linker.impl.PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTRA;
44 +
40 /** 45 /**
41 * Represents x-path linking. 46 * Represents x-path linking.
42 * 47 *
...@@ -44,49 +49,46 @@ import org.onosproject.yangutils.linker.exceptions.LinkerException; ...@@ -44,49 +49,46 @@ import org.onosproject.yangutils.linker.exceptions.LinkerException;
44 */ 49 */
45 public class YangXpathLinker<T> { 50 public class YangXpathLinker<T> {
46 51
47 - /** 52 + private List<YangAtomicPath> absPaths;
48 - * Enum for prefix resolver type when augment has come in path. 53 + private YangNode rootNode;
49 - */ 54 + private Map<YangAtomicPath, PrefixResolverType> prefixResolverTypes;
50 - private static enum PrefixResolverType { 55 + private String curPrefix;
51 - 56 + private Map<YangAtomicPath, YangNode> resolvedNodes;
52 - /**
53 - * When prefix changes from inter file to intra file.
54 - */
55 - INTER_TO_INTRA,
56 -
57 - /**
58 - * When prefix changes from intra file to inter file.
59 - */
60 - INTRA_TO_INTER,
61 57
62 /** 58 /**
63 - * When prefix changes from one inter file to other inter file. 59 + * Creates an instance of x-path linker.
64 */ 60 */
65 - INTER_TO_INTER, 61 + public YangXpathLinker() {
62 + absPaths = new ArrayList<>();
63 + setResolvedNodes(new HashMap<>());
64 + }
66 65
67 /** 66 /**
68 - * When no prefix change occurres. 67 + * Returns prefix resolver list.
68 + *
69 + * @return prefix resolver list
69 */ 70 */
70 - NO_PREFIX_CHANGE_FOR_INTRA, 71 + public Map<YangAtomicPath, PrefixResolverType> getPrefixResolverTypes() {
72 + return prefixResolverTypes;
73 + }
71 74
72 /** 75 /**
73 - * When no prefix change occurres. 76 + * Sets prefix resolver list.
77 + *
78 + * @param prefixResolverTypes prefix resolver list.
74 */ 79 */
75 - NO_PREFIX_CHANGE_FOR_INTER 80 + public void setPrefixResolverTypes(Map<YangAtomicPath, PrefixResolverType> prefixResolverTypes) {
81 + this.prefixResolverTypes = prefixResolverTypes;
76 } 82 }
77 83
78 - private List<YangAtomicPath> absPaths;
79 - private YangNode rootNode;
80 - private PrefixResolverType type;
81 - private String curPrefix;
82 - private Map<YangAtomicPath, YangNode> resolvedNodes;
83 -
84 /** 84 /**
85 - * Creates an instance of x-path linker. 85 + * Adds to the prefix resolver type map.
86 + *
87 + * @param type resolver type
88 + * @param path absolute path
86 */ 89 */
87 - public YangXpathLinker() { 90 + private void addToPrefixResolverList(PrefixResolverType type, YangAtomicPath path) {
88 - absPaths = new ArrayList<>(); 91 + getPrefixResolverTypes().put(path, type);
89 - setResolvedNodes(new HashMap<>());
90 } 92 }
91 93
92 /** 94 /**
...@@ -144,24 +146,6 @@ public class YangXpathLinker<T> { ...@@ -144,24 +146,6 @@ public class YangXpathLinker<T> {
144 } 146 }
145 147
146 /** 148 /**
147 - * Returns prefix resolver type.
148 - *
149 - * @return prefix resolver type
150 - */
151 - private PrefixResolverType getPrefixResolverType() {
152 - return type;
153 - }
154 -
155 - /**
156 - * Sets prefix resolver type.
157 - *
158 - * @param type prefix resolver type
159 - */
160 - private void setPrefixResolverType(PrefixResolverType type) {
161 - this.type = type;
162 - }
163 -
164 - /**
165 * Returns resolved nodes. 149 * Returns resolved nodes.
166 * 150 *
167 * @return resolved nodes 151 * @return resolved nodes
...@@ -214,10 +198,12 @@ public class YangXpathLinker<T> { ...@@ -214,10 +198,12 @@ public class YangXpathLinker<T> {
214 * @param root root node 198 * @param root root node
215 * @return linked target node 199 * @return linked target node
216 */ 200 */
217 - public T processLeafRefXpathLinking(List<YangAtomicPath> absPaths, YangNode root) { 201 + T processLeafRefXpathLinking(List<YangAtomicPath> absPaths, YangNode root) {
218 202
219 YangNode targetNode = null; 203 YangNode targetNode = null;
220 setRootNode(root); 204 setRootNode(root);
205 + setPrefixResolverTypes(new HashMap<>());
206 + parsePrefixResolverList(absPaths);
221 YangAtomicPath leafRefPath = absPaths.get(absPaths.size() - 1); 207 YangAtomicPath leafRefPath = absPaths.get(absPaths.size() - 1);
222 208
223 // When leaf-ref path contains only one absolute path. 209 // When leaf-ref path contains only one absolute path.
...@@ -230,7 +216,7 @@ public class YangXpathLinker<T> { ...@@ -230,7 +216,7 @@ public class YangXpathLinker<T> {
230 targetNode = parseData(root); 216 targetNode = parseData(root);
231 } 217 }
232 if (targetNode == null) { 218 if (targetNode == null) {
233 - targetNode = parsePath(getIncludedNode(root)); 219 + targetNode = searchInSubModule(root);
234 } 220 }
235 221
236 if (targetNode != null) { 222 if (targetNode != null) {
...@@ -277,11 +263,13 @@ public class YangXpathLinker<T> { ...@@ -277,11 +263,13 @@ public class YangXpathLinker<T> {
277 263
278 setAbsPaths(absPaths); 264 setAbsPaths(absPaths);
279 setRootNode(root); 265 setRootNode(root);
266 + setPrefixResolverTypes(new HashMap<>());
267 + parsePrefixResolverList(absPaths);
280 268
281 YangNode targetNode = parseData(root); 269 YangNode targetNode = parseData(root);
282 270
283 if (targetNode == null) { 271 if (targetNode == null) {
284 - targetNode = parsePath(getIncludedNode(root)); 272 + targetNode = searchInSubModule(root);
285 } 273 }
286 return targetNode; 274 return targetNode;
287 275
...@@ -363,20 +351,9 @@ public class YangXpathLinker<T> { ...@@ -363,20 +351,9 @@ public class YangXpathLinker<T> {
363 YangAtomicPath tempPath = pathIterator.next(); 351 YangAtomicPath tempPath = pathIterator.next();
364 setCurPrefix(tempPath.getNodeIdentifier().getPrefix()); 352 setCurPrefix(tempPath.getNodeIdentifier().getPrefix());
365 int index = 0; 353 int index = 0;
366 - YangNode tempAugment = null; 354 + YangNode tempAugment;
367 do { 355 do {
368 356
369 - if (tempNode instanceof YangUses) {
370 - tempNode = handleUsesNode(tempNode, tempPath.getNodeIdentifier());
371 - if (pathIterator.hasNext()) {
372 - tempPath = pathIterator.next();
373 - index++;
374 - } else {
375 - addToResolvedNodes(tempPath, tempNode);
376 - return tempNode;
377 - }
378 - }
379 -
380 if (tempPath.getNodeIdentifier().getPrefix() == null) { 357 if (tempPath.getNodeIdentifier().getPrefix() == null) {
381 tempAugment = resolveIntraFileAugment(tempPath, root); 358 tempAugment = resolveIntraFileAugment(tempPath, root);
382 } else { 359 } else {
...@@ -416,11 +393,20 @@ public class YangXpathLinker<T> { ...@@ -416,11 +393,20 @@ public class YangXpathLinker<T> {
416 * @return linked target node 393 * @return linked target node
417 */ 394 */
418 private YangNode resolveIntraFileAugment(YangAtomicPath tempPath, YangNode root) { 395 private YangNode resolveIntraFileAugment(YangAtomicPath tempPath, YangNode root) {
419 - YangNode tempAugment = null; 396 + YangNode tempAugment;
420 - setPrefixResolverType(PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTRA);
421 if (getCurPrefix() != tempPath.getNodeIdentifier().getPrefix()) { 397 if (getCurPrefix() != tempPath.getNodeIdentifier().getPrefix()) {
422 - setPrefixResolverType(PrefixResolverType.INTRA_TO_INTER); 398 + root = getIncludedNode(getRootNode(), tempPath.getNodeIdentifier().getName());
423 - root = getIncludedNode(getRootNode()); 399 + if (root == null) {
400 + root = getIncludedNode(getRootNode(), getAugmentNodeIdentifier(tempPath.getNodeIdentifier(), absPaths,
401 + getRootNode()));
402 + if (root == null) {
403 + root = getRootNode();
404 + }
405 + }
406 + } else {
407 + if (getCurPrefix() != null) {
408 + root = getImportedNode(root, tempPath.getNodeIdentifier());
409 + }
424 } 410 }
425 411
426 setCurPrefix(tempPath.getNodeIdentifier().getPrefix()); 412 setCurPrefix(tempPath.getNodeIdentifier().getPrefix());
...@@ -440,19 +426,13 @@ public class YangXpathLinker<T> { ...@@ -440,19 +426,13 @@ public class YangXpathLinker<T> {
440 */ 426 */
441 private YangNode resolveInterFileAugment(YangAtomicPath tempPath, YangNode root) { 427 private YangNode resolveInterFileAugment(YangAtomicPath tempPath, YangNode root) {
442 428
443 - YangNode tempAugment = null; 429 + YangNode tempAugment;
444 - if (tempPath.getNodeIdentifier().getPrefix().equals(getCurPrefix())) { 430 + if (!tempPath.getNodeIdentifier().getPrefix().equals(getCurPrefix())) {
445 - setPrefixResolverType(PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTER);
446 - } else {
447 setCurPrefix(tempPath.getNodeIdentifier().getPrefix()); 431 setCurPrefix(tempPath.getNodeIdentifier().getPrefix());
448 - setPrefixResolverType(PrefixResolverType.INTER_TO_INTER);
449 - if (getCurPrefix() == null) {
450 - setPrefixResolverType(PrefixResolverType.INTER_TO_INTRA);
451 - }
452 root = getImportedNode(getRootNode(), tempPath.getNodeIdentifier()); 432 root = getImportedNode(getRootNode(), tempPath.getNodeIdentifier());
453 } 433 }
454 tempAugment = getAugment(tempPath.getNodeIdentifier(), root, getAbsPaths()); 434 tempAugment = getAugment(tempPath.getNodeIdentifier(), root, getAbsPaths());
455 - if (tempAugment == null && getPrefixResolverType().equals(PrefixResolverType.INTER_TO_INTER)) { 435 + if (tempAugment == null) {
456 return resolveInterToInterFileAugment(root); 436 return resolveInterToInterFileAugment(root);
457 } 437 }
458 return tempAugment; 438 return tempAugment;
...@@ -494,6 +474,7 @@ public class YangXpathLinker<T> { ...@@ -494,6 +474,7 @@ public class YangXpathLinker<T> {
494 /** 474 /**
495 * Searches for the augment node in imported module when prefix has changed from 475 * Searches for the augment node in imported module when prefix has changed from
496 * inter file to inter file. 476 * inter file to inter file.
477 + *
497 * @param nodeId node id 478 * @param nodeId node id
498 * @param index index 479 * @param index index
499 * @return true if found 480 * @return true if found
...@@ -511,7 +492,7 @@ public class YangXpathLinker<T> { ...@@ -511,7 +492,7 @@ public class YangXpathLinker<T> {
511 * @return linked target node 492 * @return linked target node
512 */ 493 */
513 private YangNode getAugment(YangNodeIdentifier tempNodeId, YangNode root, List<YangAtomicPath> absPaths) { 494 private YangNode getAugment(YangNodeIdentifier tempNodeId, YangNode root, List<YangAtomicPath> absPaths) {
514 - String augmentName = getAugmentNodeIdentifier(tempNodeId, absPaths); 495 + String augmentName = getAugmentNodeIdentifier(tempNodeId, absPaths, root);
515 if (augmentName != null) { 496 if (augmentName != null) {
516 return searchAugmentNode(root, augmentName); 497 return searchAugmentNode(root, augmentName);
517 } 498 }
...@@ -527,7 +508,7 @@ public class YangXpathLinker<T> { ...@@ -527,7 +508,7 @@ public class YangXpathLinker<T> {
527 */ 508 */
528 private YangNode getImportedNode(YangNode root, YangNodeIdentifier nodeId) { 509 private YangNode getImportedNode(YangNode root, YangNodeIdentifier nodeId) {
529 510
530 - List<YangImport> importList = new ArrayList<>(); 511 + List<YangImport> importList;
531 512
532 if (root instanceof YangModule) { 513 if (root instanceof YangModule) {
533 importList = ((YangModule) root).getImportList(); 514 importList = ((YangModule) root).getImportList();
...@@ -545,14 +526,39 @@ public class YangXpathLinker<T> { ...@@ -545,14 +526,39 @@ public class YangXpathLinker<T> {
545 } 526 }
546 527
547 /** 528 /**
529 + * Searches in sub-module node.
530 + *
531 + * @param root root node
532 + * @return target linked node
533 + */
534 + private YangNode searchInSubModule(YangNode root) {
535 + List<YangInclude> includeList;
536 + YangNode tempNode;
537 + if (root instanceof YangModule) {
538 + includeList = ((YangModule) root).getIncludeList();
539 + } else {
540 + includeList = ((YangSubModule) root).getIncludeList();
541 + }
542 +
543 + for (YangInclude included : includeList) {
544 + tempNode = parseData(included.getIncludedNode());
545 + if (tempNode != null) {
546 + return tempNode;
547 + }
548 + }
549 + return null;
550 + }
551 +
552 + /**
548 * Process linking using include list. 553 * Process linking using include list.
549 * 554 *
550 * @param root root node 555 * @param root root node
556 + * @param tempPathName temporary path node name
551 * @return linked target node 557 * @return linked target node
552 */ 558 */
553 - private YangNode getIncludedNode(YangNode root) { 559 + private YangNode getIncludedNode(YangNode root, String tempPathName) {
554 560
555 - List<YangInclude> includeList = new ArrayList<>(); 561 + List<YangInclude> includeList;
556 562
557 if (root instanceof YangModule) { 563 if (root instanceof YangModule) {
558 includeList = ((YangModule) root).getIncludeList(); 564 includeList = ((YangModule) root).getIncludeList();
...@@ -561,34 +567,84 @@ public class YangXpathLinker<T> { ...@@ -561,34 +567,84 @@ public class YangXpathLinker<T> {
561 } 567 }
562 568
563 for (YangInclude included : includeList) { 569 for (YangInclude included : includeList) {
570 + if (verifyChildNode(included.getIncludedNode(), tempPathName)) {
564 return included.getIncludedNode(); 571 return included.getIncludedNode();
565 } 572 }
573 + }
566 574
567 - return root; 575 + return null;
568 } 576 }
569 577
570 /** 578 /**
571 - * Returns augments node id. 579 + * Verifies for child nodes in sub module.
580 + *
581 + * @param node submodule node
582 + * @param name name of child node
583 + * @return true if child node found
584 + */
585 + private boolean verifyChildNode(YangNode node, String name) {
586 + node = node.getChild();
587 + while (node != null) {
588 + if (node.getName().equals(name)) {
589 + return true;
590 + }
591 + node = node.getNextSibling();
592 + }
593 + return false;
594 + }
595 +
596 +
597 + /**
598 + * Returns augment's node id.
572 * 599 *
573 * @param nodeId node identifier 600 * @param nodeId node identifier
574 - * @return augment node id 601 + * @param absPaths absolute paths
602 + * @param root root node
603 + * @return augment's node id
575 */ 604 */
576 - private String getAugmentNodeIdentifier(YangNodeIdentifier nodeId, List<YangAtomicPath> absPaths) { 605 + private String getAugmentNodeIdentifier(YangNodeIdentifier nodeId, List<YangAtomicPath> absPaths, YangNode root) {
577 606
578 Iterator<YangAtomicPath> nodeIdIterator = absPaths.iterator(); 607 Iterator<YangAtomicPath> nodeIdIterator = absPaths.iterator();
579 - YangAtomicPath tempNodeId = null; 608 + YangAtomicPath tempNodeId;
580 StringBuilder builder = new StringBuilder(); 609 StringBuilder builder = new StringBuilder();
610 + String id;
611 + PrefixResolverType type;
581 while (nodeIdIterator.hasNext()) { 612 while (nodeIdIterator.hasNext()) {
582 tempNodeId = nodeIdIterator.next(); 613 tempNodeId = nodeIdIterator.next();
583 if (!tempNodeId.getNodeIdentifier().equals(nodeId)) { 614 if (!tempNodeId.getNodeIdentifier().equals(nodeId)) {
584 - if (tempNodeId.getNodeIdentifier().getPrefix() != null 615 + type = getPrefixResolverTypes().get(tempNodeId);
585 - && (getPrefixResolverType().equals(PrefixResolverType.INTER_TO_INTER) 616 + switch (type) {
586 - || getPrefixResolverType().equals(PrefixResolverType.INTRA_TO_INTER))) { 617 + case INTER_TO_INTRA:
587 - builder.append("/" + tempNodeId.getNodeIdentifier().getPrefix()); 618 + id = "/" + tempNodeId.getNodeIdentifier().getName();
588 - builder.append(":" + tempNodeId.getNodeIdentifier().getName()); 619 + break;
620 + case INTRA_TO_INTER:
621 + if (!getRootsPrefix(root).equals(tempNodeId.getNodeIdentifier().getPrefix())) {
622 + id = "/" + tempNodeId.getNodeIdentifier().getPrefix() + ":" + tempNodeId.getNodeIdentifier()
623 + .getName();
589 } else { 624 } else {
590 - builder.append("/" + tempNodeId.getNodeIdentifier().getName()); 625 + id = "/" + tempNodeId.getNodeIdentifier().getName();
591 } 626 }
627 + break;
628 + case INTER_TO_INTER:
629 + id = "/" + tempNodeId.getNodeIdentifier().getPrefix() + ":" + tempNodeId.getNodeIdentifier()
630 + .getName();
631 + break;
632 + case NO_PREFIX_CHANGE_FOR_INTRA:
633 + id = "/" + tempNodeId.getNodeIdentifier().getName();
634 + break;
635 + case NO_PREFIX_CHANGE_FOR_INTER:
636 + if (!getRootsPrefix(root).equals(tempNodeId.getNodeIdentifier().getPrefix())) {
637 + id = "/" + tempNodeId.getNodeIdentifier().getPrefix() + ":" + tempNodeId.getNodeIdentifier()
638 + .getName();
639 + } else {
640 + id = "/" + tempNodeId.getNodeIdentifier().getName();
641 + }
642 + break;
643 + default:
644 + id = "/" + tempNodeId.getNodeIdentifier().getName();
645 + break;
646 + }
647 + builder.append(id);
592 } else { 648 } else {
593 return builder.toString(); 649 return builder.toString();
594 } 650 }
...@@ -603,11 +659,12 @@ public class YangXpathLinker<T> { ...@@ -603,11 +659,12 @@ public class YangXpathLinker<T> {
603 * @param tempNodeId node identifier 659 * @param tempNodeId node identifier
604 * @return target augment node 660 * @return target augment node
605 */ 661 */
662 +
606 private YangNode searchAugmentNode(YangNode node, String tempNodeId) { 663 private YangNode searchAugmentNode(YangNode node, String tempNodeId) {
607 node = node.getChild(); 664 node = node.getChild();
608 while (node != null) { 665 while (node != null) {
609 if (node instanceof YangAugment) { 666 if (node instanceof YangAugment) {
610 - if (((YangAugment) node).getName().equals(tempNodeId)) { 667 + if (node.getName().equals(tempNodeId)) {
611 return node; 668 return node;
612 } 669 }
613 } 670 }
...@@ -628,11 +685,11 @@ public class YangXpathLinker<T> { ...@@ -628,11 +685,11 @@ public class YangXpathLinker<T> {
628 int size = getAbsPaths().size(); 685 int size = getAbsPaths().size();
629 if (tempNode != null && index != size) { 686 if (tempNode != null && index != size) {
630 return true; 687 return true;
631 - } else if (tempNode != null && index == size) { 688 + } else if (tempNode != null) {
632 return false; 689 return false;
633 // this is your target node. 690 // this is your target node.
634 - } else if (tempNode == null && index != size) { 691 + } else if (index != size) {
635 - return false; 692 + return true;
636 // this could be in submodule as well. 693 // this could be in submodule as well.
637 } 694 }
638 return false; 695 return false;
...@@ -661,51 +718,52 @@ public class YangXpathLinker<T> { ...@@ -661,51 +718,52 @@ public class YangXpathLinker<T> {
661 } 718 }
662 719
663 /** 720 /**
664 - * Handles linking when uses node is present. 721 + * Returns root prefix.
665 * 722 *
666 - * @param node uses node 723 + * @param root root node
667 - * @param curNodeId current node id 724 + * @return root prefix
668 - * @return linked node
669 */ 725 */
670 - private YangNode handleUsesNode(YangNode node, YangNodeIdentifier curNodeId) { 726 + private String getRootsPrefix(YangNode root) {
671 - YangNode tempNode = null; 727 + if (root instanceof YangModule) {
672 - tempNode = searchInUsesNode((YangUses) node, curNodeId); 728 + return ((YangModule) root).getPrefix();
673 - if (tempNode != null) { 729 + } else {
674 - return tempNode; 730 + return ((YangSubModule) root).getPrefix();
675 } 731 }
676 - return null;
677 } 732 }
678 733
679 /** 734 /**
680 - * Searches target node in uses resolved list. 735 + * Resolves prefix and provides prefix resolver list.
681 * 736 *
682 - * @param uses uses node 737 + * @param absolutePaths absolute paths
683 - * @param curNodeId current node id
684 - * @return linked target node
685 */ 738 */
686 - private YangNode searchInUsesNode(YangUses uses, YangNodeIdentifier curNodeId) { 739 + private void parsePrefixResolverList(List<YangAtomicPath> absolutePaths) {
687 - 740 + Iterator<YangAtomicPath> pathIterator = absolutePaths.iterator();
688 - List<YangNode> resolvedNodes = uses.getUsesResolvedNodeList(); 741 + YangAtomicPath absPath;
689 - for (YangNode node : resolvedNodes) { 742 + String prePrefix;
690 - if (node.getName().equals(curNodeId.getName())) { 743 + String curPrefix = null;
691 - return node; 744 + while (pathIterator.hasNext()) {
692 - } 745 + prePrefix = curPrefix;
746 + absPath = pathIterator.next();
747 + curPrefix = absPath.getNodeIdentifier().getPrefix();
748 + if (curPrefix != null) {
749 + if (!curPrefix.equals(prePrefix)) {
750 + if (prePrefix != null) {
751 + addToPrefixResolverList(INTER_TO_INTER, absPath);
752 + } else {
753 + addToPrefixResolverList(INTRA_TO_INTER, absPath);
693 } 754 }
694 - return null; 755 + } else {
756 + addToPrefixResolverList(NO_PREFIX_CHANGE_FOR_INTER, absPath);
695 } 757 }
696 -
697 - /**
698 - * Returns root prefix.
699 - *
700 - * @param root root node
701 - * @return root prefix
702 - */
703 - private String getRootsPrefix(YangNode root) {
704 - if (root instanceof YangModule) {
705 - return ((YangModule) root).getPrefix();
706 } else { 758 } else {
707 - return ((YangSubModule) root).getPrefix(); 759 + if (prePrefix != null) {
760 + addToPrefixResolverList(INTER_TO_INTRA, absPath);
761 + } else {
762 + addToPrefixResolverList(NO_PREFIX_CHANGE_FOR_INTRA, absPath);
763 + }
708 } 764 }
709 } 765 }
710 766
767 + }
768 +
711 } 769 }
......
...@@ -21,11 +21,14 @@ import java.util.SortedSet; ...@@ -21,11 +21,14 @@ 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.YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS;
25 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG;
24 import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS; 26 import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS;
25 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 27 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
26 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER; 28 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER;
27 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_IMPORT_CLASS; 29 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_IMPORT_CLASS;
28 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_IMPORT_PKG; 30 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_IMPORT_PKG;
31 +import static org.onosproject.yangutils.utils.UtilConstants.HASH_MAP;
29 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; 32 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
30 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; 33 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
31 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_CLASS; 34 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_CLASS;
...@@ -33,6 +36,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IM ...@@ -33,6 +36,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IM
33 import static org.onosproject.yangutils.utils.UtilConstants.LIST; 36 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
34 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_REG; 37 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_REG;
35 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; 38 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE;
39 +import static org.onosproject.yangutils.utils.UtilConstants.MAP;
36 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 40 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
37 import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG; 41 import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG;
38 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 42 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
...@@ -248,4 +252,31 @@ public class JavaImportData { ...@@ -248,4 +252,31 @@ public class JavaImportData {
248 public String getEventListenerImport() { 252 public String getEventListenerImport() {
249 return IMPORT + ONOS_EVENT_PKG + PERIOD + EVENT_LISTENER + SEMI_COLAN + NEW_LINE; 253 return IMPORT + ONOS_EVENT_PKG + PERIOD + EVENT_LISTENER + SEMI_COLAN + NEW_LINE;
250 } 254 }
255 +
256 + /**
257 + * Returns import string for map class.
258 + *
259 + * @return import string for map class
260 + */
261 + public String getMapImport() {
262 + return IMPORT + COLLECTION_IMPORTS + PERIOD + MAP + SEMI_COLAN + NEW_LINE;
263 + }
264 +
265 + /**
266 + * Returns import string for hash map class.
267 + *
268 + * @return import string for hash map class
269 + */
270 + public String getHashMapImport() {
271 + return IMPORT + COLLECTION_IMPORTS + PERIOD + HASH_MAP + SEMI_COLAN + NEW_LINE;
272 + }
273 +
274 + /**
275 + * Returns import string for hash map class.
276 + *
277 + * @return import string for hash map class
278 + */
279 + public String getYangAugmentedInfoImport() {
280 + return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS;
281 + }
251 } 282 }
......
...@@ -189,8 +189,6 @@ public class TempJavaCodeFragmentFiles { ...@@ -189,8 +189,6 @@ public class TempJavaCodeFragmentFiles {
189 if (fileType == GENERATE_ENUM_CLASS) { 189 if (fileType == GENERATE_ENUM_CLASS) {
190 getEnumerationTempFiles().generateJavaFile(GENERATE_ENUM_CLASS, curNode); 190 getEnumerationTempFiles().generateJavaFile(GENERATE_ENUM_CLASS, curNode);
191 } 191 }
192 -
193 - freeTemporaryResources(false);
194 } 192 }
195 193
196 /** 194 /**
......
...@@ -17,16 +17,18 @@ package org.onosproject.yangutils.translator.tojava; ...@@ -17,16 +17,18 @@ package org.onosproject.yangutils.translator.tojava;
17 17
18 import java.io.File; 18 import java.io.File;
19 import java.io.IOException; 19 import java.io.IOException;
20 -import java.util.ArrayList;
21 import java.util.List; 20 import java.util.List;
22 21
23 -import org.onosproject.yangutils.datamodel.RpcNotificationContainer; 22 +import org.onosproject.yangutils.datamodel.YangAugmentableNode;
24 import org.onosproject.yangutils.datamodel.YangCase; 23 import org.onosproject.yangutils.datamodel.YangCase;
25 import org.onosproject.yangutils.datamodel.YangLeaf; 24 import org.onosproject.yangutils.datamodel.YangLeaf;
26 import org.onosproject.yangutils.datamodel.YangLeafList; 25 import org.onosproject.yangutils.datamodel.YangLeafList;
27 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 26 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
28 import org.onosproject.yangutils.datamodel.YangList; 27 import org.onosproject.yangutils.datamodel.YangList;
28 +import org.onosproject.yangutils.datamodel.YangModule;
29 import org.onosproject.yangutils.datamodel.YangNode; 29 import org.onosproject.yangutils.datamodel.YangNode;
30 +import org.onosproject.yangutils.datamodel.YangSubModule;
31 +import org.onosproject.yangutils.datamodel.YangUses;
30 import org.onosproject.yangutils.translator.exception.TranslatorException; 32 import org.onosproject.yangutils.translator.exception.TranslatorException;
31 import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; 33 import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer;
32 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; 34 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
...@@ -40,6 +42,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParent ...@@ -40,6 +42,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParent
40 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; 42 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
41 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; 43 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
42 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; 44 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
45 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
43 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 46 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
44 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS; 47 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS;
45 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; 48 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
...@@ -60,10 +63,12 @@ import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo. ...@@ -60,10 +63,12 @@ import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.
60 import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo; 63 import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo;
61 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination; 64 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination;
62 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; 65 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
66 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports;
63 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile; 67 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile;
64 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile; 68 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile;
65 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; 69 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile;
66 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; 70 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile;
71 +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports;
67 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; 72 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
68 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 73 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
69 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedConstructor; 74 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedConstructor;
...@@ -74,14 +79,11 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator ...@@ -74,14 +79,11 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator
74 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; 79 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
75 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString; 80 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString;
76 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod; 81 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod;
77 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethod;
78 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString; 82 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
79 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; 83 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
80 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString; 84 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
81 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod; 85 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod;
82 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString; 86 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString;
83 -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
84 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports;
85 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; 87 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE;
86 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 88 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
87 import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT; 89 import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT;
...@@ -100,9 +102,9 @@ import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALIT ...@@ -100,9 +102,9 @@ import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALIT
100 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 102 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
101 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; 103 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
102 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 104 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
105 +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
103 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; 106 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile;
104 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; 107 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
105 -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD;
106 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; 108 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
107 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; 109 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
108 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 110 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
...@@ -113,38 +115,12 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles ...@@ -113,38 +115,12 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles
113 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength; 115 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength;
114 116
115 /** 117 /**
116 - * Represents implementation of java code fragments temporary implementations. 118 + * Represents implementation of java code fragments temporary implementations. Manages the common temp file required for
117 - * Manages the common temp file required for Java file(s) generated. 119 + * Java file(s) generated.
118 */ 120 */
119 public class TempJavaFragmentFiles { 121 public class TempJavaFragmentFiles {
120 122
121 /** 123 /**
122 - * Information about the java files being generated.
123 - */
124 - private JavaFileInfo javaFileInfo;
125 -
126 - /**
127 - * Imported class info.
128 - */
129 - private JavaImportData javaImportData;
130 -
131 - /**
132 - * The variable which guides the types of temporary files generated using
133 - * the temporary generated file types mask.
134 - */
135 - private int generatedTempFiles;
136 -
137 - /**
138 - * Absolute path where the target java file needs to be generated.
139 - */
140 - private String absoluteDirPath;
141 -
142 - /**
143 - * Contains all the interface(s)/class name which will be extended by generated files.
144 - */
145 - private JavaExtendsListHolder javaExtendsListHolder;
146 -
147 - /**
148 * File type extension for java classes. 124 * File type extension for java classes.
149 */ 125 */
150 private static final String JAVA_FILE_EXTENSION = ".java"; 126 private static final String JAVA_FILE_EXTENSION = ".java";
...@@ -228,6 +204,32 @@ public class TempJavaFragmentFiles { ...@@ -228,6 +204,32 @@ public class TempJavaFragmentFiles {
228 * File name for augment copy constructor method. 204 * File name for augment copy constructor method.
229 */ 205 */
230 private static final String AUGMENT_CONSTRUCTOR_FILE_NAME = "AugmentConstructor"; 206 private static final String AUGMENT_CONSTRUCTOR_FILE_NAME = "AugmentConstructor";
207 +
208 + /**
209 + * Information about the java files being generated.
210 + */
211 + private JavaFileInfo javaFileInfo;
212 +
213 + /**
214 + * Imported class info.
215 + */
216 + private JavaImportData javaImportData;
217 +
218 + /**
219 + * The variable which guides the types of temporary files generated using the temporary generated file types mask.
220 + */
221 + private int generatedTempFiles;
222 +
223 + /**
224 + * Absolute path where the target java file needs to be generated.
225 + */
226 + private String absoluteDirPath;
227 +
228 + /**
229 + * Contains all the interface(s)/class name which will be extended by generated files.
230 + */
231 + private JavaExtendsListHolder javaExtendsListHolder;
232 +
231 /** 233 /**
232 * Java file handle for interface file. 234 * Java file handle for interface file.
233 */ 235 */
...@@ -308,327 +310,440 @@ public class TempJavaFragmentFiles { ...@@ -308,327 +310,440 @@ public class TempJavaFragmentFiles {
308 */ 310 */
309 private File augmentConstructorImplTempFileHandle; 311 private File augmentConstructorImplTempFileHandle;
310 312
311 - /** 313 + TempJavaFragmentFiles() {
312 - * Retrieves the absolute path where the file needs to be generated.
313 - *
314 - * @return absolute path where the file needs to be generated
315 - */
316 - private String getAbsoluteDirPath() {
317 - return absoluteDirPath;
318 } 314 }
319 315
320 /** 316 /**
321 - * Sets absolute path where the file needs to be generated. 317 + * Creates an instance of temporary java code fragment.
322 * 318 *
323 - * @param absoluteDirPath absolute path where the file needs to be 319 + * @param javaFileInfo generated java file information
324 - * generated. 320 + * @throws IOException when fails to create new file handle
325 */ 321 */
326 - void setAbsoluteDirPath(String absoluteDirPath) { 322 + TempJavaFragmentFiles(JavaFileInfo javaFileInfo)
327 - this.absoluteDirPath = absoluteDirPath; 323 + throws IOException {
328 - } 324 + setJavaExtendsListHolder(new JavaExtendsListHolder());
325 + setJavaImportData(new JavaImportData());
326 + setJavaFileInfo(javaFileInfo);
327 + setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
328 + getJavaFileInfo().getPackageFilePath()));
329 329
330 - /** 330 + /*
331 - * Sets the generated java file information. 331 + * Initialize getter when generation file type matches to interface
332 - * 332 + * mask.
333 - * @param javaFileInfo generated java file information
334 */ 333 */
335 - public void setJavaFileInfo(JavaFileInfo javaFileInfo) { 334 + if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) {
336 - this.javaFileInfo = javaFileInfo; 335 + addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK);
337 } 336 }
338 337
339 - /** 338 + /*
340 - * Retrieves the generated java file information. 339 + * Initialize getter and setter when generation file type matches to
341 - * 340 + * builder interface mask.
342 - * @return generated java file information
343 */ 341 */
344 - public JavaFileInfo getJavaFileInfo() { 342 + if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) {
345 - return javaFileInfo; 343 + addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK);
344 + addGeneratedTempFile(SETTER_FOR_INTERFACE_MASK);
346 } 345 }
347 346
348 - /** 347 + /*
349 - * Retrieves the generated temp files. 348 + * Initialize getterImpl, setterImpl and attributes when generation file
350 - * 349 + * type matches to builder class mask.
351 - * @return generated temp files
352 */ 350 */
353 - int getGeneratedTempFiles() { 351 + if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) {
354 - return generatedTempFiles; 352 + addGeneratedTempFile(ATTRIBUTES_MASK);
353 + addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
354 + addGeneratedTempFile(SETTER_FOR_CLASS_MASK);
355 + addGeneratedTempFile(AUGMENTE_CLASS_CONSTRUCTOR_MASK);
355 } 356 }
356 357
357 - /** 358 + /*
358 - * Clears the generated file mask. 359 + * Initialize getterImpl, attributes, constructor, hash code, equals and
360 + * to strings when generation file type matches to impl class mask.
359 */ 361 */
360 - void clearGeneratedTempFileMask() { 362 + if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) {
361 - generatedTempFiles = 0; 363 + addGeneratedTempFile(ATTRIBUTES_MASK);
364 + addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
365 + addGeneratedTempFile(HASH_CODE_IMPL_MASK);
366 + addGeneratedTempFile(EQUALS_IMPL_MASK);
367 + addGeneratedTempFile(TO_STRING_IMPL_MASK);
362 } 368 }
363 369
364 - /** 370 + /*
365 - * Adds to generated temporary files. 371 + * Initialize temp files to generate type class.
366 - *
367 - * @param generatedTempFile generated file
368 */ 372 */
369 - void addGeneratedTempFile(int generatedTempFile) { 373 + if ((getGeneratedJavaFiles() & GENERATE_TYPE_CLASS) != 0) {
370 - generatedTempFiles |= generatedTempFile; 374 + addGeneratedTempFile(ATTRIBUTES_MASK);
371 - setGeneratedTempFiles(generatedTempFiles); 375 + addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
376 + addGeneratedTempFile(HASH_CODE_IMPL_MASK);
377 + addGeneratedTempFile(EQUALS_IMPL_MASK);
378 + addGeneratedTempFile(TO_STRING_IMPL_MASK);
379 + addGeneratedTempFile(FROM_STRING_IMPL_MASK);
372 } 380 }
373 381
374 - /** 382 + /*
375 - * Sets generated file files. 383 + * Initialize temp files to generate enum class.
376 - *
377 - * @param fileType generated file type
378 */ 384 */
379 - void setGeneratedTempFiles(int fileType) { 385 + if ((getGeneratedJavaFiles() & GENERATE_ENUM_CLASS) != 0) {
380 - generatedTempFiles = fileType; 386 + addGeneratedTempFile(FROM_STRING_IMPL_MASK);
381 } 387 }
382 388
383 - /** 389 + /*
384 - * Retrieves the generated Java files. 390 + * Set temporary file handles.
385 - *
386 - * @return generated Java files
387 */ 391 */
388 - int getGeneratedJavaFiles() { 392 + if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) {
389 - return getJavaFileInfo().getGeneratedFileTypes(); 393 + setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME));
394 + }
395 +
396 + if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) {
397 + setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME));
398 + }
399 +
400 + if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) {
401 + setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME));
402 + }
403 +
404 + if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
405 + setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME));
406 + }
407 +
408 + if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) {
409 + setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME));
410 + }
411 +
412 + if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
413 + setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME));
414 + }
415 + if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) {
416 + setEqualsImplTempFileHandle(getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME));
417 + }
418 + if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) {
419 + setToStringImplTempFileHandle(getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME));
420 + }
421 + if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
422 + setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME));
423 + }
424 + if ((getGeneratedTempFiles() & AUGMENTE_CLASS_CONSTRUCTOR_MASK) != 0) {
425 + setAugmentConstructorImplTempFileHandle(getTemporaryFileHandle(AUGMENT_CONSTRUCTOR_FILE_NAME));
390 } 426 }
391 427
392 - /**
393 - * Retrieves the mapped Java class name.
394 - *
395 - * @return mapped Java class name
396 - */
397 - String getGeneratedJavaClassName() {
398 - return getCapitalCase(getJavaFileInfo().getJavaName());
399 } 428 }
400 429
401 /** 430 /**
402 - * Retrieves the import data for the generated Java file. 431 + * Adds current node info as and attribute to the parent generated file.
403 * 432 *
404 - * @return import data for the generated Java file 433 + * @param curNode current node which needs to be added as an attribute in the parent generated code
434 + * @param isList is list construct
435 + * @param pluginConfig plugin configurations
436 + * @throws IOException IO operation exception
405 */ 437 */
406 - public JavaImportData getJavaImportData() { 438 + public static void addCurNodeInfoInParentTempFile(YangNode curNode,
407 - return javaImportData; 439 + boolean isList, YangPluginConfig pluginConfig)
440 + throws IOException {
441 + YangNode parent = getParentNodeInGenCode(curNode);
442 + if (!(parent instanceof JavaCodeGenerator)) {
443 + throw new TranslatorException("missing parent node to contain current node info in generated file");
408 } 444 }
409 445
410 - /** 446 + if (parent instanceof YangJavaGrouping) {
411 - * Sets import data for the generated Java file. 447 + /*
412 - * 448 + * In case of grouping, there is no need to add the information, it
413 - * @param javaImportData import data for the generated Java file 449 + * will be taken care in uses
414 */ 450 */
415 - void setJavaImportData(JavaImportData javaImportData) { 451 + return;
416 - this.javaImportData = javaImportData; 452 + }
453 + TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) parent)
454 + .getTempJavaCodeFragmentFiles().getBeanTempFiles();
455 +
456 + JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode,
457 + parent, isList, tempJavaBeanFragmentFiles);
458 + if (!(parent instanceof TempJavaCodeFragmentFilesContainer)) {
459 + throw new TranslatorException("missing parent temp file handle");
460 + }
461 + getNodesInterfaceFragmentFiles(parent, javaAttributeInfo, pluginConfig);
417 } 462 }
418 463
419 /** 464 /**
420 - * Retrieves the status of any attributes added. 465 + * Creates an attribute info object corresponding to a data model node and return it.
421 * 466 *
422 - * @return status of any attributes added 467 + * @param curNode current data model node for which the java code generation is being handled
468 + * @param targetNode target node in which the current node is an attribute
469 + * @param isListNode is the current added attribute needs to be a list
470 + * @param tempJavaFragmentFiles temp java fragment files
471 + * @return AttributeInfo attribute details required to add in temporary files
423 */ 472 */
424 - public boolean isAttributePresent() { 473 + public static JavaAttributeInfo getCurNodeAsAttributeInTarget(YangNode curNode,
425 - return isAttributePresent; 474 + YangNode targetNode, boolean isListNode,
475 + TempJavaFragmentFiles tempJavaFragmentFiles) {
476 + String curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
477 + if (curNodeName == null) {
478 + updateJavaFileInfo(curNode, null);
479 + curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
426 } 480 }
427 481
428 - /** 482 + /*
429 - * Sets status of any attributes added. 483 + * Get the import info corresponding to the attribute for import in
430 - * 484 + * generated java files or qualified access
431 - * @param attributePresent status of any attributes added
432 */ 485 */
433 - public void setAttributePresent(boolean attributePresent) { 486 + JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
434 - isAttributePresent = attributePresent; 487 + getCapitalCase(curNodeName));
488 + if (!(targetNode instanceof TempJavaCodeFragmentFilesContainer)) {
489 + throw new TranslatorException("Parent node does not have file info");
490 + }
491 + JavaImportData parentImportData = tempJavaFragmentFiles.getJavaImportData();
492 + JavaFileInfo fileInfo = ((JavaFileInfoContainer) targetNode).getJavaFileInfo();
493 +
494 + boolean isQualified;
495 + if ((targetNode instanceof YangJavaModule || targetNode instanceof YangJavaSubModule)
496 + && (qualifiedTypeInfo.getClassInfo().contentEquals(SERVICE)
497 + || qualifiedTypeInfo.getClassInfo().contentEquals(COMPONENT)
498 + || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(ACTIVATE))
499 + || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(DEACTIVATE))
500 + || qualifiedTypeInfo.getClassInfo().contentEquals(REFERENCE_CARDINALITY)
501 + || qualifiedTypeInfo.getClassInfo().contentEquals(REFERENCE))
502 + || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))
503 + || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + MANAGER))) {
504 +
505 + isQualified = true;
506 + } else {
507 + String className;
508 + if (targetNode instanceof YangJavaModule || targetNode instanceof YangJavaSubModule) {
509 + className = getCapitalCase(fileInfo.getJavaName()) + "Service";
510 + } else {
511 + className = getCapitalCase(fileInfo.getJavaName());
512 + }
513 +
514 + isQualified = parentImportData.addImportInfo(qualifiedTypeInfo,
515 + className, fileInfo.getPackage());
516 + }
517 +
518 + if (isListNode) {
519 + parentImportData.setIfListImported(true);
520 + }
521 +
522 + return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode);
435 } 523 }
436 524
437 /** 525 /**
438 - * Returns getter methods's temporary file handle. 526 + * Adds java code snippet for corresponding files.
439 * 527 *
440 - * @return temporary file handle 528 + * @param node java node
529 + * @param attr attribute info
530 + * @param config plugin configurations
531 + * @throws IOException when fails to do IO operations
441 */ 532 */
442 - public File getGetterInterfaceTempFileHandle() { 533 + public static void getNodesInterfaceFragmentFiles(YangNode node, JavaAttributeInfo attr,
443 - return getterInterfaceTempFileHandle; 534 + YangPluginConfig config) throws IOException {
535 + TempJavaFragmentFiles tempJavaFragmentFiles;
536 + JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo();
537 + if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_SERVICE_AND_MANAGER) != 0) {
538 + tempJavaFragmentFiles = ((TempJavaCodeFragmentFilesContainer) node)
539 + .getTempJavaCodeFragmentFiles()
540 + .getServiceTempFiles();
541 + tempJavaFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(attr, config);
542 + }
543 + if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_INTERFACE_WITH_BUILDER) != 0) {
544 + tempJavaFragmentFiles = ((TempJavaCodeFragmentFilesContainer) node)
545 + .getTempJavaCodeFragmentFiles()
546 + .getBeanTempFiles();
547 + tempJavaFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(attr, config);
548 + }
549 +
444 } 550 }
445 551
446 /** 552 /**
447 - * Sets to getter method's temporary file handle. 553 + * Retrieves the absolute path where the file needs to be generated.
448 * 554 *
449 - * @param getterForInterface file handle for to getter method 555 + * @return absolute path where the file needs to be generated
450 */ 556 */
451 - private void setGetterInterfaceTempFileHandle(File getterForInterface) { 557 + private String getAbsoluteDirPath() {
452 - getterInterfaceTempFileHandle = getterForInterface; 558 + return absoluteDirPath;
453 } 559 }
454 560
455 /** 561 /**
456 - * Returns setter method's temporary file handle. 562 + * Sets absolute path where the file needs to be generated.
457 * 563 *
458 - * @return temporary file handle 564 + * @param absoluteDirPath absolute path where the file needs to be generated.
459 */ 565 */
460 - public File getSetterInterfaceTempFileHandle() { 566 + void setAbsoluteDirPath(String absoluteDirPath) {
461 - return setterInterfaceTempFileHandle; 567 + this.absoluteDirPath = absoluteDirPath;
462 } 568 }
463 569
464 /** 570 /**
465 - * Sets to setter method's temporary file handle. 571 + * Retrieves the generated java file information.
466 * 572 *
467 - * @param setterForInterface file handle for to setter method 573 + * @return generated java file information
468 */ 574 */
469 - private void setSetterInterfaceTempFileHandle(File setterForInterface) { 575 + public JavaFileInfo getJavaFileInfo() {
470 - setterInterfaceTempFileHandle = setterForInterface; 576 + return javaFileInfo;
471 } 577 }
472 578
473 /** 579 /**
474 - * Returns setter method's impl's temporary file handle. 580 + * Sets the generated java file information.
475 * 581 *
476 - * @return temporary file handle 582 + * @param javaFileInfo generated java file information
477 */ 583 */
478 - public File getSetterImplTempFileHandle() { 584 + public void setJavaFileInfo(JavaFileInfo javaFileInfo) {
479 - return setterImplTempFileHandle; 585 + this.javaFileInfo = javaFileInfo;
480 } 586 }
481 587
482 /** 588 /**
483 - * Sets to setter method's impl's temporary file handle. 589 + * Retrieves the generated temp files.
484 * 590 *
485 - * @param setterImpl file handle for to setter method's implementation class 591 + * @return generated temp files
486 */ 592 */
487 - private void setSetterImplTempFileHandle(File setterImpl) { 593 + int getGeneratedTempFiles() {
488 - setterImplTempFileHandle = setterImpl; 594 + return generatedTempFiles;
489 } 595 }
490 596
491 /** 597 /**
492 - * Returns from string method's temporary file handle. 598 + * Sets generated file files.
493 * 599 *
494 - * @return from string method's temporary file handle 600 + * @param fileType generated file type
495 */ 601 */
496 - public File getFromStringImplTempFileHandle() { 602 + void setGeneratedTempFiles(int fileType) {
497 - return fromStringImplTempFileHandle; 603 + generatedTempFiles = fileType;
498 } 604 }
499 605
500 /** 606 /**
501 - * Sets from string method's temporary file handle. 607 + * Clears the generated file mask.
502 - *
503 - * @param fromStringImplTempFileHandle from string method's temporary file
504 - * handle
505 */ 608 */
506 - private void setFromStringImplTempFileHandle(File fromStringImplTempFileHandle) { 609 + void clearGeneratedTempFileMask() {
507 - this.fromStringImplTempFileHandle = fromStringImplTempFileHandle; 610 + generatedTempFiles = 0;
508 } 611 }
509 612
510 /** 613 /**
511 - * Creates an instance of temporary java code fragment. 614 + * Adds to generated temporary files.
512 * 615 *
513 - * @param javaFileInfo generated java file information 616 + * @param generatedTempFile generated file
514 - * @throws IOException when fails to create new file handle
515 - */
516 - TempJavaFragmentFiles(JavaFileInfo javaFileInfo)
517 - throws IOException {
518 - setJavaExtendsListHolder(new JavaExtendsListHolder());
519 - setJavaImportData(new JavaImportData());
520 - setJavaFileInfo(javaFileInfo);
521 - setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
522 - getJavaFileInfo().getPackageFilePath()));
523 -
524 - /*
525 - * Initialize getter when generation file type matches to interface
526 - * mask.
527 */ 617 */
528 - if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) { 618 + void addGeneratedTempFile(int generatedTempFile) {
529 - addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK); 619 + generatedTempFiles |= generatedTempFile;
620 + setGeneratedTempFiles(generatedTempFiles);
530 } 621 }
531 622
532 - /* 623 + /**
533 - * Initialize getter and setter when generation file type matches to 624 + * Retrieves the generated Java files.
534 - * builder interface mask. 625 + *
626 + * @return generated Java files
535 */ 627 */
536 - if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) { 628 + int getGeneratedJavaFiles() {
537 - addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK); 629 + return getJavaFileInfo().getGeneratedFileTypes();
538 - addGeneratedTempFile(SETTER_FOR_INTERFACE_MASK);
539 } 630 }
540 631
541 - /* 632 + /**
542 - * Initialize getterImpl, setterImpl and attributes when generation file 633 + * Retrieves the mapped Java class name.
543 - * type matches to builder class mask. 634 + *
635 + * @return mapped Java class name
544 */ 636 */
545 - if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { 637 + String getGeneratedJavaClassName() {
546 - addGeneratedTempFile(ATTRIBUTES_MASK); 638 + return getCapitalCase(getJavaFileInfo().getJavaName());
547 - addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
548 - addGeneratedTempFile(SETTER_FOR_CLASS_MASK);
549 - addGeneratedTempFile(AUGMENTE_CLASS_CONSTRUCTOR_MASK);
550 } 639 }
551 640
552 - /* 641 + /**
553 - * Initialize getterImpl, attributes, constructor, hash code, equals and 642 + * Retrieves the import data for the generated Java file.
554 - * to strings when generation file type matches to impl class mask. 643 + *
644 + * @return import data for the generated Java file
555 */ 645 */
556 - if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) { 646 + public JavaImportData getJavaImportData() {
557 - addGeneratedTempFile(ATTRIBUTES_MASK); 647 + return javaImportData;
558 - addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
559 - addGeneratedTempFile(HASH_CODE_IMPL_MASK);
560 - addGeneratedTempFile(EQUALS_IMPL_MASK);
561 - addGeneratedTempFile(TO_STRING_IMPL_MASK);
562 } 648 }
563 649
564 - /* 650 + /**
565 - * Initialize temp files to generate type class. 651 + * Sets import data for the generated Java file.
566 - */ 652 + *
567 - if ((getGeneratedJavaFiles() & GENERATE_TYPE_CLASS) != 0) { 653 + * @param javaImportData import data for the generated Java file
568 - addGeneratedTempFile(ATTRIBUTES_MASK); 654 + */
569 - addGeneratedTempFile(GETTER_FOR_CLASS_MASK); 655 + void setJavaImportData(JavaImportData javaImportData) {
570 - addGeneratedTempFile(HASH_CODE_IMPL_MASK); 656 + this.javaImportData = javaImportData;
571 - addGeneratedTempFile(EQUALS_IMPL_MASK);
572 - addGeneratedTempFile(TO_STRING_IMPL_MASK);
573 - addGeneratedTempFile(FROM_STRING_IMPL_MASK);
574 } 657 }
575 658
576 - /* 659 + /**
577 - * Initialize temp files to generate enum class. 660 + * Retrieves the status of any attributes added.
661 + *
662 + * @return status of any attributes added
578 */ 663 */
579 - if ((getGeneratedJavaFiles() & GENERATE_ENUM_CLASS) != 0) { 664 + public boolean isAttributePresent() {
580 - addGeneratedTempFile(FROM_STRING_IMPL_MASK); 665 + return isAttributePresent;
581 } 666 }
582 - /* 667 +
583 - * Initialize getter and setter when generation file type matches to 668 + /**
584 - * builder interface mask. 669 + * Sets status of any attributes added.
670 + *
671 + * @param attributePresent status of any attributes added
585 */ 672 */
586 - if ((getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) { 673 + public void setAttributePresent(boolean attributePresent) {
587 - addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK); 674 + isAttributePresent = attributePresent;
588 - addGeneratedTempFile(SETTER_FOR_INTERFACE_MASK);
589 - addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
590 - addGeneratedTempFile(SETTER_FOR_CLASS_MASK);
591 } 675 }
592 676
593 - /* 677 + /**
594 - * Set temporary file handles. 678 + * Returns getter methods's temporary file handle.
679 + *
680 + * @return temporary file handle
595 */ 681 */
596 - if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) { 682 + public File getGetterInterfaceTempFileHandle() {
597 - setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME)); 683 + return getterInterfaceTempFileHandle;
598 } 684 }
599 685
600 - if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) { 686 + /**
601 - setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME)); 687 + * Sets to getter method's temporary file handle.
688 + *
689 + * @param getterForInterface file handle for to getter method
690 + */
691 + private void setGetterInterfaceTempFileHandle(File getterForInterface) {
692 + getterInterfaceTempFileHandle = getterForInterface;
602 } 693 }
603 694
604 - if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) { 695 + /**
605 - setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME)); 696 + * Returns setter method's temporary file handle.
697 + *
698 + * @return temporary file handle
699 + */
700 + public File getSetterInterfaceTempFileHandle() {
701 + return setterInterfaceTempFileHandle;
606 } 702 }
607 703
608 - if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) { 704 + /**
609 - setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME)); 705 + * Sets to setter method's temporary file handle.
706 + *
707 + * @param setterForInterface file handle for to setter method
708 + */
709 + private void setSetterInterfaceTempFileHandle(File setterForInterface) {
710 + setterInterfaceTempFileHandle = setterForInterface;
610 } 711 }
611 712
612 - if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) { 713 + /**
613 - setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME)); 714 + * Returns setter method's impl's temporary file handle.
715 + *
716 + * @return temporary file handle
717 + */
718 + public File getSetterImplTempFileHandle() {
719 + return setterImplTempFileHandle;
614 } 720 }
615 721
616 - if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { 722 + /**
617 - setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME)); 723 + * Sets to setter method's impl's temporary file handle.
618 - } 724 + *
619 - if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) { 725 + * @param setterImpl file handle for to setter method's implementation class
620 - setEqualsImplTempFileHandle(getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME)); 726 + */
621 - } 727 + private void setSetterImplTempFileHandle(File setterImpl) {
622 - if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) { 728 + setterImplTempFileHandle = setterImpl;
623 - setToStringImplTempFileHandle(getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME));
624 - }
625 - if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
626 - setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME));
627 } 729 }
628 - if ((getGeneratedTempFiles() & AUGMENTE_CLASS_CONSTRUCTOR_MASK) != 0) { 730 +
629 - setAugmentConstructorImplTempFileHandle(getTemporaryFileHandle(AUGMENT_CONSTRUCTOR_FILE_NAME)); 731 + /**
732 + * Returns from string method's temporary file handle.
733 + *
734 + * @return from string method's temporary file handle
735 + */
736 + public File getFromStringImplTempFileHandle() {
737 + return fromStringImplTempFileHandle;
630 } 738 }
631 739
740 + /**
741 + * Sets from string method's temporary file handle.
742 + *
743 + * @param fromStringImplTempFileHandle from string method's temporary file handle
744 + */
745 + private void setFromStringImplTempFileHandle(File fromStringImplTempFileHandle) {
746 + this.fromStringImplTempFileHandle = fromStringImplTempFileHandle;
632 } 747 }
633 748
634 /** 749 /**
...@@ -942,19 +1057,6 @@ public class TempJavaFragmentFiles { ...@@ -942,19 +1057,6 @@ public class TempJavaFragmentFiles {
942 } 1057 }
943 1058
944 /** 1059 /**
945 - * Adds default constructor for class.
946 - *
947 - * @param pluginCnfig plugin configurations
948 - * @return default constructor for class
949 - * @throws IOException when fails to append to file
950 - */
951 - public String addOfMethod(YangPluginConfig pluginCnfig)
952 - throws IOException {
953 - return getJavaDoc(OF_METHOD, getGeneratedJavaClassName(), false, pluginCnfig)
954 - + getOfMethod(getGeneratedJavaClassName(), null);
955 - }
956 -
957 - /**
958 * Adds hash code method for class. 1060 * Adds hash code method for class.
959 * 1061 *
960 * @param attr attribute info 1062 * @param attr attribute info
...@@ -1117,159 +1219,6 @@ public class TempJavaFragmentFiles { ...@@ -1117,159 +1219,6 @@ public class TempJavaFragmentFiles {
1117 } 1219 }
1118 1220
1119 /** 1221 /**
1120 - * Adds current node info as and attribute to the parent generated file.
1121 - *
1122 - * @param curNode current node which needs to be added as an attribute in
1123 - * the parent generated code
1124 - * @param isList is list construct
1125 - * @param pluginConfig plugin configurations
1126 - * @throws IOException IO operation exception
1127 - */
1128 - public static void addCurNodeInfoInParentTempFile(YangNode curNode,
1129 - boolean isList, YangPluginConfig pluginConfig)
1130 - throws IOException {
1131 - YangNode parent = getParentNodeInGenCode(curNode);
1132 - if (!(parent instanceof JavaCodeGenerator)) {
1133 - throw new TranslatorException("missing parent node to contain current node info in generated file");
1134 - }
1135 -
1136 - if (parent instanceof YangJavaGrouping) {
1137 - /*
1138 - * In case of grouping, there is no need to add the information, it
1139 - * will be taken care in uses
1140 - */
1141 - return;
1142 - }
1143 -
1144 - JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode,
1145 - parent, isList);
1146 - if (!(parent instanceof TempJavaCodeFragmentFilesContainer)) {
1147 - throw new TranslatorException("missing parent temp file handle");
1148 - }
1149 - getNodesInterfaceFragmentFiles(parent)
1150 - .addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig);
1151 - }
1152 -
1153 - /**
1154 - * Adds current node info as and attribute to the parent generated file.
1155 - *
1156 - * @param curNode current node which needs to be added as an attribute in
1157 - * the parent generated code
1158 - * @param pluginConfig plugin configurations
1159 - * @param targetNode target node to add the attribute
1160 - * @throws IOException IO operation exception
1161 - */
1162 - public static void addCurNodeAsAttributeInTargetTempFile(YangNode curNode,
1163 - YangPluginConfig pluginConfig, YangNode targetNode)
1164 - throws IOException {
1165 -
1166 - if (!(targetNode instanceof JavaCodeGenerator)) {
1167 - throw new TranslatorException("invalid target node to generated file");
1168 - }
1169 -
1170 - if (targetNode instanceof YangJavaGrouping) {
1171 - /*
1172 - * In case of grouping, there is no need to add the information, it
1173 - * will be taken care in uses
1174 - */
1175 - return;
1176 - }
1177 -
1178 - boolean isList = curNode instanceof YangList;
1179 -
1180 - JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode,
1181 - targetNode, isList);
1182 - if (!(targetNode instanceof TempJavaCodeFragmentFilesContainer)) {
1183 - throw new TranslatorException("missing target node's temp file handle");
1184 - }
1185 - getNodesInterfaceFragmentFiles(targetNode)
1186 - .addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig);
1187 - }
1188 -
1189 - /**
1190 - * Creates an attribute info object corresponding to a data model node and
1191 - * return it.
1192 - *
1193 - * @param curNode current data model node for which the java code generation
1194 - * is being handled
1195 - * @param targetNode target node in which the current node is an attribute
1196 - * @param isListNode is the current added attribute needs to be a list
1197 - * @return AttributeInfo attribute details required to add in temporary
1198 - * files
1199 - */
1200 - public static JavaAttributeInfo getCurNodeAsAttributeInTarget(YangNode curNode,
1201 - YangNode targetNode, boolean isListNode) {
1202 - String curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
1203 - if (curNodeName == null) {
1204 - updateJavaFileInfo(curNode, null);
1205 - curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
1206 - }
1207 -
1208 - /*
1209 - * Get the import info corresponding to the attribute for import in
1210 - * generated java files or qualified access
1211 - */
1212 - JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
1213 - getCapitalCase(curNodeName));
1214 - if (!(targetNode instanceof TempJavaCodeFragmentFilesContainer)) {
1215 - throw new TranslatorException("Parent node does not have file info");
1216 - }
1217 - TempJavaFragmentFiles tempJavaFragmentFiles = getNodesInterfaceFragmentFiles(targetNode);
1218 - JavaImportData parentImportData = tempJavaFragmentFiles.getJavaImportData();
1219 - JavaFileInfo fileInfo = ((JavaFileInfoContainer) targetNode).getJavaFileInfo();
1220 -
1221 - boolean isQualified;
1222 - if ((targetNode instanceof YangJavaModule || targetNode instanceof YangJavaSubModule)
1223 - && (qualifiedTypeInfo.getClassInfo().contentEquals(SERVICE)
1224 - || qualifiedTypeInfo.getClassInfo().contentEquals(COMPONENT)
1225 - || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(ACTIVATE))
1226 - || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(DEACTIVATE))
1227 - || qualifiedTypeInfo.getClassInfo().contentEquals(REFERENCE_CARDINALITY)
1228 - || qualifiedTypeInfo.getClassInfo().contentEquals(REFERENCE))
1229 - || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))
1230 - || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + MANAGER))) {
1231 -
1232 - isQualified = true;
1233 - } else {
1234 - String className;
1235 - if (targetNode instanceof YangJavaModule || targetNode instanceof YangJavaSubModule) {
1236 - className = getCapitalCase(fileInfo.getJavaName()) + "Service";
1237 - } else {
1238 - className = getCapitalCase(fileInfo.getJavaName());
1239 - }
1240 -
1241 - isQualified = parentImportData.addImportInfo(qualifiedTypeInfo,
1242 - className, fileInfo.getPackage());
1243 - }
1244 -
1245 - if (isListNode) {
1246 - parentImportData.setIfListImported(true);
1247 - }
1248 -
1249 - return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode);
1250 - }
1251 -
1252 - /**
1253 - * Returns interface fragment files for node.
1254 - *
1255 - * @param node YANG node
1256 - * @return interface fragment files for node
1257 - */
1258 - public static TempJavaFragmentFiles getNodesInterfaceFragmentFiles(YangNode node) {
1259 - TempJavaFragmentFiles tempJavaFragmentFiles;
1260 - if (node instanceof RpcNotificationContainer) {
1261 - tempJavaFragmentFiles = ((TempJavaCodeFragmentFilesContainer) node)
1262 - .getTempJavaCodeFragmentFiles()
1263 - .getServiceTempFiles();
1264 - } else {
1265 - tempJavaFragmentFiles = ((TempJavaCodeFragmentFilesContainer) node)
1266 - .getTempJavaCodeFragmentFiles()
1267 - .getBeanTempFiles();
1268 - }
1269 - return tempJavaFragmentFiles;
1270 - }
1271 -
1272 - /**
1273 * Adds parent's info to current node import list. 1222 * Adds parent's info to current node import list.
1274 * 1223 *
1275 * @param curNode current node for which import list needs to be updated 1224 * @param curNode current node for which import list needs to be updated
...@@ -1378,8 +1327,7 @@ public class TempJavaFragmentFiles { ...@@ -1378,8 +1327,7 @@ public class TempJavaFragmentFiles {
1378 } 1327 }
1379 1328
1380 /** 1329 /**
1381 - * Adds all the leaves in the current data model node as part of the 1330 + * Adds all the leaves in the current data model node as part of the generated temporary file.
1382 - * generated temporary file.
1383 * 1331 *
1384 * @param curNode java file info of the generated file 1332 * @param curNode java file info of the generated file
1385 * @param yangPluginConfig plugin config 1333 * @param yangPluginConfig plugin config
...@@ -1399,8 +1347,7 @@ public class TempJavaFragmentFiles { ...@@ -1399,8 +1347,7 @@ public class TempJavaFragmentFiles {
1399 /** 1347 /**
1400 * Adds the new attribute info to the target generated temporary files. 1348 * Adds the new attribute info to the target generated temporary files.
1401 * 1349 *
1402 - * @param newAttrInfo the attribute info that needs to be added to temporary 1350 + * @param newAttrInfo the attribute info that needs to be added to temporary files
1403 - * files
1404 * @param pluginConfig plugin configurations 1351 * @param pluginConfig plugin configurations
1405 * @throws IOException IO operation fail 1352 * @throws IOException IO operation fail
1406 */ 1353 */
...@@ -1489,8 +1436,12 @@ public class TempJavaFragmentFiles { ...@@ -1489,8 +1436,12 @@ public class TempJavaFragmentFiles {
1489 */ 1436 */
1490 public void generateJavaFile(int fileType, YangNode curNode) 1437 public void generateJavaFile(int fileType, YangNode curNode)
1491 throws IOException { 1438 throws IOException {
1492 - List<String> imports = new ArrayList<>(); 1439 +
1493 - imports = getJavaImportData().getImports(); 1440 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
1441 + addResolvedAugmentedDataNodeImports(curNode);
1442 + }
1443 + List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles()
1444 + .getJavaImportData().getImports();
1494 1445
1495 JavaFileInfo curInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); 1446 JavaFileInfo curInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
1496 1447
...@@ -1543,7 +1494,10 @@ public class TempJavaFragmentFiles { ...@@ -1543,7 +1494,10 @@ public class TempJavaFragmentFiles {
1543 } 1494 }
1544 if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & IMPL_CLASS_MASK) != 0) { 1495 if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & IMPL_CLASS_MASK) != 0) {
1545 if (isAttributePresent()) { 1496 if (isAttributePresent()) {
1546 - addImportsToStringAndHasCodeMethods(curNode, imports); 1497 + addImportsToStringAndHasCodeMethods(imports);
1498 + }
1499 + if (curNode instanceof YangAugmentableNode) {
1500 + addImportsForAugmentableClass(imports);
1547 } 1501 }
1548 sortImports(imports); 1502 sortImports(imports);
1549 /* 1503 /*
...@@ -1586,6 +1540,8 @@ public class TempJavaFragmentFiles { ...@@ -1586,6 +1540,8 @@ public class TempJavaFragmentFiles {
1586 throws IOException { 1540 throws IOException {
1587 YangJavaAugment augment = (YangJavaAugment) curNode; 1541 YangJavaAugment augment = (YangJavaAugment) curNode;
1588 1542
1543 + TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
1544 + .getTempJavaCodeFragmentFiles().getBeanTempFiles();
1589 YangNode augmentedNode = augment.getAugmentedNode(); 1545 YangNode augmentedNode = augment.getAugmentedNode();
1590 if (augmentedNode instanceof YangLeavesHolder) { 1546 if (augmentedNode instanceof YangLeavesHolder) {
1591 YangLeavesHolder holder = (YangLeavesHolder) augmentedNode; 1547 YangLeavesHolder holder = (YangLeavesHolder) augmentedNode;
...@@ -1610,7 +1566,10 @@ public class TempJavaFragmentFiles { ...@@ -1610,7 +1566,10 @@ public class TempJavaFragmentFiles {
1610 if (augmentedNode instanceof YangList) { 1566 if (augmentedNode instanceof YangList) {
1611 isList = true; 1567 isList = true;
1612 } 1568 }
1613 - addAugmentConstructor(getCurNodeAsAttributeInTarget(augmentedNode, augment, isList), pluginConfig); 1569 + if (!(augmentedNode instanceof YangUses)) {
1570 + addAugmentConstructor(getCurNodeAsAttributeInTarget(augmentedNode, augment, isList,
1571 + tempJavaBeanFragmentFiles), pluginConfig);
1572 + }
1614 augmentedNode = augmentedNode.getNextSibling(); 1573 augmentedNode = augmentedNode.getNextSibling();
1615 } 1574 }
1616 1575
...@@ -1619,14 +1578,23 @@ public class TempJavaFragmentFiles { ...@@ -1619,14 +1578,23 @@ public class TempJavaFragmentFiles {
1619 /** 1578 /**
1620 * Adds imports for ToString and HashCodeMethod. 1579 * Adds imports for ToString and HashCodeMethod.
1621 * 1580 *
1622 - * @param curNode current YANG node
1623 * @param imports import list 1581 * @param imports import list
1624 - * @return import list
1625 */ 1582 */
1626 - public List<String> addImportsToStringAndHasCodeMethods(YangNode curNode, List<String> imports) { 1583 + public void addImportsToStringAndHasCodeMethods(List<String> imports) {
1627 imports.add(getJavaImportData().getImportForHashAndEquals()); 1584 imports.add(getJavaImportData().getImportForHashAndEquals());
1628 imports.add(getJavaImportData().getImportForToString()); 1585 imports.add(getJavaImportData().getImportForToString());
1629 - return imports; 1586 + }
1587 +
1588 +
1589 + /**
1590 + * Adds import for map and hash map.
1591 + *
1592 + * @param imports import list
1593 + */
1594 + public void addImportsForAugmentableClass(List<String> imports) {
1595 + imports.add(getJavaImportData().getHashMapImport());
1596 + imports.add(getJavaImportData().getMapImport());
1597 + imports.add(getJavaImportData().getYangAugmentedInfoImport());
1630 } 1598 }
1631 1599
1632 /** 1600 /**
...@@ -1636,7 +1604,7 @@ public class TempJavaFragmentFiles { ...@@ -1636,7 +1604,7 @@ public class TempJavaFragmentFiles {
1636 * @return import for class 1604 * @return import for class
1637 */ 1605 */
1638 private List<String> removeAugmentedImport(List<String> imports, JavaQualifiedTypeInfo augmentedInfo) { 1606 private List<String> removeAugmentedImport(List<String> imports, JavaQualifiedTypeInfo augmentedInfo) {
1639 - String augmentedNodeImport = null; 1607 + String augmentedNodeImport;
1640 if (imports != null && augmentedInfo != null) { 1608 if (imports != null && augmentedInfo != null) {
1641 augmentedNodeImport = IMPORT + augmentedInfo.getPkgInfo() + PERIOD + getCapitalCase(DEFAULT) 1609 augmentedNodeImport = IMPORT + augmentedInfo.getPkgInfo() + PERIOD + getCapitalCase(DEFAULT)
1642 + augmentedInfo.getClassInfo() + PERIOD + augmentedInfo.getClassInfo() 1610 + augmentedInfo.getClassInfo() + PERIOD + augmentedInfo.getClassInfo()
...@@ -1646,6 +1614,7 @@ public class TempJavaFragmentFiles { ...@@ -1646,6 +1614,7 @@ public class TempJavaFragmentFiles {
1646 + augmentedInfo.getClassInfo() + PERIOD + augmentedInfo.getClassInfo() 1614 + augmentedInfo.getClassInfo() + PERIOD + augmentedInfo.getClassInfo()
1647 + BUILDER + SEMI_COLAN + NEW_LINE; 1615 + BUILDER + SEMI_COLAN + NEW_LINE;
1648 imports.remove(augmentedNodeImport); 1616 imports.remove(augmentedNodeImport);
1617 + imports.remove(getJavaImportData().getYangAugmentedInfoImport());
1649 } 1618 }
1650 return imports; 1619 return imports;
1651 } 1620 }
...@@ -1668,9 +1637,8 @@ public class TempJavaFragmentFiles { ...@@ -1668,9 +1637,8 @@ public class TempJavaFragmentFiles {
1668 /** 1637 /**
1669 * Removes all temporary file handles. 1638 * Removes all temporary file handles.
1670 * 1639 *
1671 - * @param isErrorOccurred when translator fails to generate java files we 1640 + * @param isErrorOccurred when translator fails to generate java files we need to close all open file handles
1672 - * need to close all open file handles include temporary files 1641 + * include temporary files and java files.
1673 - * and java files.
1674 * @throws IOException when failed to delete the temporary files 1642 * @throws IOException when failed to delete the temporary files
1675 */ 1643 */
1676 public void freeTemporaryResources(boolean isErrorOccurred) 1644 public void freeTemporaryResources(boolean isErrorOccurred)
...@@ -1719,8 +1687,8 @@ public class TempJavaFragmentFiles { ...@@ -1719,8 +1687,8 @@ public class TempJavaFragmentFiles {
1719 } 1687 }
1720 1688
1721 /** 1689 /**
1722 - * Returns if the attribute needs to be accessed in a qualified manner or 1690 + * Returns if the attribute needs to be accessed in a qualified manner or not, if it needs to be imported, then the
1723 - * not, if it needs to be imported, then the same needs to be done. 1691 + * same needs to be done.
1724 * 1692 *
1725 * @param importInfo import info for the current attribute being added 1693 * @param importInfo import info for the current attribute being added
1726 * @return status of the qualified access to the attribute 1694 * @return status of the qualified access to the attribute
...@@ -1732,16 +1700,4 @@ public class TempJavaFragmentFiles { ...@@ -1732,16 +1700,4 @@ public class TempJavaFragmentFiles {
1732 getJavaFileInfo().getPackage()); 1700 getJavaFileInfo().getPackage());
1733 } 1701 }
1734 1702
1735 - /**
1736 - * Checks if the import info is same as the package of the current generated
1737 - * java file.
1738 - *
1739 - * @param importInfo import info for an attribute
1740 - * @return true if the import info is same as the current nodes package
1741 - * false otherwise
1742 - */
1743 - public boolean isImportPkgEqualCurNodePkg(JavaQualifiedTypeInfo importInfo) {
1744 - return getJavaFileInfo().getPackage()
1745 - .contentEquals(importInfo.getPkgInfo());
1746 - }
1747 } 1703 }
......
...@@ -22,9 +22,9 @@ import java.util.ArrayList; ...@@ -22,9 +22,9 @@ import java.util.ArrayList;
22 import java.util.List; 22 import java.util.List;
23 23
24 import org.onosproject.yangutils.datamodel.YangNode; 24 import org.onosproject.yangutils.datamodel.YangNode;
25 -import org.onosproject.yangutils.datamodel.YangNotification;
26 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; 25 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
27 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; 26 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
27 +import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
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_LISTENER_INTERFACE; 30 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
...@@ -38,6 +38,8 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. ...@@ -38,6 +38,8 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.
38 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK; 38 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK;
39 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; 39 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
40 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; 40 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode;
41 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAnnotationsImports;
42 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addListenersImport;
41 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; 43 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
42 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventFile; 44 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventFile;
43 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventListenerFile; 45 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventListenerFile;
...@@ -45,17 +47,12 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato ...@@ -45,17 +47,12 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato
45 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile; 47 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile;
46 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile; 48 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile;
47 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; 49 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
48 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 50 +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
49 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
50 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; 51 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
51 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
52 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; 52 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
53 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; 53 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod;
54 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; 54 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod;
55 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; 55 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
56 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAnnotationsImports;
57 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addListenersImport;
58 -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
59 import static org.onosproject.yangutils.utils.UtilConstants.COMMA; 56 import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
60 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 57 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
61 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; 58 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
...@@ -66,22 +63,30 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; ...@@ -66,22 +63,30 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
66 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; 63 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
67 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 64 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
68 import static org.onosproject.yangutils.utils.UtilConstants.VOID; 65 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
69 -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 66 +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
70 -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc;
71 -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
72 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; 67 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE;
73 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; 68 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
74 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD; 69 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD;
70 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc;
71 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
72 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
73 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
74 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
75 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
75 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; 76 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
76 77
77 /** 78 /**
78 - * Represents implementation of java service code fragments temporary implementations. 79 + * Represents implementation of java service code fragments temporary implementations. Maintains the temp files required
79 - * Maintains the temp files required specific for service and manager java snippet generation. 80 + * specific for service and manager java snippet generation.
80 */ 81 */
81 public class TempJavaServiceFragmentFiles 82 public class TempJavaServiceFragmentFiles
82 extends TempJavaFragmentFiles { 83 extends TempJavaFragmentFiles {
83 84
84 /** 85 /**
86 + * File name for generated class file for special type like union, typedef suffix.
87 + */
88 + public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject";
89 + /**
85 * File name for rpc method. 90 * File name for rpc method.
86 */ 91 */
87 private static final String RPC_INTERFACE_FILE_NAME = "Rpc"; 92 private static final String RPC_INTERFACE_FILE_NAME = "Rpc";
...@@ -139,13 +144,6 @@ public class TempJavaServiceFragmentFiles ...@@ -139,13 +144,6 @@ public class TempJavaServiceFragmentFiles
139 * suffix. 144 * suffix.
140 */ 145 */
141 private static final String EVENT_LISTENER_FILE_NAME_SUFFIX = "Listener"; 146 private static final String EVENT_LISTENER_FILE_NAME_SUFFIX = "Listener";
142 -
143 - /**
144 - * File name for generated class file for special type like union, typedef
145 - * suffix.
146 - */
147 - public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject";
148 -
149 private static final String JAVA_FILE_EXTENSION = ".java"; 147 private static final String JAVA_FILE_EXTENSION = ".java";
150 148
151 /** 149 /**
...@@ -209,6 +207,65 @@ public class TempJavaServiceFragmentFiles ...@@ -209,6 +207,65 @@ public class TempJavaServiceFragmentFiles
209 private File eventSubjectSetterTempFileHandle; 207 private File eventSubjectSetterTempFileHandle;
210 208
211 /** 209 /**
210 + * Creates an instance of temporary java code fragment.
211 + *
212 + * @param javaFileInfo generated file information
213 + * @throws IOException when fails to create new file handle
214 + */
215 + public TempJavaServiceFragmentFiles(JavaFileInfo javaFileInfo)
216 + throws IOException {
217 + setJavaExtendsListHolder(new JavaExtendsListHolder());
218 + setJavaImportData(new JavaImportData());
219 + setJavaFileInfo(javaFileInfo);
220 + setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
221 + getJavaFileInfo().getPackageFilePath()));
222 + addGeneratedTempFile(RPC_INTERFACE_MASK);
223 + addGeneratedTempFile(RPC_IMPL_MASK);
224 +
225 + addGeneratedTempFile(EVENT_ENUM_MASK);
226 + addGeneratedTempFile(EVENT_METHOD_MASK);
227 + addGeneratedTempFile(EVENT_SUBJECT_ATTRIBUTE_MASK);
228 + addGeneratedTempFile(EVENT_SUBJECT_GETTER_MASK);
229 + addGeneratedTempFile(EVENT_SUBJECT_SETTER_MASK);
230 +
231 + setRpcInterfaceTempFileHandle(getTemporaryFileHandle(RPC_INTERFACE_FILE_NAME));
232 + setRpcImplTempFileHandle(getTemporaryFileHandle(RPC_IMPL_FILE_NAME));
233 +
234 + setEventEnumTempFileHandle(getTemporaryFileHandle(EVENT_ENUM_FILE_NAME));
235 + setEventMethodTempFileHandle(getTemporaryFileHandle(EVENT_METHOD_FILE_NAME));
236 + setEventSubjectAttributeTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_ATTRIBUTE_FILE_NAME));
237 + setEventSubjectGetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_GETTER_FILE_NAME));
238 + setEventSubjectSetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_SETTER_FILE_NAME));
239 + }
240 +
241 + /*Adds event method contents to event file.*/
242 + private static String getEventFileContents(String eventClassname, String classname) {
243 + return "\n" +
244 + " /**\n" +
245 + " * Creates " + classname + " event with type and subject.\n" +
246 + " *\n" +
247 + " * @param type event type\n" +
248 + " * @param subject subject " + classname + "\n" +
249 + " */\n" +
250 + " public " + eventClassname + "(Type type, " + getCapitalCase(classname) + " subject) {\n" +
251 + " super(type, subject);\n" +
252 + " }\n" +
253 + "\n" +
254 + " /**\n" +
255 + " * Creates " + classname + " event with type, subject and time.\n" +
256 + " *\n" +
257 + " * @param type event type\n" +
258 + " * @param subject subject " + classname + "\n" +
259 + " * @param time time of event\n" +
260 + " */\n" +
261 + " public " + eventClassname + "(Type type, " + getCapitalCase(classname)
262 + + " subject, long time) {\n" +
263 + " super(type, subject, time);\n" +
264 + " }\n" +
265 + "\n";
266 + }
267 +
268 + /**
212 * Returns rpc method's java file handle. 269 * Returns rpc method's java file handle.
213 * 270 *
214 * @return java file handle 271 * @return java file handle
...@@ -335,35 +392,6 @@ public class TempJavaServiceFragmentFiles ...@@ -335,35 +392,6 @@ public class TempJavaServiceFragmentFiles
335 } 392 }
336 393
337 /** 394 /**
338 - * Creates an instance of temporary java code fragment.
339 - *
340 - * @param javaFileInfo generated file information
341 - * @throws IOException when fails to create new file handle
342 - */
343 - public TempJavaServiceFragmentFiles(JavaFileInfo javaFileInfo)
344 - throws IOException {
345 - super(javaFileInfo);
346 -
347 - addGeneratedTempFile(RPC_INTERFACE_MASK);
348 - addGeneratedTempFile(RPC_IMPL_MASK);
349 -
350 - addGeneratedTempFile(EVENT_ENUM_MASK);
351 - addGeneratedTempFile(EVENT_METHOD_MASK);
352 - addGeneratedTempFile(EVENT_SUBJECT_ATTRIBUTE_MASK);
353 - addGeneratedTempFile(EVENT_SUBJECT_GETTER_MASK);
354 - addGeneratedTempFile(EVENT_SUBJECT_SETTER_MASK);
355 -
356 - setRpcInterfaceTempFileHandle(getTemporaryFileHandle(RPC_INTERFACE_FILE_NAME));
357 - setRpcImplTempFileHandle(getTemporaryFileHandle(RPC_IMPL_FILE_NAME));
358 -
359 - setEventEnumTempFileHandle(getTemporaryFileHandle(EVENT_ENUM_FILE_NAME));
360 - setEventMethodTempFileHandle(getTemporaryFileHandle(EVENT_METHOD_FILE_NAME));
361 - setEventSubjectAttributeTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_ATTRIBUTE_FILE_NAME));
362 - setEventSubjectGetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_GETTER_FILE_NAME));
363 - setEventSubjectSetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_SETTER_FILE_NAME));
364 - }
365 -
366 - /**
367 * Constructs java code exit. 395 * Constructs java code exit.
368 * 396 *
369 * @param fileType generated file type 397 * @param fileType generated file type
...@@ -373,7 +401,8 @@ public class TempJavaServiceFragmentFiles ...@@ -373,7 +401,8 @@ public class TempJavaServiceFragmentFiles
373 @Override 401 @Override
374 public void generateJavaFile(int fileType, YangNode curNode) 402 public void generateJavaFile(int fileType, YangNode curNode)
375 throws IOException { 403 throws IOException {
376 - List<String> imports = getJavaImportData().getImports(); 404 + List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles()
405 + .getJavaImportData().getImports();
377 406
378 createPackage(curNode); 407 createPackage(curNode);
379 408
...@@ -395,7 +424,7 @@ public class TempJavaServiceFragmentFiles ...@@ -395,7 +424,7 @@ public class TempJavaServiceFragmentFiles
395 * Creates rpc interface file. 424 * Creates rpc interface file.
396 */ 425 */
397 setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX))); 426 setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX)));
398 - generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports, isAttributePresent()); 427 + generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports);
399 428
400 if (isNotification) { 429 if (isNotification) {
401 addListenersImport(curNode, imports, false, LISTENER_SERVICE); 430 addListenersImport(curNode, imports, false, LISTENER_SERVICE);
...@@ -406,7 +435,7 @@ public class TempJavaServiceFragmentFiles ...@@ -406,7 +435,7 @@ public class TempJavaServiceFragmentFiles
406 * Create builder class file. 435 * Create builder class file.
407 */ 436 */
408 setManagerJavaFileHandle(getJavaFileHandle(getJavaClassName(MANAGER_FILE_NAME_SUFFIX))); 437 setManagerJavaFileHandle(getJavaFileHandle(getJavaClassName(MANAGER_FILE_NAME_SUFFIX)));
409 - generateManagerClassFile(getManagerJavaFileHandle(), imports, curNode, isAttributePresent()); 438 + generateManagerClassFile(getManagerJavaFileHandle(), imports, curNode);
410 439
411 insertDataIntoJavaFile(getManagerJavaFileHandle(), getJavaClassDefClose()); 440 insertDataIntoJavaFile(getManagerJavaFileHandle(), getJavaClassDefClose());
412 if (isNotification) { 441 if (isNotification) {
...@@ -468,8 +497,8 @@ public class TempJavaServiceFragmentFiles ...@@ -468,8 +497,8 @@ public class TempJavaServiceFragmentFiles
468 * @throws IOException IO operation fail 497 * @throws IOException IO operation fail
469 */ 498 */
470 public void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo javaAttributeInfoOfInput, 499 public void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo javaAttributeInfoOfInput,
471 - JavaAttributeInfo javaAttributeInfoOfOutput, YangPluginConfig pluginConfig, 500 + JavaAttributeInfo javaAttributeInfoOfOutput,
472 - String rpcName) 501 + YangPluginConfig pluginConfig, String rpcName)
473 throws IOException { 502 throws IOException {
474 addRpcString(javaAttributeInfoOfInput, javaAttributeInfoOfOutput, pluginConfig, rpcName); 503 addRpcString(javaAttributeInfoOfInput, javaAttributeInfoOfOutput, pluginConfig, rpcName);
475 } 504 }
...@@ -558,9 +587,8 @@ public class TempJavaServiceFragmentFiles ...@@ -558,9 +587,8 @@ public class TempJavaServiceFragmentFiles
558 /** 587 /**
559 * Removes all temporary file handles. 588 * Removes all temporary file handles.
560 * 589 *
561 - * @param isErrorOccurred when translator fails to generate java files we 590 + * @param isErrorOccurred when translator fails to generate java files we need to close all open file handles
562 - * need to close all open file handles include temporary files 591 + * include temporary files and java files.
563 - * and java files.
564 * @throws IOException when failed to delete the temporary files 592 * @throws IOException when failed to delete the temporary files
565 */ 593 */
566 @Override 594 @Override
...@@ -691,9 +719,9 @@ public class TempJavaServiceFragmentFiles ...@@ -691,9 +719,9 @@ public class TempJavaServiceFragmentFiles
691 public void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig) 719 public void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig)
692 throws IOException { 720 throws IOException {
693 721
694 - String currentInfo = getCapitalCase(getCamelCase(((YangNotification) curNode).getName(), 722 + String currentInfo = getCapitalCase(getCamelCase(curNode.getName(),
695 pluginConfig.getConflictResolver())); 723 pluginConfig.getConflictResolver()));
696 - String notificationName = ((YangNotification) curNode).getName(); 724 + String notificationName = curNode.getName();
697 725
698 JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, 726 JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
699 getCapitalCase(currentInfo)); 727 getCapitalCase(currentInfo));
...@@ -722,33 +750,6 @@ public class TempJavaServiceFragmentFiles ...@@ -722,33 +750,6 @@ public class TempJavaServiceFragmentFiles
722 appendToFile(getEventMethodTempFileHandle(), getEventFileContents(eventClassname, className)); 750 appendToFile(getEventMethodTempFileHandle(), getEventFileContents(eventClassname, className));
723 } 751 }
724 752
725 - /*Adds event method contents to event file.*/
726 - private static String getEventFileContents(String eventClassname, String classname) {
727 - return "\n" +
728 - " /**\n" +
729 - " * Creates " + classname + " event with type and subject.\n" +
730 - " *\n" +
731 - " * @param type event type\n" +
732 - " * @param subject subject " + classname + "\n" +
733 - " */\n" +
734 - " public " + eventClassname + "(Type type, " + getCapitalCase(classname) + " subject) {\n" +
735 - " super(type, subject);\n" +
736 - " }\n" +
737 - "\n" +
738 - " /**\n" +
739 - " * Creates " + classname + " event with type, subject and time.\n" +
740 - " *\n" +
741 - " * @param type event type\n" +
742 - " * @param subject subject " + classname + "\n" +
743 - " * @param time time of event\n" +
744 - " */\n" +
745 - " public " + eventClassname + "(Type type, " + getCapitalCase(classname)
746 - + " subject, long time) {\n" +
747 - " super(type, subject, time);\n" +
748 - " }\n" +
749 - "\n";
750 - }
751 -
752 /*Adds events to event subject file.*/ 753 /*Adds events to event subject file.*/
753 private void addEventSubjectAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) 754 private void addEventSubjectAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
754 throws IOException { 755 throws IOException {
......
...@@ -332,7 +332,7 @@ public class TempJavaTypeFragmentFiles ...@@ -332,7 +332,7 @@ public class TempJavaTypeFragmentFiles
332 * Creates type def class file. 332 * Creates type def class file.
333 */ 333 */
334 if ((fileType & GENERATE_TYPEDEF_CLASS) != 0) { 334 if ((fileType & GENERATE_TYPEDEF_CLASS) != 0) {
335 - addImportsToStringAndHasCodeMethods(curNode, imports); 335 + addImportsToStringAndHasCodeMethods(imports);
336 setTypedefClassJavaFileHandle(getJavaFileHandle(getJavaClassName(TYPEDEF_CLASS_FILE_NAME_SUFFIX))); 336 setTypedefClassJavaFileHandle(getJavaFileHandle(getJavaClassName(TYPEDEF_CLASS_FILE_NAME_SUFFIX)));
337 generateTypeDefClassFile(getTypedefClassJavaFileHandle(), curNode, imports); 337 generateTypeDefClassFile(getTypedefClassJavaFileHandle(), curNode, imports);
338 } 338 }
...@@ -340,7 +340,7 @@ public class TempJavaTypeFragmentFiles ...@@ -340,7 +340,7 @@ public class TempJavaTypeFragmentFiles
340 * Creates type class file. 340 * Creates type class file.
341 */ 341 */
342 if ((fileType & GENERATE_UNION_CLASS) != 0) { 342 if ((fileType & GENERATE_UNION_CLASS) != 0) {
343 - addImportsToStringAndHasCodeMethods(curNode, imports); 343 + addImportsToStringAndHasCodeMethods(imports);
344 setTypeClassJavaFileHandle(getJavaFileHandle(getJavaClassName(UNION_TYPE_CLASS_FILE_NAME_SUFFIX))); 344 setTypeClassJavaFileHandle(getJavaFileHandle(getJavaClassName(UNION_TYPE_CLASS_FILE_NAME_SUFFIX)));
345 generateUnionClassFile(getTypeClassJavaFileHandle(), curNode, imports); 345 generateUnionClassFile(getTypeClassJavaFileHandle(), curNode, imports);
346 } 346 }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.translator.tojava.javamodel; 17 +package org.onosproject.yangutils.translator.tojava;
18 18
19 import java.io.File; 19 import java.io.File;
20 import java.io.IOException; 20 import java.io.IOException;
...@@ -26,16 +26,17 @@ import org.onosproject.yangutils.datamodel.YangCase; ...@@ -26,16 +26,17 @@ import org.onosproject.yangutils.datamodel.YangCase;
26 import org.onosproject.yangutils.datamodel.YangChoice; 26 import org.onosproject.yangutils.datamodel.YangChoice;
27 import org.onosproject.yangutils.datamodel.YangGrouping; 27 import org.onosproject.yangutils.datamodel.YangGrouping;
28 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 28 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
29 +import org.onosproject.yangutils.datamodel.YangModule;
29 import org.onosproject.yangutils.datamodel.YangNode; 30 import org.onosproject.yangutils.datamodel.YangNode;
31 +import org.onosproject.yangutils.datamodel.YangSubModule;
30 import org.onosproject.yangutils.datamodel.YangTypeDef; 32 import org.onosproject.yangutils.datamodel.YangTypeDef;
31 import org.onosproject.yangutils.datamodel.YangTypeHolder; 33 import org.onosproject.yangutils.datamodel.YangTypeHolder;
32 import org.onosproject.yangutils.datamodel.utils.DataModelUtils; 34 import org.onosproject.yangutils.datamodel.utils.DataModelUtils;
33 import org.onosproject.yangutils.translator.exception.TranslatorException; 35 import org.onosproject.yangutils.translator.exception.TranslatorException;
34 -import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; 36 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
35 -import org.onosproject.yangutils.translator.tojava.JavaFileInfo; 37 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration;
36 -import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 38 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
37 -import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; 39 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
38 -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
39 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 40 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
40 41
41 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.isRpcChildNodePresent; 42 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.isRpcChildNodePresent;
...@@ -50,6 +51,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; ...@@ -50,6 +51,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
50 import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; 51 import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
51 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 52 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
52 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; 53 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
54 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
55 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG;
53 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 56 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
54 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 57 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
55 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; 58 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
...@@ -75,7 +78,6 @@ public final class YangJavaModelUtils { ...@@ -75,7 +78,6 @@ public final class YangJavaModelUtils {
75 public static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 78 public static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
76 YangPluginConfig yangPluginConfig) 79 YangPluginConfig yangPluginConfig)
77 throws IOException { 80 throws IOException {
78 -
79 if (javaCodeGeneratorInfo instanceof YangJavaAugment) { 81 if (javaCodeGeneratorInfo instanceof YangJavaAugment) {
80 javaCodeGeneratorInfo.getJavaFileInfo() 82 javaCodeGeneratorInfo.getJavaFileInfo()
81 .setJavaName(((YangJavaAugment) javaCodeGeneratorInfo).getAugmentClassName()); 83 .setJavaName(((YangJavaAugment) javaCodeGeneratorInfo).getAugmentClassName());
...@@ -138,11 +140,11 @@ public final class YangJavaModelUtils { ...@@ -138,11 +140,11 @@ public final class YangJavaModelUtils {
138 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() 140 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
139 .getServiceTempFiles().addCurNodeLeavesInfoToTempFiles( 141 .getServiceTempFiles().addCurNodeLeavesInfoToTempFiles(
140 (YangNode) javaCodeGeneratorInfo, yangPluginConfig); 142 (YangNode) javaCodeGeneratorInfo, yangPluginConfig);
141 - if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaModule) { 143 + if (javaCodeGeneratorInfo instanceof YangJavaModule) {
142 if (!((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes().isEmpty()) { 144 if (!((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes().isEmpty()) {
143 updateNotificaitonNodeInfo(javaCodeGeneratorInfo, yangPluginConfig); 145 updateNotificaitonNodeInfo(javaCodeGeneratorInfo, yangPluginConfig);
144 } 146 }
145 - } else if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaSubModule) { 147 + } else if (javaCodeGeneratorInfo instanceof YangJavaSubModule) {
146 if (!((YangJavaSubModule) javaCodeGeneratorInfo).getNotificationNodes().isEmpty()) { 148 if (!((YangJavaSubModule) javaCodeGeneratorInfo).getNotificationNodes().isEmpty()) {
147 updateNotificaitonNodeInfo(javaCodeGeneratorInfo, yangPluginConfig); 149 updateNotificaitonNodeInfo(javaCodeGeneratorInfo, yangPluginConfig);
148 } 150 }
...@@ -186,6 +188,7 @@ public final class YangJavaModelUtils { ...@@ -186,6 +188,7 @@ public final class YangJavaModelUtils {
186 * Process generate code entry of YANG node. 188 * Process generate code entry of YANG node.
187 * 189 *
188 * @param javaCodeGeneratorInfo YANG java file info node 190 * @param javaCodeGeneratorInfo YANG java file info node
191 + * @param yangPluginConfig plugin configurations
189 * @throws IOException IO operations fails 192 * @throws IOException IO operations fails
190 */ 193 */
191 private static void generateTempFiles(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 194 private static void generateTempFiles(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
...@@ -209,14 +212,14 @@ public final class YangJavaModelUtils { ...@@ -209,14 +212,14 @@ public final class YangJavaModelUtils {
209 private static void updateNotificaitonNodeInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 212 private static void updateNotificaitonNodeInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
210 YangPluginConfig yangPluginConfig) 213 YangPluginConfig yangPluginConfig)
211 throws IOException { 214 throws IOException {
212 - if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaModule) { 215 + if (javaCodeGeneratorInfo instanceof YangJavaModule) {
213 for (YangNode notificaiton : ((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes()) { 216 for (YangNode notificaiton : ((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes()) {
214 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() 217 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
215 .getServiceTempFiles() 218 .getServiceTempFiles()
216 .addJavaSnippetOfEvent(notificaiton, yangPluginConfig); 219 .addJavaSnippetOfEvent(notificaiton, yangPluginConfig);
217 } 220 }
218 } 221 }
219 - if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaSubModule) { 222 + if (javaCodeGeneratorInfo instanceof YangJavaSubModule) {
220 for (YangNode notificaiton : ((YangJavaSubModule) javaCodeGeneratorInfo) 223 for (YangNode notificaiton : ((YangJavaSubModule) javaCodeGeneratorInfo)
221 .getNotificationNodes()) { 224 .getNotificationNodes()) {
222 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() 225 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
...@@ -267,8 +270,9 @@ public final class YangJavaModelUtils { ...@@ -267,8 +270,9 @@ public final class YangJavaModelUtils {
267 } 270 }
268 271
269 generateCodeOfNode(javaCodeGeneratorInfo, yangPlugin); 272 generateCodeOfNode(javaCodeGeneratorInfo, yangPlugin);
270 - 273 + TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles();
271 if (javaCodeGeneratorInfo instanceof YangJavaAugment) { 274 if (javaCodeGeneratorInfo instanceof YangJavaAugment) {
275 +
272 JavaQualifiedTypeInfo augmentedBuilderInfo = new JavaQualifiedTypeInfo(); 276 JavaQualifiedTypeInfo augmentedBuilderInfo = new JavaQualifiedTypeInfo();
273 JavaQualifiedTypeInfo augmentedBuilderClassInfo = new JavaQualifiedTypeInfo(); 277 JavaQualifiedTypeInfo augmentedBuilderClassInfo = new JavaQualifiedTypeInfo();
274 JavaQualifiedTypeInfo augmentedClassInfo = new JavaQualifiedTypeInfo(); 278 JavaQualifiedTypeInfo augmentedClassInfo = new JavaQualifiedTypeInfo();
...@@ -283,8 +287,10 @@ public final class YangJavaModelUtils { ...@@ -283,8 +287,10 @@ public final class YangJavaModelUtils {
283 } else { 287 } else {
284 name = getCapitalCase(getCamelCase(augmentedNode.getName(), yangPlugin.getConflictResolver())); 288 name = getCapitalCase(getCamelCase(augmentedNode.getName(), yangPlugin.getConflictResolver()));
285 augmentedClassInfo.setClassInfo(name); 289 augmentedClassInfo.setClassInfo(name);
286 - augmentedClassInfo.setPkgInfo(getAugmentedNodesPackage(augmentedNode, yangPlugin)); 290 + augmentedClassInfo.setPkgInfo(getAugmentedNodesPackage(augmentedNode,
291 + yangPlugin));
287 } 292 }
293 +
288 augmentedBuilderInfo.setClassInfo(name + PERIOD + name + BUILDER); 294 augmentedBuilderInfo.setClassInfo(name + PERIOD + name + BUILDER);
289 augmentedBuilderInfo.setPkgInfo(augmentedClassInfo.getPkgInfo()); 295 augmentedBuilderInfo.setPkgInfo(augmentedClassInfo.getPkgInfo());
290 augmentedBuilderClassInfo.setClassInfo(getCapitalCase(DEFAULT) + name + PERIOD + name + BUILDER); 296 augmentedBuilderClassInfo.setClassInfo(getCapitalCase(DEFAULT) + name + PERIOD + name + BUILDER);
...@@ -296,13 +302,25 @@ public final class YangJavaModelUtils { ...@@ -296,13 +302,25 @@ public final class YangJavaModelUtils {
296 ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedBuilderClassInfo); 302 ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedBuilderClassInfo);
297 ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedClassInfo); 303 ((YangJavaAugment) javaCodeGeneratorInfo).addToExtendedClassInfo(augmentedClassInfo);
298 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() 304 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder()
299 - .addToExtendsList(augmentedClassInfo, (YangNode) javaCodeGeneratorInfo); 305 + .addToExtendsList(augmentedClassInfo, (YangNode) javaCodeGeneratorInfo,
306 + tempJavaCodeFragmentFiles.getBeanTempFiles());
307 + javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder()
308 + .addToExtendsList(augmentedBuilderInfo, (YangNode) javaCodeGeneratorInfo,
309 + tempJavaCodeFragmentFiles.getBeanTempFiles());
300 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() 310 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder()
301 - .addToExtendsList(augmentedBuilderInfo, (YangNode) javaCodeGeneratorInfo); 311 + .addToExtendsList(augmentedImplInfo, (YangNode) javaCodeGeneratorInfo,
312 + tempJavaCodeFragmentFiles.getBeanTempFiles());
302 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() 313 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder()
303 - .addToExtendsList(augmentedImplInfo, (YangNode) javaCodeGeneratorInfo); 314 + .addToExtendsList(augmentedBuilderClassInfo, (YangNode) javaCodeGeneratorInfo,
315 + tempJavaCodeFragmentFiles.getBeanTempFiles());
316 +
317 + JavaQualifiedTypeInfo yangAugmentedInfo = new JavaQualifiedTypeInfo();
318 + yangAugmentedInfo.setClassInfo(YANG_AUGMENTED_INFO);
319 + yangAugmentedInfo.setPkgInfo(YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG);
304 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() 320 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder()
305 - .addToExtendsList(augmentedBuilderClassInfo, (YangNode) javaCodeGeneratorInfo); 321 + .addToExtendsList(yangAugmentedInfo, (YangNode) javaCodeGeneratorInfo,
322 + tempJavaCodeFragmentFiles.getBeanTempFiles());
323 +
306 324
307 } 325 }
308 326
...@@ -314,7 +332,8 @@ public final class YangJavaModelUtils { ...@@ -314,7 +332,8 @@ public final class YangJavaModelUtils {
314 parentsInfo.setClassInfo(parentName); 332 parentsInfo.setClassInfo(parentName);
315 parentsInfo.setPkgInfo(parentPkg); 333 parentsInfo.setPkgInfo(parentPkg);
316 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder() 334 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles().getJavaExtendsListHolder()
317 - .addToExtendsList(parentsInfo, (YangNode) javaCodeGeneratorInfo); 335 + .addToExtendsList(parentsInfo, (YangNode) javaCodeGeneratorInfo,
336 + tempJavaCodeFragmentFiles.getBeanTempFiles());
318 337
319 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles() 338 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles()
320 .addParentInfoInCurNodeTempFile((YangNode) javaCodeGeneratorInfo, yangPlugin); 339 .addParentInfoInCurNodeTempFile((YangNode) javaCodeGeneratorInfo, yangPlugin);
...@@ -322,45 +341,6 @@ public final class YangJavaModelUtils { ...@@ -322,45 +341,6 @@ public final class YangJavaModelUtils {
322 } 341 }
323 } 342 }
324 343
325 - private static String getAugmentedNodesPackage(YangNode node, YangPluginConfig yangPluginConfig) {
326 -
327 - List<String> clsInfo = new ArrayList<>();
328 - node = node.getParent();
329 - while (node != null) {
330 - if (!(node instanceof YangJavaModule)
331 - || !(node instanceof YangJavaSubModule)) {
332 - if (node instanceof YangJavaAugment) {
333 - clsInfo.add(((YangJavaAugment) node).getAugmentClassName());
334 - } else {
335 - clsInfo.add(getCamelCase(node.getName(), yangPluginConfig.getConflictResolver()));
336 - }
337 - }
338 - if (node instanceof YangJavaModule
339 - || node instanceof YangJavaSubModule) {
340 - break;
341 - }
342 - node = node.getParent();
343 - }
344 -
345 - StringBuilder pkg = new StringBuilder();
346 - if (node instanceof YangJavaModule) {
347 - YangJavaModule module = (YangJavaModule) node;
348 - pkg.append(getRootPackage(module.getVersion(), module.getNameSpace().getUri(), module
349 - .getRevision().getRevDate(), yangPluginConfig.getConflictResolver()));
350 - } else if (node instanceof YangJavaSubModule) {
351 - YangJavaSubModule submodule = (YangJavaSubModule) node;
352 - pkg.append(getRootPackage(submodule.getVersion(),
353 - submodule.getNameSpaceFromModule(submodule.getBelongsTo()),
354 - submodule.getRevision().getRevDate(), yangPluginConfig.getConflictResolver()));
355 - }
356 - for (int i = 1; i <= clsInfo.size(); i++) {
357 - pkg.append("." + clsInfo.get(clsInfo.size() - i));
358 - }
359 -
360 - return pkg.toString().toLowerCase();
361 -
362 - }
363 -
364 /** 344 /**
365 * Generates code for the current data model node. 345 * Generates code for the current data model node.
366 * 346 *
...@@ -398,18 +378,17 @@ public final class YangJavaModelUtils { ...@@ -398,18 +378,17 @@ public final class YangJavaModelUtils {
398 javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_SERVICE_AND_MANAGER); 378 javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_SERVICE_AND_MANAGER);
399 } 379 }
400 380
401 - if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaModule) { 381 + if (javaCodeGeneratorInfo instanceof YangJavaModule) {
402 if (!((YangJavaModule) javaCodeGeneratorInfo) 382 if (!((YangJavaModule) javaCodeGeneratorInfo)
403 .isNotificationChildNodePresent((YangNode) javaCodeGeneratorInfo)) { 383 .isNotificationChildNodePresent((YangNode) javaCodeGeneratorInfo)) {
404 updateCodeGenInfoForEvent(javaCodeGeneratorInfo); 384 updateCodeGenInfoForEvent(javaCodeGeneratorInfo);
405 } 385 }
406 - } else if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaSubModule) { 386 + } else if (javaCodeGeneratorInfo instanceof YangJavaSubModule) {
407 if (!((YangJavaSubModule) javaCodeGeneratorInfo) 387 if (!((YangJavaSubModule) javaCodeGeneratorInfo)
408 .isNotificationChildNodePresent((YangNode) javaCodeGeneratorInfo)) { 388 .isNotificationChildNodePresent((YangNode) javaCodeGeneratorInfo)) {
409 updateCodeGenInfoForEvent(javaCodeGeneratorInfo); 389 updateCodeGenInfoForEvent(javaCodeGeneratorInfo);
410 } 390 }
411 } 391 }
412 -
413 generateTempFiles(javaCodeGeneratorInfo, yangPluginConfig); 392 generateTempFiles(javaCodeGeneratorInfo, yangPluginConfig);
414 } 393 }
415 394
...@@ -452,13 +431,26 @@ public final class YangJavaModelUtils { ...@@ -452,13 +431,26 @@ public final class YangJavaModelUtils {
452 public static boolean isManagerCodeGenRequired(YangNode node) { 431 public static boolean isManagerCodeGenRequired(YangNode node) {
453 YangLeavesHolder holder = (YangLeavesHolder) node; 432 YangLeavesHolder holder = (YangLeavesHolder) node;
454 433
434 + boolean isCodeReq = true;
435 +
436 + List<YangNode> childNodes = new ArrayList<>();
437 + node = node.getChild();
438 + while (node != null) {
439 + childNodes.add(node);
440 + node = node.getNextSibling();
441 + }
442 +
443 + if (childNodes.size() == 0) {
455 if (holder.getListOfLeaf() != null && !holder.getListOfLeaf().isEmpty()) { 444 if (holder.getListOfLeaf() != null && !holder.getListOfLeaf().isEmpty()) {
456 - return true; 445 + isCodeReq = true;
457 } else if (holder.getListOfLeafList() != null && !holder.getListOfLeafList().isEmpty()) { 446 } else if (holder.getListOfLeafList() != null && !holder.getListOfLeafList().isEmpty()) {
458 - return true; 447 + isCodeReq = true;
459 } 448 }
460 - node = node.getChild(); 449 + return isCodeReq;
461 - return node != null && !(node instanceof YangTypeDef) && !(node instanceof YangGrouping); 450 + } else if (childNodes.size() == 1) {
451 + return childNodes.get(0) instanceof YangTypeDef && childNodes.get(0) instanceof YangGrouping;
452 + }
453 + return isCodeReq;
462 } 454 }
463 455
464 /** 456 /**
...@@ -482,4 +474,49 @@ public final class YangJavaModelUtils { ...@@ -482,4 +474,49 @@ public final class YangJavaModelUtils {
482 return true; 474 return true;
483 } 475 }
484 476
477 + /**
478 + * Returns augmented nodes package.
479 + *
480 + * @param node augmented node
481 + * @param yangPluginConfig plugin config
482 + * @return java package
483 + */
484 + public static String getAugmentedNodesPackage(YangNode node, YangPluginConfig yangPluginConfig) {
485 +
486 + List<String> clsInfo = new ArrayList<>();
487 + node = node.getParent();
488 + while (node != null) {
489 + if (!(node instanceof YangModule)
490 + || !(node instanceof YangSubModule)) {
491 + if (node instanceof YangJavaAugment) {
492 + clsInfo.add(((YangJavaAugment) node).getAugmentClassName());
493 + } else {
494 + clsInfo.add(getCamelCase(node.getName(), yangPluginConfig.getConflictResolver()));
495 + }
496 + }
497 + if (node instanceof YangJavaModule
498 + || node instanceof YangJavaSubModule) {
499 + break;
500 + }
501 + node = node.getParent();
502 + }
503 +
504 + StringBuilder pkg = new StringBuilder();
505 + if (node instanceof YangJavaModule) {
506 + YangJavaModule module = (YangJavaModule) node;
507 + pkg.append(getRootPackage(module.getVersion(), module.getNameSpace().getUri(), module
508 + .getRevision().getRevDate(), yangPluginConfig.getConflictResolver()));
509 + } else if (node instanceof YangJavaSubModule) {
510 + YangJavaSubModule submodule = (YangJavaSubModule) node;
511 + pkg.append(getRootPackage(submodule.getVersion(),
512 + submodule.getNameSpaceFromModule(submodule.getBelongsTo()),
513 + submodule.getRevision().getRevDate(), yangPluginConfig.getConflictResolver()));
514 + }
515 + for (int i = 1; i <= clsInfo.size(); i++) {
516 + pkg.append("." + clsInfo.get(clsInfo.size() - i));
517 + }
518 +
519 + return pkg.toString().toLowerCase();
520 +
521 + }
485 } 522 }
......
...@@ -34,7 +34,7 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; ...@@ -34,7 +34,7 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
34 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 34 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
35 import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; 35 import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil;
36 36
37 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.getCurNodePackage; 37 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getCurNodePackage;
38 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 38 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
39 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; 39 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
40 import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL; 40 import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL;
......
...@@ -30,7 +30,8 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -30,7 +30,8 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
30 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 30 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
31 31
32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
33 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; 33 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode;
34 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
34 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 35 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
35 36
36 /** 37 /**
...@@ -154,10 +155,11 @@ public class YangJavaAugment ...@@ -154,10 +155,11 @@ public class YangJavaAugment
154 */ 155 */
155 public String getAugmentClassName() { 156 public String getAugmentClassName() {
156 YangNodeIdentifier nodeId = getTargetNode().get(getTargetNode().size() - 1).getNodeIdentifier(); 157 YangNodeIdentifier nodeId = getTargetNode().get(getTargetNode().size() - 1).getNodeIdentifier();
158 + String name = getCapitalCase(getCamelCase(nodeId.getName(), null));
157 if (nodeId.getPrefix() != null) { 159 if (nodeId.getPrefix() != null) {
158 - return AUGMENTED + getCapitalCase(nodeId.getPrefix()) + getCapitalCase(nodeId.getName()); 160 + return AUGMENTED + getCapitalCase(nodeId.getPrefix()) + name;
159 } else { 161 } else {
160 - return AUGMENTED + getCapitalCase(nodeId.getName()); 162 + return AUGMENTED + name;
161 } 163 }
162 } 164 }
163 165
......
...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
27 27
28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
29 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; 29 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode;
30 30
31 /** 31 /**
32 * Represents case information extended to support java code generation. 32 * Represents case information extended to support java code generation.
......
...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
27 27
28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; 28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
29 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent; 29 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeAndUpdateInParent;
30 30
31 /** 31 /**
32 * Represents choice information extended to support java code generation. 32 * Represents choice information extended to support java code generation.
......
...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
27 27
28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
29 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent; 29 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeAndUpdateInParent;
30 30
31 /** 31 /**
32 * Represents container information extended to support java code generation. 32 * Represents container information extended to support java code generation.
......
...@@ -27,7 +27,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -27,7 +27,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
27 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 27 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
28 28
29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; 29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
30 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode; 30 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfNode;
31 31
32 /** 32 /**
33 * Represents YANG java enumeration information extended to support java code generation. 33 * Represents YANG java enumeration information extended to support java code generation.
......
...@@ -31,7 +31,7 @@ import java.util.List; ...@@ -31,7 +31,7 @@ import java.util.List;
31 31
32 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;
33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; 33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS;
34 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo; 34 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.updatePackageInfo;
35 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; 35 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
36 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; 36 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
37 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 37 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
......
...@@ -27,7 +27,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -27,7 +27,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
27 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 27 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
28 28
29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
30 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; 30 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode;
31 31
32 /** 32 /**
33 * Represents input information extended to support java code generation. 33 * Represents input information extended to support java code generation.
......
...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
27 27
28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
29 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent; 29 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeAndUpdateInParent;
30 30
31 /** 31 /**
32 * Represents YANG list information extended to support java code generation. 32 * Represents YANG list information extended to support java code generation.
......
...@@ -32,10 +32,11 @@ import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; ...@@ -32,10 +32,11 @@ import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; 32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
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_INTERFACE_WITH_BUILDER;
35 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 36 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
36 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode; 37 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode;
37 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.isManagerCodeGenRequired; 38 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
38 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.isGenerationOfCodeReq; 39 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq;
39 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 40 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
40 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; 41 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
41 42
...@@ -71,7 +72,7 @@ public class YangJavaModule ...@@ -71,7 +72,7 @@ public class YangJavaModule
71 super(); 72 super();
72 setJavaFileInfo(new JavaFileInfo()); 73 setJavaFileInfo(new JavaFileInfo());
73 setNotificationNodes(new ArrayList<>()); 74 setNotificationNodes(new ArrayList<>());
74 - int gentype = GENERATE_SERVICE_AND_MANAGER; 75 + int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER;
75 if (isNotificationChildNodePresent(this)) { 76 if (isNotificationChildNodePresent(this)) {
76 gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_EVENT_SUBJECT_CLASS | GENERATE_EVENT_CLASS 77 gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_EVENT_SUBJECT_CLASS | GENERATE_EVENT_CLASS
77 | GENERATE_EVENT_LISTENER_INTERFACE; 78 | GENERATE_EVENT_LISTENER_INTERFACE;
...@@ -158,7 +159,10 @@ public class YangJavaModule ...@@ -158,7 +159,10 @@ public class YangJavaModule
158 159
159 try { 160 try {
160 if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { 161 if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) {
161 - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); 162 + getTempJavaCodeFragmentFiles()
163 + .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
164 + getTempJavaCodeFragmentFiles()
165 + .generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
162 } 166 }
163 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + 167 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() +
164 getJavaFileInfo().getPackageFilePath()); 168 getJavaFileInfo().getPackageFilePath());
......
...@@ -28,12 +28,13 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; ...@@ -28,12 +28,13 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
28 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; 28 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
30 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; 30 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
31 +import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
31 import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; 32 import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
32 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 33 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
33 34
34 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 35 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
35 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 36 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
36 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; 37 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode;
37 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING; 38 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING;
38 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; 39 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
39 40
...@@ -143,22 +144,23 @@ public class YangJavaNotification ...@@ -143,22 +144,23 @@ public class YangJavaNotification
143 /*Adds current notification info to the extends list so its parents service*/ 144 /*Adds current notification info to the extends list so its parents service*/
144 private void addNotificationToExtendsList() { 145 private void addNotificationToExtendsList() {
145 YangNode parent = getParent(); 146 YangNode parent = getParent();
146 - JavaExtendsListHolder holder = ((TempJavaCodeFragmentFilesContainer) parent) 147 + TempJavaServiceFragmentFiles tempJavaServiceFragmentFiles = ((TempJavaCodeFragmentFilesContainer) parent)
147 .getTempJavaCodeFragmentFiles() 148 .getTempJavaCodeFragmentFiles()
148 - .getServiceTempFiles().getJavaExtendsListHolder(); 149 + .getServiceTempFiles();
150 + JavaExtendsListHolder holder = tempJavaServiceFragmentFiles.getJavaExtendsListHolder();
149 JavaQualifiedTypeInfo event = new JavaQualifiedTypeInfo(); 151 JavaQualifiedTypeInfo event = new JavaQualifiedTypeInfo();
150 152
151 String parentInfo = getCapitalCase(((JavaFileInfoContainer) parent) 153 String parentInfo = getCapitalCase(((JavaFileInfoContainer) parent)
152 .getJavaFileInfo().getJavaName()); 154 .getJavaFileInfo().getJavaName());
153 event.setClassInfo(parentInfo + EVENT_STRING); 155 event.setClassInfo(parentInfo + EVENT_STRING);
154 event.setPkgInfo(getJavaFileInfo().getPackage()); 156 event.setPkgInfo(getJavaFileInfo().getPackage());
155 - holder.addToExtendsList(event, parent); 157 + holder.addToExtendsList(event, parent, tempJavaServiceFragmentFiles);
156 158
157 JavaQualifiedTypeInfo eventListener = new JavaQualifiedTypeInfo(); 159 JavaQualifiedTypeInfo eventListener = new JavaQualifiedTypeInfo();
158 160
159 eventListener.setClassInfo(parentInfo + EVENT_LISTENER_STRING); 161 eventListener.setClassInfo(parentInfo + EVENT_LISTENER_STRING);
160 eventListener.setPkgInfo(getJavaFileInfo().getPackage()); 162 eventListener.setPkgInfo(getJavaFileInfo().getPackage());
161 - holder.addToExtendsList(eventListener, parent); 163 + holder.addToExtendsList(eventListener, parent, tempJavaServiceFragmentFiles);
162 164
163 } 165 }
164 166
......
...@@ -27,7 +27,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -27,7 +27,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
27 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 27 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
28 28
29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
30 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; 30 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode;
31 31
32 /** 32 /**
33 * Represents output information extended to support java code generation. 33 * Represents output information extended to support java code generation.
......
...@@ -39,7 +39,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParent ...@@ -39,7 +39,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParent
39 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; 39 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
40 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; 40 import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode;
41 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 41 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
42 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo; 42 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.updatePackageInfo;
43 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; 43 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE;
44 import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT; 44 import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT;
45 import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; 45 import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE;
......
...@@ -34,10 +34,11 @@ import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; ...@@ -34,10 +34,11 @@ import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
34 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; 34 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
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_INTERFACE_WITH_BUILDER;
37 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 38 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
38 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode; 39 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode;
39 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.isManagerCodeGenRequired; 40 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
40 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.isGenerationOfCodeReq; 41 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq;
41 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 42 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
42 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; 43 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
43 44
...@@ -72,7 +73,7 @@ public class YangJavaSubModule ...@@ -72,7 +73,7 @@ public class YangJavaSubModule
72 public YangJavaSubModule() { 73 public YangJavaSubModule() {
73 super(); 74 super();
74 setJavaFileInfo(new JavaFileInfo()); 75 setJavaFileInfo(new JavaFileInfo());
75 - int gentype = GENERATE_SERVICE_AND_MANAGER; 76 + int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER;
76 if (isNotificationChildNodePresent(this)) { 77 if (isNotificationChildNodePresent(this)) {
77 gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_EVENT_SUBJECT_CLASS | GENERATE_EVENT_CLASS 78 gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_EVENT_SUBJECT_CLASS | GENERATE_EVENT_CLASS
78 | GENERATE_EVENT_LISTENER_INTERFACE; 79 | GENERATE_EVENT_LISTENER_INTERFACE;
...@@ -170,6 +171,8 @@ public class YangJavaSubModule ...@@ -170,6 +171,8 @@ public class YangJavaSubModule
170 */ 171 */
171 try { 172 try {
172 if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { 173 if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) {
174 +
175 + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
173 getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); 176 getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
174 } 177 }
175 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + 178 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() +
......
...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
27 27
28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; 28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
29 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode; 29 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfNode;
30 30
31 /** 31 /**
32 * Represents type define information extended to support java code generation. 32 * Represents type define information extended to support java code generation.
......
...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
27 27
28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; 28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
29 -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode; 29 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfNode;
30 30
31 /** 31 /**
32 * Represents union information extended to support java code generation. 32 * Represents union information extended to support java code generation.
......
...@@ -282,7 +282,7 @@ public final class ClassDefinitionGenerator { ...@@ -282,7 +282,7 @@ public final class ClassDefinitionGenerator {
282 curNode = curNode.getChild(); 282 curNode = curNode.getChild();
283 while (curNode != null) { 283 while (curNode != null) {
284 if (curNode instanceof YangNotification) { 284 if (curNode instanceof YangNotification) {
285 - return getRpcInterfaceDefinitionWhenItExtends(yangName, holder); 285 + return getRpcInterfaceDefinitionWhenItExtends(yangName);
286 } 286 }
287 curNode = curNode.getNextSibling(); 287 curNode = curNode.getNextSibling();
288 } 288 }
...@@ -295,8 +295,7 @@ public final class ClassDefinitionGenerator { ...@@ -295,8 +295,7 @@ public final class ClassDefinitionGenerator {
295 } 295 }
296 296
297 /* Provides class definition when RPC interface needs to extends any event.*/ 297 /* Provides class definition when RPC interface needs to extends any event.*/
298 - private static String getRpcInterfaceDefinitionWhenItExtends(String yangName, 298 + private static String getRpcInterfaceDefinitionWhenItExtends(String yangName) {
299 - JavaExtendsListHolder holder) {
300 299
301 if (yangName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) { 300 if (yangName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) {
302 String[] strArray = yangName.split(SERVICE); 301 String[] strArray = yangName.split(SERVICE);
......
...@@ -19,14 +19,14 @@ package org.onosproject.yangutils.translator.tojava.utils; ...@@ -19,14 +19,14 @@ package org.onosproject.yangutils.translator.tojava.utils;
19 import java.util.List; 19 import java.util.List;
20 20
21 import org.onosproject.yangutils.datamodel.YangNode; 21 import org.onosproject.yangutils.datamodel.YangNode;
22 +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
22 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; 23 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
23 -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 24 +import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
24 -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
25 -import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles;
26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 25 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
27 26
28 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; 27 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
29 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION_IMPORT; 28 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION_IMPORT;
29 +import static org.onosproject.yangutils.utils.UtilConstants.CLASS_STRING;
30 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 30 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
31 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; 31 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
32 import static org.onosproject.yangutils.utils.UtilConstants.COMMA; 32 import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
...@@ -38,6 +38,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET ...@@ -38,6 +38,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET
38 import static org.onosproject.yangutils.utils.UtilConstants.ENUM; 38 import static org.onosproject.yangutils.utils.UtilConstants.ENUM;
39 import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; 39 import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
40 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.HASH_MAP;
41 import static org.onosproject.yangutils.utils.UtilConstants.IMMEDIATE; 42 import static org.onosproject.yangutils.utils.UtilConstants.IMMEDIATE;
42 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; 43 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
43 import static org.onosproject.yangutils.utils.UtilConstants.INT; 44 import static org.onosproject.yangutils.utils.UtilConstants.INT;
...@@ -45,18 +46,22 @@ import static org.onosproject.yangutils.utils.UtilConstants.LIST; ...@@ -45,18 +46,22 @@ import static org.onosproject.yangutils.utils.UtilConstants.LIST;
45 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; 46 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_FACTORY_IMPORT;
47 import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT; 48 import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT;
49 +import static org.onosproject.yangutils.utils.UtilConstants.MAP;
50 +import static org.onosproject.yangutils.utils.UtilConstants.NEW;
48 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 51 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
49 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; 52 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
50 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; 53 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
51 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 54 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
52 import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; 55 import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
53 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; 56 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
57 +import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK;
54 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 58 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
55 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION; 59 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION;
56 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_IMPORT; 60 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_IMPORT;
57 import static org.onosproject.yangutils.utils.UtilConstants.SPACE; 61 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
58 import static org.onosproject.yangutils.utils.UtilConstants.TRUE; 62 import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
59 import static org.onosproject.yangutils.utils.UtilConstants.TYPE; 63 import static org.onosproject.yangutils.utils.UtilConstants.TYPE;
64 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
60 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; 65 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE;
61 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; 66 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
62 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; 67 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
...@@ -221,11 +226,13 @@ public final class JavaCodeSnippetGen { ...@@ -221,11 +226,13 @@ public final class JavaCodeSnippetGen {
221 public static void addListenersImport(YangNode curNode, List<String> imports, boolean operation, 226 public static void addListenersImport(YangNode curNode, List<String> imports, boolean operation,
222 String classInfo) { 227 String classInfo) {
223 String thisImport = ""; 228 String thisImport = "";
229 + TempJavaServiceFragmentFiles tempJavaServiceFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
230 + .getTempJavaCodeFragmentFiles().getServiceTempFiles();
224 if (classInfo.equals(LISTENER_SERVICE)) { 231 if (classInfo.equals(LISTENER_SERVICE)) {
225 - thisImport = getTempJavaFragment(curNode).getJavaImportData().getListenerServiceImport(); 232 + thisImport = tempJavaServiceFragmentFiles.getJavaImportData().getListenerServiceImport();
226 performOperationOnImports(imports, thisImport, operation); 233 performOperationOnImports(imports, thisImport, operation);
227 } else { 234 } else {
228 - thisImport = getTempJavaFragment(curNode).getJavaImportData().getListenerRegistryImport(); 235 + thisImport = tempJavaServiceFragmentFiles.getJavaImportData().getListenerRegistryImport();
229 performOperationOnImports(imports, thisImport, operation); 236 performOperationOnImports(imports, thisImport, operation);
230 } 237 }
231 } 238 }
...@@ -250,25 +257,6 @@ public final class JavaCodeSnippetGen { ...@@ -250,25 +257,6 @@ public final class JavaCodeSnippetGen {
250 } 257 }
251 258
252 /** 259 /**
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. 260 * Returns integer attribute for enum's class to get the values.
273 * 261 *
274 * @param className enum's class name 262 * @param className enum's class name
...@@ -285,7 +273,20 @@ public final class JavaCodeSnippetGen { ...@@ -285,7 +273,20 @@ public final class JavaCodeSnippetGen {
285 * @return component string 273 * @return component string
286 */ 274 */
287 public static String addComponentString() { 275 public static String addComponentString() {
288 - return NEW_LINE + COMPONENT_ANNOTATION + SPACE + OPEN_PARENTHESIS + IMMEDIATE + SPACE 276 + return NEW_LINE + COMPONENT_ANNOTATION + OPEN_PARENTHESIS + IMMEDIATE + SPACE
289 + EQUAL + SPACE + TRUE + CLOSE_PARENTHESIS + NEW_LINE + SERVICE_ANNOTATION; 277 + EQUAL + SPACE + TRUE + CLOSE_PARENTHESIS + NEW_LINE + SERVICE_ANNOTATION;
290 } 278 }
279 +
280 + /**
281 + * Returns attribute for augmentation.
282 + *
283 + * @return attribute for augmentation
284 + */
285 + public static String addAugmentationAttribute() {
286 + return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING
287 + + DIAMOND_OPEN_BRACKET + QUESTION_MARK + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + YANG_AUGMENTED_INFO
288 + + DIAMOND_CLOSE_BRACKET + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SPACE + EQUAL + SPACE +
289 + NEW + SPACE + HASH_MAP + DIAMOND_OPEN_BRACKET + DIAMOND_CLOSE_BRACKET + OPEN_PARENTHESIS
290 + + CLOSE_PARENTHESIS + SEMI_COLAN;
291 + }
291 } 292 }
......
...@@ -26,9 +26,9 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; ...@@ -26,9 +26,9 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
26 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 26 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
27 import org.onosproject.yangutils.translator.tojava.JavaImportData; 27 import org.onosproject.yangutils.translator.tojava.JavaImportData;
28 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; 28 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
29 +import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles;
29 30
30 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 31 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
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
...@@ -36,6 +36,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetG ...@@ -36,6 +36,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetG
36 */ 36 */
37 public class JavaExtendsListHolder { 37 public class JavaExtendsListHolder {
38 38
39 + private Map<JavaQualifiedTypeInfo, Boolean> extendedClassStore;
40 + private List<JavaQualifiedTypeInfo> extendsList;
41 +
39 /** 42 /**
40 * Creates an instance of JavaExtendsListHolder. 43 * Creates an instance of JavaExtendsListHolder.
41 */ 44 */
...@@ -44,9 +47,6 @@ public class JavaExtendsListHolder { ...@@ -44,9 +47,6 @@ public class JavaExtendsListHolder {
44 setExtendsList(new ArrayList<>()); 47 setExtendsList(new ArrayList<>());
45 } 48 }
46 49
47 - private Map<JavaQualifiedTypeInfo, Boolean> extendedClassStore;
48 - private List<JavaQualifiedTypeInfo> extendsList;
49 -
50 /** 50 /**
51 * Returns extends list. 51 * Returns extends list.
52 * 52 *
...@@ -70,11 +70,13 @@ public class JavaExtendsListHolder { ...@@ -70,11 +70,13 @@ public class JavaExtendsListHolder {
70 * 70 *
71 * @param info java file info 71 * @param info java file info
72 * @param node YANG node 72 * @param node YANG node
73 + * @param tempJavaFragmentFiles temp java fragment files
73 */ 74 */
74 - public void addToExtendsList(JavaQualifiedTypeInfo info, YangNode node) { 75 + public void addToExtendsList(JavaQualifiedTypeInfo info, YangNode node,
76 + TempJavaFragmentFiles tempJavaFragmentFiles) {
75 JavaFileInfo fileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo(); 77 JavaFileInfo fileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo();
76 78
77 - JavaImportData importData = getTempJavaFragment(node).getJavaImportData(); 79 + JavaImportData importData = tempJavaFragmentFiles.getJavaImportData();
78 boolean qualified = importData.addImportInfo(info, 80 boolean qualified = importData.addImportInfo(info,
79 getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage()); 81 getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage());
80 82
......
...@@ -22,7 +22,9 @@ import java.util.ArrayList; ...@@ -22,7 +22,9 @@ import java.util.ArrayList;
22 import java.util.List; 22 import java.util.List;
23 23
24 import org.onosproject.yangutils.datamodel.YangAugment; 24 import org.onosproject.yangutils.datamodel.YangAugment;
25 +import org.onosproject.yangutils.datamodel.YangAugmentableNode;
25 import org.onosproject.yangutils.datamodel.YangNode; 26 import org.onosproject.yangutils.datamodel.YangNode;
27 +import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
26 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; 28 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
27 import org.onosproject.yangutils.translator.tojava.JavaFileInfo; 29 import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
28 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 30 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
...@@ -63,12 +65,19 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. ...@@ -63,12 +65,19 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.
63 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; 65 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
64 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; 66 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
65 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; 67 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
66 -import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle; 68 +import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getCurNodeAsAttributeInTarget;
69 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAugmentationAttribute;
67 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEnumsValueAttribute; 70 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEnumsValueAttribute;
71 +import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEventEnumTypeStart;
72 +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle;
68 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; 73 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
69 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addActivateMethod; 74 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addActivateMethod;
70 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod; 75 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod;
76 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl;
77 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentInfoImpl;
71 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedNodesConstructorStart; 78 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedNodesConstructorStart;
79 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForManager;
80 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForService;
72 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart; 81 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart;
73 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstructor; 82 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsConstructor;
74 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfMethod; 83 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEnumsOfMethod;
...@@ -77,12 +86,16 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator ...@@ -77,12 +86,16 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator
77 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodClose; 86 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodClose;
78 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodSignature; 87 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethodSignature;
79 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetter; 88 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetter;
89 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
90 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString;
80 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose; 91 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose;
81 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen; 92 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen;
82 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString; 93 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOmitNullValueString;
94 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
95 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
96 +import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
83 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodClose; 97 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodClose;
84 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen; 98 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen;
85 -import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEventEnumTypeStart;
86 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 99 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
87 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 100 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
88 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; 101 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
...@@ -320,12 +333,10 @@ public final class JavaFileGenerator { ...@@ -320,12 +333,10 @@ public final class JavaFileGenerator {
320 * @param file file 333 * @param file file
321 * @param imports imports for the file 334 * @param imports imports for the file
322 * @param curNode current YANG node 335 * @param curNode current YANG node
323 - * @param isAttrPresent if any attribute is present or not
324 * @return builder class file 336 * @return builder class file
325 * @throws IOException when fails to write in file 337 * @throws IOException when fails to write in file
326 */ 338 */
327 - public static File generateManagerClassFile(File file, List<String> imports, YangNode curNode, 339 + public static File generateManagerClassFile(File file, List<String> imports, YangNode curNode)
328 - boolean isAttrPresent)
329 throws IOException { 340 throws IOException {
330 341
331 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); 342 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
...@@ -341,25 +352,26 @@ public final class JavaFileGenerator { ...@@ -341,25 +352,26 @@ public final class JavaFileGenerator {
341 methods.add(addActivateMethod()); 352 methods.add(addActivateMethod());
342 methods.add(addDeActivateMethod()); 353 methods.add(addDeActivateMethod());
343 354
355 + TempJavaServiceFragmentFiles tempJavaServiceFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
356 + .getTempJavaCodeFragmentFiles().getServiceTempFiles();
357 +
358 + JavaAttributeInfo rootAttribute = getCurNodeAsAttributeInTarget(curNode, curNode, false,
359 + tempJavaServiceFragmentFiles);
344 try { 360 try {
345 - if (isAttrPresent) {
346 /** 361 /**
347 * Getter methods. 362 * Getter methods.
348 */ 363 */
349 - methods.add( 364 + methods.add(getOverRideString() +
350 - getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, 365 + getGetterForClass(rootAttribute, GENERATE_SERVICE_AND_MANAGER) + NEW_LINE);
351 - ((TempJavaCodeFragmentFilesContainer) curNode)
352 - .getTempJavaCodeFragmentFiles().getServiceTempFiles(), path));
353 /** 366 /**
354 * Setter methods. 367 * Setter methods.
355 */ 368 */
356 - methods.add( 369 + methods.add(getOverRideString() +
357 - getDataFromTempFileHandle(SETTER_FOR_CLASS_MASK, 370 + getSetterForClass(rootAttribute, className, GENERATE_SERVICE_AND_MANAGER)
358 - ((TempJavaCodeFragmentFilesContainer) curNode)
359 - .getTempJavaCodeFragmentFiles().getServiceTempFiles(), path)
360 + NEW_LINE); 371 + NEW_LINE);
361 372
362 - } 373 + methods.add(getAugmentsDataMethodForManager(curNode) + NEW_LINE);
374 +
363 if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) { 375 if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) {
364 JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; 376 JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode;
365 /** 377 /**
...@@ -410,7 +422,9 @@ public final class JavaFileGenerator { ...@@ -410,7 +422,9 @@ public final class JavaFileGenerator {
410 if (curNode instanceof YangAugment) { 422 if (curNode instanceof YangAugment) {
411 isAugmentNode = true; 423 isAugmentNode = true;
412 } 424 }
413 - 425 + if (curNode instanceof YangAugmentableNode) {
426 + insertDataIntoJavaFile(file, addAugmentationAttribute());
427 + }
414 if (isAttrPresent) { 428 if (isAttrPresent) {
415 /** 429 /**
416 * Add attribute strings. 430 * Add attribute strings.
...@@ -483,6 +497,11 @@ public final class JavaFileGenerator { ...@@ -483,6 +497,11 @@ public final class JavaFileGenerator {
483 + " while impl class file generation"); 497 + " while impl class file generation");
484 } 498 }
485 499
500 + if (curNode instanceof YangAugmentableNode) {
501 + methods.add(getAddAugmentInfoMethodImpl());
502 + methods.add(getAugmentInfoImpl());
503 + }
504 +
486 /** 505 /**
487 * Add methods in impl class. 506 * Add methods in impl class.
488 */ 507 */
...@@ -796,38 +815,38 @@ public final class JavaFileGenerator { ...@@ -796,38 +815,38 @@ public final class JavaFileGenerator {
796 * @param file generated file 815 * @param file generated file
797 * @param curNode current YANG node 816 * @param curNode current YANG node
798 * @param imports imports for file 817 * @param imports imports for file
799 - * @param isAttributePresent is attribute present
800 * @return rpc class file 818 * @return rpc class file
801 * @throws IOException when fails to generate class file 819 * @throws IOException when fails to generate class file
802 */ 820 */
803 - public static File generateServiceInterfaceFile(File file, YangNode curNode, List<String> imports, 821 + public static File generateServiceInterfaceFile(File file, YangNode curNode, List<String> imports)
804 - boolean isAttributePresent)
805 throws IOException { 822 throws IOException {
806 823
807 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); 824 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
808 825
826 + TempJavaServiceFragmentFiles tempJavaServiceFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
827 + .getTempJavaCodeFragmentFiles().getServiceTempFiles();
809 String className = getCapitalCase(javaFileInfo.getJavaName()) + SERVICE_METHOD_STRING; 828 String className = getCapitalCase(javaFileInfo.getJavaName()) + SERVICE_METHOD_STRING;
810 String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 829 String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
811 initiateJavaFileGeneration(file, GENERATE_SERVICE_AND_MANAGER, imports, curNode, className); 830 initiateJavaFileGeneration(file, GENERATE_SERVICE_AND_MANAGER, imports, curNode, className);
812 831
813 List<String> methods = new ArrayList<>(); 832 List<String> methods = new ArrayList<>();
833 + JavaAttributeInfo rootAttribute = getCurNodeAsAttributeInTarget(curNode, curNode, false,
834 + tempJavaServiceFragmentFiles);
814 835
815 try { 836 try {
816 - if (isAttributePresent) {
817 -
818 /** 837 /**
819 * Getter methods. 838 * Getter methods.
820 */ 839 */
821 - methods.add(getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, 840 + methods.add(getGetterString(rootAttribute, GENERATE_SERVICE_AND_MANAGER,
822 - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 841 + javaFileInfo.getPluginConfig()) + NEW_LINE);
823 - .getServiceTempFiles(), path));
824 /** 842 /**
825 * Setter methods. 843 * Setter methods.
826 */ 844 */
827 - methods.add(getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK, 845 + methods.add(getSetterString(rootAttribute, className, GENERATE_SERVICE_AND_MANAGER,
828 - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 846 + javaFileInfo.getPluginConfig()) + NEW_LINE);
829 - .getServiceTempFiles(), path)); 847 +
830 - } 848 + methods.add(getAugmentsDataMethodForService(curNode) + NEW_LINE);
849 +
831 if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) { 850 if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) {
832 JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; 851 JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode;
833 /** 852 /**
......
...@@ -18,14 +18,23 @@ package org.onosproject.yangutils.translator.tojava.utils; ...@@ -18,14 +18,23 @@ package org.onosproject.yangutils.translator.tojava.utils;
18 18
19 import java.io.File; 19 import java.io.File;
20 import java.io.IOException; 20 import java.io.IOException;
21 +import java.util.ArrayList;
22 +import java.util.HashMap;
21 import java.util.List; 23 import java.util.List;
24 +import java.util.Map;
22 25
26 +import org.onosproject.yangutils.datamodel.YangAtomicPath;
23 import org.onosproject.yangutils.datamodel.YangAugment; 27 import org.onosproject.yangutils.datamodel.YangAugment;
24 import org.onosproject.yangutils.datamodel.YangNode; 28 import org.onosproject.yangutils.datamodel.YangNode;
29 +import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
25 import org.onosproject.yangutils.translator.exception.TranslatorException; 30 import org.onosproject.yangutils.translator.exception.TranslatorException;
31 +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
26 import org.onosproject.yangutils.translator.tojava.JavaFileInfo; 32 import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
27 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; 33 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
34 +import org.onosproject.yangutils.translator.tojava.JavaImportData;
35 +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
28 import org.onosproject.yangutils.translator.tojava.TempJavaBeanFragmentFiles; 36 import org.onosproject.yangutils.translator.tojava.TempJavaBeanFragmentFiles;
37 +import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
29 import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; 38 import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles;
30 import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; 39 import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles;
31 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; 40 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
...@@ -67,6 +76,8 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. ...@@ -67,6 +76,8 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.
67 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; 76 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
68 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; 77 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
69 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; 78 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
79 +import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode;
80 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getAugmentedNodesPackage;
70 import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; 81 import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition;
71 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 82 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
72 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 83 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
...@@ -553,4 +564,191 @@ public final class JavaFileGeneratorUtils { ...@@ -553,4 +564,191 @@ public final class JavaFileGeneratorUtils {
553 insertDataIntoJavaFile(file, generateClassDefinition(genType, fileName)); 564 insertDataIntoJavaFile(file, generateClassDefinition(genType, fileName));
554 } 565 }
555 566
567 + /**
568 + * Returns resolved augments for manager classes.
569 + *
570 + * @param parent parent node
571 + * @return resolved augments for manager classes
572 + */
573 + public static Map<YangAtomicPath, YangAugment> getResolvedAugmentsForManager(YangNode parent) {
574 + Map<YangAtomicPath, YangAugment> resolvedAugmentsForManager = new HashMap<>();
575 + YangNodeIdentifier nodeId;
576 + List<YangAtomicPath> targets = new ArrayList<>();
577 + for (YangAugment augment : getListOfAugments(parent)) {
578 + nodeId = augment.getTargetNode().get(0).getNodeIdentifier();
579 + if (validateNodeIdentifierInSet(nodeId, targets)) {
580 + targets.add(augment.getTargetNode().get(0));
581 + resolvedAugmentsForManager.put(augment.getTargetNode().get(0), augment);
582 + }
583 + }
584 + return resolvedAugmentsForManager;
585 + }
586 +
587 + /**
588 + * Returns set of node identifiers.
589 + *
590 + * @param parent parent node
591 + * @return set of node identifiers
592 + */
593 + public static List<YangAtomicPath> getSetOfNodeIdentifiers(YangNode parent) {
594 +
595 + List<YangAtomicPath> targets = new ArrayList<>();
596 + YangNodeIdentifier nodeId;
597 + List<YangAugment> augments = getListOfAugments(parent);
598 + for (YangAugment augment : augments) {
599 + nodeId = augment.getTargetNode().get(0).getNodeIdentifier();
600 +
601 + if (validateNodeIdentifierInSet(nodeId, targets)) {
602 + targets.add(augment.getTargetNode().get(0));
603 + }
604 + }
605 + return targets;
606 + }
607 +
608 + /* Returns list of augments.*/
609 + private static List<YangAugment> getListOfAugments(YangNode parent) {
610 + List<YangAugment> augments = new ArrayList<>();
611 + YangNode child = parent.getChild();
612 + while (child != null) {
613 + if (child instanceof YangAugment) {
614 + augments.add((YangAugment) child);
615 + }
616 + child = child.getNextSibling();
617 + }
618 + return augments;
619 + }
620 +
621 + /*Validates the set for duplicate names of node identifiers.*/
622 + private static boolean validateNodeIdentifierInSet(YangNodeIdentifier nodeId, List<YangAtomicPath> targets) {
623 + boolean isPresent = true;
624 + for (YangAtomicPath target : targets) {
625 + if (target.getNodeIdentifier().getName().equals(nodeId.getName())) {
626 + if (target.getNodeIdentifier().getPrefix() != null) {
627 + isPresent = !target.getNodeIdentifier().getPrefix().equals(nodeId.getPrefix());
628 + } else {
629 + isPresent = nodeId.getPrefix() != null;
630 + }
631 + }
632 + }
633 + return isPresent;
634 + }
635 +
636 + /**
637 + * Adds resolved augmented node imports to manager class.
638 + *
639 + * @param parent parent node
640 + */
641 + public static void addResolvedAugmentedDataNodeImports(YangNode parent) {
642 + Map<YangAtomicPath, YangAugment> resolvedAugmentsForManager = getResolvedAugmentsForManager(parent);
643 + List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent);
644 + TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = ((JavaCodeGeneratorInfo) parent)
645 + .getTempJavaCodeFragmentFiles();
646 + YangNode augmentedNode;
647 + JavaQualifiedTypeInfo javaQualifiedTypeInfo;
648 + String curNodeName;
649 + JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
650 + for (YangAtomicPath nodeId : targets) {
651 + augmentedNode = resolvedAugmentsForManager.get(nodeId).getResolveNodeInPath().get(nodeId);
652 + if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) {
653 + curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName();
654 + } else {
655 + curNodeName = getCapitalCase(getCamelCase(augmentedNode.getName(), parentInfo.getPluginConfig()
656 + .getConflictResolver()));
657 + }
658 +
659 + javaQualifiedTypeInfo = getQualifiedTypeInfoOfAugmentedNode(augmentedNode, getCapitalCase(curNodeName),
660 + parentInfo.getPluginConfig());
661 + tempJavaCodeFragmentFiles.getServiceTempFiles().getJavaImportData().addImportInfo(javaQualifiedTypeInfo,
662 + parentInfo.getJavaName(), parentInfo.getPackage());
663 +
664 + }
665 + }
666 +
667 + /**
668 + * Returns qualified type info of augmented node.
669 + *
670 + * @param augmentedNode augmented node
671 + * @param curNodeName current node name
672 + * @param pluginConfig plugin configurations
673 + * @return qualified type info of augmented node
674 + */
675 + public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfAugmentedNode(YangNode augmentedNode, String curNodeName,
676 + YangPluginConfig pluginConfig) {
677 + JavaQualifiedTypeInfo javaQualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(augmentedNode,
678 + getCapitalCase(curNodeName));
679 + if (javaQualifiedTypeInfo.getPkgInfo() == null) {
680 + javaQualifiedTypeInfo.setPkgInfo(getAugmentedNodesPackage(augmentedNode,
681 + pluginConfig));
682 + }
683 + return javaQualifiedTypeInfo;
684 + }
685 +
686 + /**
687 + * Validates if augmented node is imported in parent node.
688 + *
689 + * @param javaQualifiedTypeInfo qualified type info
690 + * @param importData import data
691 + * @return true if present in imports
692 + */
693 + private static boolean validateQualifiedInfoOfAugmentedNode(JavaQualifiedTypeInfo javaQualifiedTypeInfo,
694 + JavaImportData importData) {
695 + for (JavaQualifiedTypeInfo curImportInfo : importData.getImportSet()) {
696 + if (curImportInfo.getClassInfo()
697 + .contentEquals(javaQualifiedTypeInfo.getClassInfo())) {
698 + return curImportInfo.getPkgInfo()
699 + .contentEquals(javaQualifiedTypeInfo.getPkgInfo());
700 + }
701 + }
702 + return true;
703 + }
704 +
705 + /**
706 + * Return augmented class name for data methods in manager and service.
707 + *
708 + * @param augmentedNode augmented node
709 + * @param parent parent node
710 + * @return augmented class name for data methods in manager and service
711 + */
712 + public static String getAugmentedClassNameForDataMethods(YangNode augmentedNode, YangNode parent) {
713 + String curNodeName;
714 + JavaQualifiedTypeInfo javaQualifiedTypeInfo;
715 + JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
716 + YangPluginConfig pluginConfig = parentInfo.getPluginConfig();
717 + TempJavaServiceFragmentFiles tempJavaServiceFragmentFiles = ((JavaCodeGeneratorInfo) parent)
718 + .getTempJavaCodeFragmentFiles().getServiceTempFiles();
719 + if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) {
720 + curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName();
721 + } else {
722 + curNodeName = getCapitalCase(getCamelCase(augmentedNode.getName(), pluginConfig
723 + .getConflictResolver()));
724 + }
725 +
726 + javaQualifiedTypeInfo = getQualifiedTypeInfoOfAugmentedNode(augmentedNode,
727 + getCapitalCase(curNodeName),
728 + parentInfo.getPluginConfig());
729 + if (validateQualifiedInfoOfAugmentedNode(javaQualifiedTypeInfo,
730 + tempJavaServiceFragmentFiles.getJavaImportData())) {
731 + return javaQualifiedTypeInfo.getClassInfo();
732 + } else {
733 + return javaQualifiedTypeInfo.getPkgInfo() + PERIOD + javaQualifiedTypeInfo.getClassInfo();
734 + }
735 + }
736 +
737 + /**
738 + * Returns parent node name for data methods in manager and service.
739 + *
740 + * @param parent parent node
741 + * @param pluginConfig plugin configurations
742 + * @return parent node name for data methods in manager and service
743 + */
744 + public static String getParentNodeNameForDataMethods(YangNode parent, YangPluginConfig pluginConfig) {
745 + JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
746 + if (parentInfo.getJavaName() != null) {
747 + return getCapitalCase(parentInfo.getJavaName());
748 + }
749 + return getCapitalCase(getCamelCase(parent.getName(), pluginConfig
750 + .getConflictResolver()));
751 +
752 + }
753 +
556 } 754 }
......
...@@ -19,19 +19,29 @@ package org.onosproject.yangutils.translator.tojava.utils; ...@@ -19,19 +19,29 @@ package org.onosproject.yangutils.translator.tojava.utils;
19 import java.util.List; 19 import java.util.List;
20 import java.util.Map; 20 import java.util.Map;
21 21
22 +import org.onosproject.yangutils.datamodel.YangAtomicPath;
23 +import org.onosproject.yangutils.datamodel.YangAugment;
24 +import org.onosproject.yangutils.datamodel.YangNode;
22 import org.onosproject.yangutils.datamodel.YangType; 25 import org.onosproject.yangutils.datamodel.YangType;
23 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; 26 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
24 import org.onosproject.yangutils.translator.exception.TranslatorException; 27 import org.onosproject.yangutils.translator.exception.TranslatorException;
25 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; 28 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
29 +import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
26 import org.onosproject.yangutils.utils.io.impl.JavaDocGen; 30 import org.onosproject.yangutils.utils.io.impl.JavaDocGen;
27 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 31 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
28 32
29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; 33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
30 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 34 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
35 +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentedClassNameForDataMethods;
36 +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods;
37 +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getResolvedAugmentsForManager;
38 +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers;
31 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; 39 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE;
32 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION; 40 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION;
33 import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; 41 import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
34 import static org.onosproject.yangutils.utils.UtilConstants.AND; 42 import static org.onosproject.yangutils.utils.UtilConstants.AND;
43 +import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION;
44 +import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
35 import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL; 45 import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL;
36 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; 46 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
37 import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; 47 import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
...@@ -43,6 +53,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER; ...@@ -43,6 +53,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER;
43 import static org.onosproject.yangutils.utils.UtilConstants.CASE; 53 import static org.onosproject.yangutils.utils.UtilConstants.CASE;
44 import static org.onosproject.yangutils.utils.UtilConstants.CATCH; 54 import static org.onosproject.yangutils.utils.UtilConstants.CATCH;
45 import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING; 55 import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING;
56 +import static org.onosproject.yangutils.utils.UtilConstants.CLASS;
57 +import static org.onosproject.yangutils.utils.UtilConstants.CLASS_STRING;
46 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 58 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
47 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; 59 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
48 import static org.onosproject.yangutils.utils.UtilConstants.COLAN; 60 import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
...@@ -63,6 +75,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.FALSE; ...@@ -63,6 +75,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.FALSE;
63 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; 75 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
64 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME; 76 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME;
65 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME; 77 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME;
78 +import static org.onosproject.yangutils.utils.UtilConstants.GET;
66 import static org.onosproject.yangutils.utils.UtilConstants.GET_BYTES; 79 import static org.onosproject.yangutils.utils.UtilConstants.GET_BYTES;
67 import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX; 80 import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX;
68 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING; 81 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING;
...@@ -75,6 +88,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; ...@@ -75,6 +88,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER;
75 import static org.onosproject.yangutils.utils.UtilConstants.LIST; 88 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
76 import static org.onosproject.yangutils.utils.UtilConstants.LONG; 89 import static org.onosproject.yangutils.utils.UtilConstants.LONG;
77 import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER; 90 import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER;
91 +import static org.onosproject.yangutils.utils.UtilConstants.MAP;
78 import static org.onosproject.yangutils.utils.UtilConstants.NEW; 92 import static org.onosproject.yangutils.utils.UtilConstants.NEW;
79 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 93 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
80 import static org.onosproject.yangutils.utils.UtilConstants.NULL; 94 import static org.onosproject.yangutils.utils.UtilConstants.NULL;
...@@ -94,6 +108,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.PARSE_LONG; ...@@ -94,6 +108,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.PARSE_LONG;
94 import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT; 108 import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT;
95 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 109 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
96 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; 110 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
111 +import static org.onosproject.yangutils.utils.UtilConstants.PUT;
97 import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; 112 import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
98 import static org.onosproject.yangutils.utils.UtilConstants.RETURN; 113 import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
99 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; 114 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
...@@ -117,6 +132,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.TRY; ...@@ -117,6 +132,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.TRY;
117 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; 132 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
118 import static org.onosproject.yangutils.utils.UtilConstants.VALUE; 133 import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
119 import static org.onosproject.yangutils.utils.UtilConstants.VOID; 134 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
135 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
120 import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO; 136 import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO;
121 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD; 137 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD;
122 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR; 138 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR;
...@@ -127,6 +143,8 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MAN ...@@ -127,6 +143,8 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MAN
127 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; 143 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD;
128 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD; 144 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
129 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; 145 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR;
146 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForAddAugmentation;
147 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForGetAugmentation;
130 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForTypeConstructor; 148 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForTypeConstructor;
131 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; 149 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
132 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 150 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
...@@ -941,6 +959,38 @@ public final class MethodsGenerator { ...@@ -941,6 +959,38 @@ public final class MethodsGenerator {
941 } 959 }
942 960
943 /** 961 /**
962 + * Returns implementation of add augmentation.
963 + *
964 + * @return implementation of add augmentation
965 + */
966 + public static String getAddAugmentInfoMethodImpl() {
967 + return NEW_LINE + generateForAddAugmentation() + FOUR_SPACE_INDENTATION +
968 + PUBLIC + SPACE + VOID + SPACE + ADD_STRING
969 + + AUGMENTATION + OPEN_PARENTHESIS + YANG_AUGMENTED_INFO + SPACE + VALUE + COMMA + SPACE + CLASS_STRING +
970 + SPACE + CLASS + OBJECT_STRING + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
971 + EIGHT_SPACE_INDENTATION + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + PUT + OPEN_PARENTHESIS +
972 + CLASS + OBJECT_STRING + COMMA + SPACE + VALUE +
973 + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION +
974 + CLOSE_CURLY_BRACKET + NEW_LINE;
975 + }
976 +
977 + /**
978 + * Returns implementation of get augment info.
979 + *
980 + * @return implementation of get augment info
981 + */
982 + public static String getAugmentInfoImpl() {
983 +
984 + return generateForGetAugmentation() + FOUR_SPACE_INDENTATION + PUBLIC + SPACE +
985 + YANG_AUGMENTED_INFO + SPACE + GET_METHOD_PREFIX +
986 + YANG_AUGMENTED_INFO + OPEN_PARENTHESIS + CLASS_STRING + SPACE + CLASS + OBJECT_STRING +
987 + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION +
988 + RETURN + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + GET + OPEN_PARENTHESIS + CLASS +
989 + OBJECT_STRING + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION +
990 + CLOSE_CURLY_BRACKET + NEW_LINE;
991 + }
992 +
993 + /**
944 * Returns enum's constructor. 994 * Returns enum's constructor.
945 * 995 *
946 * @param className enum's class name 996 * @param className enum's class name
...@@ -1096,4 +1146,90 @@ public final class MethodsGenerator { ...@@ -1096,4 +1146,90 @@ public final class MethodsGenerator {
1096 + VALUE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS 1146 + VALUE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
1097 + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; 1147 + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
1098 } 1148 }
1149 +
1150 + /**
1151 + * Returns augmented data getter and setter methods for service class.
1152 + *
1153 + * @param parent parent node
1154 + * @return augmented data getter and setter methods for service class
1155 + */
1156 + public static String getAugmentsDataMethodForService(YangNode parent) {
1157 + Map<YangAtomicPath, YangAugment> resolvedAugmentsForManager = getResolvedAugmentsForManager(parent);
1158 + List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent);
1159 + YangNode augmentedNode;
1160 + String curNodeName;
1161 + String method;
1162 + StringBuilder methods = new StringBuilder();
1163 + String parentName;
1164 + String returnType;
1165 + YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig();
1166 + for (YangAtomicPath nodeId : targets) {
1167 + augmentedNode = resolvedAugmentsForManager.get(nodeId).getResolveNodeInPath().get(nodeId);
1168 + if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) {
1169 + curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName();
1170 + } else {
1171 + curNodeName = getCapitalCase(getCamelCase(augmentedNode.getName(), pluginConfig
1172 + .getConflictResolver()));
1173 + }
1174 + returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent);
1175 + parentName = getParentNodeNameForDataMethods(augmentedNode.getParent(), pluginConfig);
1176 + method = getJavaDoc(GETTER_METHOD, getSmallCase(AUGMENTED + parentName + curNodeName), false,
1177 + pluginConfig) + getGetterForInterface(AUGMENTED + parentName
1178 + + getCapitalCase(curNodeName),
1179 + returnType, false, GENERATE_SERVICE_AND_MANAGER)
1180 + + NEW_LINE;
1181 + methods.append(method);
1182 +
1183 + method = getJavaDoc(MANAGER_SETTER_METHOD, AUGMENTED +
1184 + getCapitalCase(parentName) + curNodeName, false, pluginConfig) +
1185 + getSetterForInterface(getSmallCase(AUGMENTED) + parentName +
1186 + getCapitalCase(curNodeName), returnType, parentName,
1187 + false,
1188 + GENERATE_SERVICE_AND_MANAGER) + NEW_LINE;
1189 + methods.append(method);
1190 + }
1191 + return methods.toString();
1192 + }
1193 +
1194 + /**
1195 + * Returns augmented data getter and setter methods for manager class.
1196 + *
1197 + * @param parent parent node
1198 + * @return augmented data getter and setter methods for manager class
1199 + */
1200 + public static String getAugmentsDataMethodForManager(YangNode parent) {
1201 + Map<YangAtomicPath, YangAugment> resolvedAugmentsForManager = getResolvedAugmentsForManager(parent);
1202 + List<YangAtomicPath> targets = getSetOfNodeIdentifiers(parent);
1203 + YangNode augmentedNode;
1204 + String curNodeName;
1205 + String returnType;
1206 + String method;
1207 + StringBuilder methods = new StringBuilder();
1208 + String parentName;
1209 + YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig();
1210 + for (YangAtomicPath nodeId : targets) {
1211 + augmentedNode = resolvedAugmentsForManager.get(nodeId).getResolveNodeInPath().get(nodeId);
1212 + if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) {
1213 + curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName();
1214 + } else {
1215 + curNodeName = getCapitalCase(getCamelCase(augmentedNode.getName(), pluginConfig
1216 + .getConflictResolver()));
1217 + }
1218 + returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent);
1219 + parentName = getParentNodeNameForDataMethods(augmentedNode.getParent(), pluginConfig);
1220 + method = getOverRideString() + getGetter(returnType, AUGMENTED
1221 + + parentName + getCapitalCase(curNodeName),
1222 + GENERATE_SERVICE_AND_MANAGER) + NEW_LINE;
1223 + methods.append(method);
1224 +
1225 + method = getOverRideString() + getSetter(parentName, getSmallCase(AUGMENTED) +
1226 + getCapitalCase(parentName) + getCapitalCase(curNodeName),
1227 + returnType,
1228 + GENERATE_SERVICE_AND_MANAGER)
1229 + + NEW_LINE;
1230 + methods.append(method);
1231 + }
1232 + return methods.toString();
1233 + }
1234 +
1099 } 1235 }
......
...@@ -97,11 +97,6 @@ public final class UtilConstants { ...@@ -97,11 +97,6 @@ public final class UtilConstants {
97 public static final String JAVA_DOC_RETURN = " * @return "; 97 public static final String JAVA_DOC_RETURN = " * @return ";
98 98
99 /** 99 /**
100 - * JavaDocs's throw annotation.
101 - */
102 - public static final String JAVA_DOC_THROWS = " * @throws ";
103 -
104 - /**
105 * JavaDocs's description for setter method. 100 * JavaDocs's description for setter method.
106 */ 101 */
107 public static final String JAVA_DOC_SETTERS = " * Returns the builder object of "; 102 public static final String JAVA_DOC_SETTERS = " * Returns the builder object of ";
...@@ -307,11 +302,6 @@ public final class UtilConstants { ...@@ -307,11 +302,6 @@ public final class UtilConstants {
307 public static final String IDENTITYREF = "identityref"; 302 public static final String IDENTITYREF = "identityref";
308 303
309 /** 304 /**
310 - * Static attribute for instance identifier string.
311 - */
312 - public static final String INSTANCE_IDENTIFIER = "instance-identifier";
313 -
314 - /**
315 * Static attribute for output variable of rpc. 305 * Static attribute for output variable of rpc.
316 */ 306 */
317 public static final String RPC_INPUT_VAR_NAME = "inputVar"; 307 public static final String RPC_INPUT_VAR_NAME = "inputVar";
...@@ -332,16 +322,6 @@ public final class UtilConstants { ...@@ -332,16 +322,6 @@ public final class UtilConstants {
332 public static final String ADD = "+"; 322 public static final String ADD = "+";
333 323
334 /** 324 /**
335 - * Static attribute for asterisk.
336 - */
337 - public static final String ASTERISK = "*";
338 -
339 - /**
340 - * Static attribute for at.
341 - */
342 - public static final String AT = "@";
343 -
344 - /**
345 * Static attribute for quotes. 325 * Static attribute for quotes.
346 */ 326 */
347 public static final String QUOTES = "\""; 327 public static final String QUOTES = "\"";
...@@ -357,6 +337,21 @@ public final class UtilConstants { ...@@ -357,6 +337,21 @@ public final class UtilConstants {
357 public static final String COMMA = ","; 337 public static final String COMMA = ",";
358 338
359 /** 339 /**
340 + * Static attribute for class.
341 + */
342 + public static final String CLASS_STRING = "Class";
343 +
344 + /**
345 + * Static attribute for put.
346 + */
347 + public static final String PUT = "put";
348 +
349 + /**
350 + * Static attribute for get.
351 + */
352 + public static final String GET = "get";
353 +
354 + /**
360 * Static attribute for slash character. 355 * Static attribute for slash character.
361 */ 356 */
362 public static final char CHAR_OF_SLASH = '/'; 357 public static final char CHAR_OF_SLASH = '/';
...@@ -432,11 +427,6 @@ public final class UtilConstants { ...@@ -432,11 +427,6 @@ public final class UtilConstants {
432 public static final String VALUE = "value"; 427 public static final String VALUE = "value";
433 428
434 /** 429 /**
435 - * Static attribute for enumValue syntax.
436 - */
437 - public static final String ENUM_VALUE = "enumValue";
438 -
439 - /**
440 * Static attribute for suffix s. 430 * Static attribute for suffix s.
441 */ 431 */
442 public static final String SUFFIX_S = "s"; 432 public static final String SUFFIX_S = "s";
...@@ -447,16 +437,6 @@ public final class UtilConstants { ...@@ -447,16 +437,6 @@ public final class UtilConstants {
447 public static final String IF = "if"; 437 public static final String IF = "if";
448 438
449 /** 439 /**
450 - * Static attribute for for.
451 - */
452 - public static final String FOR = "for";
453 -
454 - /**
455 - * Static attribute for while.
456 - */
457 - public static final String WHILE = "while";
458 -
459 - /**
460 * Static attribute for of. 440 * Static attribute for of.
461 */ 441 */
462 public static final String OF = "of"; 442 public static final String OF = "of";
...@@ -532,11 +512,6 @@ public final class UtilConstants { ...@@ -532,11 +512,6 @@ public final class UtilConstants {
532 public static final String OPEN_PARENTHESIS = "("; 512 public static final String OPEN_PARENTHESIS = "(";
533 513
534 /** 514 /**
535 - * Static attribute for clear syntax.
536 - */
537 - public static final String CLEAR = "clear";
538 -
539 - /**
540 * Static attribute for switch syntax. 515 * Static attribute for switch syntax.
541 */ 516 */
542 public static final String SWITCH = "switch"; 517 public static final String SWITCH = "switch";
...@@ -592,11 +567,6 @@ public final class UtilConstants { ...@@ -592,11 +567,6 @@ public final class UtilConstants {
592 public static final String FOUR_SPACE_INDENTATION = " "; 567 public static final String FOUR_SPACE_INDENTATION = " ";
593 568
594 /** 569 /**
595 - * Static attribute for not syntax.
596 - */
597 - public static final String NOT = "!";
598 -
599 - /**
600 * Static attribute for try syntax. 570 * Static attribute for try syntax.
601 */ 571 */
602 public static final String TRY = "try"; 572 public static final String TRY = "try";
...@@ -667,11 +637,6 @@ public final class UtilConstants { ...@@ -667,11 +637,6 @@ public final class UtilConstants {
667 public static final String ABSTRACT = "abstract"; 637 public static final String ABSTRACT = "abstract";
668 638
669 /** 639 /**
670 - * Static attribute for protected modifier.
671 - */
672 - public static final String PROTECTED = "protected";
673 -
674 - /**
675 * Void java type. 640 * Void java type.
676 */ 641 */
677 public static final String VOID = "void"; 642 public static final String VOID = "void";
...@@ -732,11 +697,6 @@ public final class UtilConstants { ...@@ -732,11 +697,6 @@ public final class UtilConstants {
732 public static final String LONG = "long"; 697 public static final String LONG = "long";
733 698
734 /** 699 /**
735 - * Float java built in type.
736 - */
737 - public static final String FLOAT = "float";
738 -
739 - /**
740 * Double java built in type. 700 * Double java built in type.
741 */ 701 */
742 public static final String DOUBLE = "double"; 702 public static final String DOUBLE = "double";
...@@ -767,14 +727,9 @@ public final class UtilConstants { ...@@ -767,14 +727,9 @@ public final class UtilConstants {
767 public static final String LONG_WRAPPER = "Long"; 727 public static final String LONG_WRAPPER = "Long";
768 728
769 /** 729 /**
770 - * YangUint64 java built in wrapper type. 730 + * Static varibale for question mark.
771 - */
772 - public static final String YANG_UINT64 = "YangUint64";
773 -
774 - /**
775 - * Double java built in wrapper type.
776 */ 731 */
777 - public static final String DOUBLE_WRAPPER = "Double"; 732 + public static final String QUESTION_MARK = "?";
778 733
779 /** 734 /**
780 * List of keywords in java, this is used for checking if the input does not contain these keywords. 735 * List of keywords in java, this is used for checking if the input does not contain these keywords.
...@@ -977,11 +932,22 @@ public final class UtilConstants { ...@@ -977,11 +932,22 @@ public final class UtilConstants {
977 public static final String OVERRIDE = "@Override"; 932 public static final String OVERRIDE = "@Override";
978 933
979 /** 934 /**
980 - * Static attribute for new line. 935 + * Static attribute for collections.
981 */ 936 */
982 public static final String COLLECTION_IMPORTS = "java.util"; 937 public static final String COLLECTION_IMPORTS = "java.util";
983 938
984 /** 939 /**
940 + * Static attribute for map.
941 + */
942 + public static final String MAP = "Map";
943 +
944 + /**
945 + * Static attribute for hash map.
946 + */
947 + public static final String HASH_MAP = "HashMap";
948 +
949 +
950 + /**
985 * Static attribute for more object import package. 951 * Static attribute for more object import package.
986 */ 952 */
987 public static final String GOOGLE_MORE_OBJECT_IMPORT_PKG = "com.google.common.base"; 953 public static final String GOOGLE_MORE_OBJECT_IMPORT_PKG = "com.google.common.base";
...@@ -1007,25 +973,14 @@ public final class UtilConstants { ...@@ -1007,25 +973,14 @@ public final class UtilConstants {
1007 public static final String JAVA_UTIL_OBJECTS_IMPORT_CLASS = "Objects;\n"; 973 public static final String JAVA_UTIL_OBJECTS_IMPORT_CLASS = "Objects;\n";
1008 974
1009 /** 975 /**
1010 - * Static attribute for AugmentationHolder class import package.
1011 - */
1012 - public static final String PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG =
1013 - "org.onosproject.yangutils.utils";
1014 -
1015 - /**
1016 - * Static attribute for AugmentationHolder class import class.
1017 - */
1018 - public static final String AUGMENTATION_HOLDER_CLASS_IMPORT_CLASS = "AugmentationHolder;\n";
1019 -
1020 - /**
1021 * Static attribute for AugmentedInfo class import package. 976 * Static attribute for AugmentedInfo class import package.
1022 */ 977 */
1023 - public static final String AUGMENTED_INFO_CLASS_IMPORT_PKG = "org.onosproject.yangutils.utils"; 978 + public static final String YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG = "org.onosproject.yangutils.datamodel";
1024 979
1025 /** 980 /**
1026 * Static attribute for AugmentedInfo class import class. 981 * Static attribute for AugmentedInfo class import class.
1027 */ 982 */
1028 - public static final String AUGMENTED_INFO_CLASS_IMPORT_CLASS = "AugmentedInfo;\n"; 983 + public static final String YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS = "YangAugmentedInfo;\n";
1029 984
1030 /** 985 /**
1031 * Static attribute for augmentation class. 986 * Static attribute for augmentation class.
...@@ -1033,19 +988,14 @@ public final class UtilConstants { ...@@ -1033,19 +988,14 @@ public final class UtilConstants {
1033 public static final String AUGMENTATION = "Augmentation"; 988 public static final String AUGMENTATION = "Augmentation";
1034 989
1035 /** 990 /**
1036 - * Static attribute for AugmentationHolder class.
1037 - */
1038 - public static final String AUGMENTATION_HOLDER = "AugmentationHolder";
1039 -
1040 - /**
1041 * Static attribute for AugmentedInfo class. 991 * Static attribute for AugmentedInfo class.
1042 */ 992 */
1043 - public static final String AUGMENTED_INFO = "AugmentedInfo"; 993 + public static final String YANG_AUGMENTED_INFO = "YangAugmentedInfo";
1044 994
1045 /** 995 /**
1046 - * Static attribute for augmentable. 996 + * Static attribute for augmented.
1047 */ 997 */
1048 - public static final String AUGMENTABLE = "Augmentable"; 998 + public static final String AUGMENTED = "Augmented";
1049 999
1050 /** 1000 /**
1051 * Static attribute for list. 1001 * Static attribute for list.
...@@ -1053,11 +1003,6 @@ public final class UtilConstants { ...@@ -1053,11 +1003,6 @@ public final class UtilConstants {
1053 public static final String LIST = "List"; 1003 public static final String LIST = "List";
1054 1004
1055 /** 1005 /**
1056 - * Static attribute for array list.
1057 - */
1058 - public static final String ARRAY_LIST = "ArrayList";
1059 -
1060 - /**
1061 * Comment to be added for autogenerated impl methods. 1006 * Comment to be added for autogenerated impl methods.
1062 */ 1007 */
1063 public static final String YANG_UTILS_TODO = "//TODO: YANG utils generated code"; 1008 public static final String YANG_UTILS_TODO = "//TODO: YANG utils generated code";
...@@ -1166,16 +1111,6 @@ public final class UtilConstants { ...@@ -1166,16 +1111,6 @@ public final class UtilConstants {
1166 public static final String EVENT_LISTENER = "EventListener"; 1111 public static final String EVENT_LISTENER = "EventListener";
1167 1112
1168 /** 1113 /**
1169 - * Static attribute for YANG types package.
1170 - */
1171 - public static final String YANG_TYPES_PKG = "org.onosproject.yangutils.datamodel.utils.builtindatatype";
1172 -
1173 - /**
1174 - * Static attribute for MathContext class.
1175 - */
1176 - public static final String MATH_CONTEXT = "MathContext";
1177 -
1178 - /**
1179 * Static attribute for YANG file error. 1114 * Static attribute for YANG file error.
1180 */ 1115 */
1181 public static final String YANG_FILE_ERROR = "YANG file error : "; 1116 public static final String YANG_FILE_ERROR = "YANG file error : ";
......
...@@ -16,11 +16,13 @@ ...@@ -16,11 +16,13 @@
16 16
17 package org.onosproject.yangutils.utils.io.impl; 17 package org.onosproject.yangutils.utils.io.impl;
18 18
19 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 19 +import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
20 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
20 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 21 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
21 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC; 22 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC;
22 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC; 23 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC;
23 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_OBJECT; 24 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_OBJECT;
25 +import static org.onosproject.yangutils.utils.UtilConstants.CLASS;
24 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 26 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
25 import static org.onosproject.yangutils.utils.UtilConstants.ENUM_ATTRIBUTE_JAVADOC; 27 import static org.onosproject.yangutils.utils.UtilConstants.ENUM_ATTRIBUTE_JAVADOC;
26 import static org.onosproject.yangutils.utils.UtilConstants.ENUM_CLASS_JAVADOC; 28 import static org.onosproject.yangutils.utils.UtilConstants.ENUM_CLASS_JAVADOC;
...@@ -47,9 +49,11 @@ import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_RPC; ...@@ -47,9 +49,11 @@ import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_RPC;
47 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS; 49 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS;
48 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS_COMMON; 50 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS_COMMON;
49 import static org.onosproject.yangutils.utils.UtilConstants.LIST; 51 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
52 +import static org.onosproject.yangutils.utils.UtilConstants.MAP;
50 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 53 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
51 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE_ASTERISK; 54 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE_ASTERISK;
52 import static org.onosproject.yangutils.utils.UtilConstants.OBJECT; 55 import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
56 +import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING;
53 import static org.onosproject.yangutils.utils.UtilConstants.OF; 57 import static org.onosproject.yangutils.utils.UtilConstants.OF;
54 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC; 58 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC;
55 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC_OF_CHILD; 59 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC_OF_CHILD;
...@@ -60,6 +64,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.SPACE; ...@@ -60,6 +64,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
60 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; 64 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
61 import static org.onosproject.yangutils.utils.UtilConstants.VALUE; 65 import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
62 import static org.onosproject.yangutils.utils.UtilConstants.VOID; 66 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
67 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
68 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
63 69
64 /** 70 /**
65 * Represents javadoc for the generated classes. 71 * Represents javadoc for the generated classes.
...@@ -73,122 +79,6 @@ public final class JavaDocGen { ...@@ -73,122 +79,6 @@ public final class JavaDocGen {
73 } 79 }
74 80
75 /** 81 /**
76 - * JavaDocs types.
77 - */
78 - public enum JavaDocType {
79 -
80 - /**
81 - * For class.
82 - */
83 - IMPL_CLASS,
84 -
85 - /**
86 - * For builder class.
87 - */
88 - BUILDER_CLASS,
89 -
90 - /**
91 - * For interface.
92 - */
93 - INTERFACE,
94 -
95 - /**
96 - * For builder interface.
97 - */
98 - BUILDER_INTERFACE,
99 -
100 - /**
101 - * For package-info.
102 - */
103 - PACKAGE_INFO,
104 -
105 - /**
106 - * For getters.
107 - */
108 - GETTER_METHOD,
109 -
110 - /**
111 - * For rpc service.
112 - */
113 - RPC_INTERFACE,
114 -
115 - /**
116 - * For rpc manager.
117 - */
118 - RPC_MANAGER,
119 -
120 - /**
121 - * For event.
122 - */
123 - EVENT,
124 -
125 - /**
126 - * For event listener.
127 - */
128 - EVENT_LISTENER,
129 -
130 - /**
131 - * For setters.
132 - */
133 - SETTER_METHOD,
134 -
135 - /**
136 - * For type def's setters.
137 - */
138 - TYPE_DEF_SETTER_METHOD,
139 -
140 - /**
141 - * For of method.
142 - */
143 - OF_METHOD,
144 -
145 - /**
146 - * For default constructor.
147 - */
148 - DEFAULT_CONSTRUCTOR,
149 -
150 - /**
151 - * For constructor.
152 - */
153 - CONSTRUCTOR,
154 -
155 - /**
156 - * For from method.
157 - */
158 - FROM_METHOD,
159 -
160 - /**
161 - * For type constructor.
162 - */
163 - TYPE_CONSTRUCTOR,
164 -
165 - /**
166 - * For build.
167 - */
168 - BUILD_METHOD,
169 -
170 - /**
171 - * For enum.
172 - */
173 - ENUM_CLASS,
174 -
175 - /**
176 - * For enum's attributes.
177 - */
178 - ENUM_ATTRIBUTE,
179 -
180 - /**
181 - * For manager setters.
182 - */
183 - MANAGER_SETTER_METHOD,
184 -
185 - /**
186 - * For event subject.
187 - */
188 - EVENT_SUBJECT_CLASS
189 - }
190 -
191 - /**
192 * Returns java docs. 82 * Returns java docs.
193 * 83 *
194 * @param type java doc type 84 * @param type java doc type
...@@ -596,4 +486,143 @@ public final class JavaDocGen { ...@@ -596,4 +486,143 @@ public final class JavaDocGen {
596 + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE 486 + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE
597 + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; 487 + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
598 } 488 }
489 +
490 + /**
491 + * Generates javaDocs for add augmentation method.
492 + *
493 + * @return javaDocs
494 + */
495 + public static String generateForAddAugmentation() {
496 + return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION
497 + + JAVA_DOC_SETTERS_COMMON + getSmallCase(YANG_AUGMENTED_INFO) + MAP + PERIOD + NEW_LINE +
498 + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + VALUE + SPACE +
499 + VALUE + SPACE + OF + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + NEW_LINE + FOUR_SPACE_INDENTATION
500 + + JAVA_DOC_PARAM + CLASS + OBJECT_STRING + SPACE +
501 + VALUE + SPACE + OF + SPACE + AUGMENTED + CLASS + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
502 + }
503 +
504 + public static String generateForGetAugmentation() {
505 + return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION
506 + + JAVA_DOC_GETTERS + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD + NEW_LINE +
507 + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + CLASS +
508 + OBJECT_STRING + SPACE + VALUE + SPACE + OF + SPACE + AUGMENTED + CLASS + NEW_LINE +
509 + FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + VALUE + SPACE +
510 + OF + SPACE + YANG_AUGMENTED_INFO + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
511 + }
512 +
513 + /**
514 + * JavaDocs types.
515 + */
516 + public enum JavaDocType {
517 +
518 + /**
519 + * For class.
520 + */
521 + IMPL_CLASS,
522 +
523 + /**
524 + * For builder class.
525 + */
526 + BUILDER_CLASS,
527 +
528 + /**
529 + * For interface.
530 + */
531 + INTERFACE,
532 +
533 + /**
534 + * For builder interface.
535 + */
536 + BUILDER_INTERFACE,
537 +
538 + /**
539 + * For package-info.
540 + */
541 + PACKAGE_INFO,
542 +
543 + /**
544 + * For getters.
545 + */
546 + GETTER_METHOD,
547 +
548 + /**
549 + * For rpc service.
550 + */
551 + RPC_INTERFACE,
552 +
553 + /**
554 + * For rpc manager.
555 + */
556 + RPC_MANAGER,
557 +
558 + /**
559 + * For event.
560 + */
561 + EVENT,
562 +
563 + /**
564 + * For event listener.
565 + */
566 + EVENT_LISTENER,
567 +
568 + /**
569 + * For setters.
570 + */
571 + SETTER_METHOD,
572 +
573 + /**
574 + * For type def's setters.
575 + */
576 + TYPE_DEF_SETTER_METHOD,
577 +
578 + /**
579 + * For of method.
580 + */
581 + OF_METHOD,
582 +
583 + /**
584 + * For default constructor.
585 + */
586 + DEFAULT_CONSTRUCTOR,
587 +
588 + /**
589 + * For constructor.
590 + */
591 + CONSTRUCTOR,
592 +
593 + /**
594 + * For from method.
595 + */
596 + FROM_METHOD,
597 +
598 + /**
599 + * For type constructor.
600 + */
601 + TYPE_CONSTRUCTOR,
602 +
603 + /**
604 + * For build.
605 + */
606 + BUILD_METHOD,
607 +
608 + /**
609 + * For enum.
610 + */
611 + ENUM_CLASS,
612 +
613 + /**
614 + * For enum's attributes.
615 + */
616 + ENUM_ATTRIBUTE,
617 +
618 + /**
619 + * For manager setters.
620 + */
621 + MANAGER_SETTER_METHOD,
622 +
623 + /**
624 + * For event subject.
625 + */
626 + EVENT_SUBJECT_CLASS
627 + }
599 } 628 }
......
...@@ -206,7 +206,7 @@ public class InterJarLinkerTest { ...@@ -206,7 +206,7 @@ public class InterJarLinkerTest {
206 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);
207 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);
208 assertThat(true, is(folder.exists())); 208 assertThat(true, is(folder.exists()));
209 - assertThat(false, is(file.exists())); 209 + assertThat(true, is(file.exists()));
210 } 210 }
211 211
212 /** 212 /**
......
...@@ -50,6 +50,7 @@ public final class NotificationTranslatorTest { ...@@ -50,6 +50,7 @@ public final class NotificationTranslatorTest {
50 generateJavaCode(node, yangPluginConfig); 50 generateJavaCode(node, yangPluginConfig);
51 51
52 deleteDirectory("target/NotificationTest/"); 52 deleteDirectory("target/NotificationTest/");
53 + deleteDirectory("target/NotificationTest1/");
53 } 54 }
54 55
55 // TODO enhance the test cases, after having a framework of translator test. 56 // TODO enhance the test cases, after having a framework of translator test.
......
...@@ -26,7 +26,6 @@ import org.onosproject.yangutils.datamodel.YangAugment; ...@@ -26,7 +26,6 @@ import org.onosproject.yangutils.datamodel.YangAugment;
26 import org.onosproject.yangutils.datamodel.YangNode; 26 import org.onosproject.yangutils.datamodel.YangNode;
27 import org.onosproject.yangutils.datamodel.YangReferenceResolver; 27 import org.onosproject.yangutils.datamodel.YangReferenceResolver;
28 import org.onosproject.yangutils.datamodel.YangResolutionInfo; 28 import org.onosproject.yangutils.datamodel.YangResolutionInfo;
29 -import org.onosproject.yangutils.linker.exceptions.LinkerException;
30 import org.onosproject.yangutils.linker.impl.YangLinkerManager; 29 import org.onosproject.yangutils.linker.impl.YangLinkerManager;
31 import org.onosproject.yangutils.linker.impl.YangXpathLinker; 30 import org.onosproject.yangutils.linker.impl.YangXpathLinker;
32 import org.onosproject.yangutils.utils.io.impl.YangFileScanner; 31 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
...@@ -44,6 +43,7 @@ public class YangXpathLinkerTest { ...@@ -44,6 +43,7 @@ public class YangXpathLinkerTest {
44 private YangLinkerManager linkerManager = new YangLinkerManager(); 43 private YangLinkerManager linkerManager = new YangLinkerManager();
45 private static final String INTRA_FILE_PATH = "src/test/resources/xPathLinker/IntraFile/"; 44 private static final String INTRA_FILE_PATH = "src/test/resources/xPathLinker/IntraFile/";
46 private static final String INTER_FILE_PATH = "src/test/resources/xPathLinker/InterFile/"; 45 private static final String INTER_FILE_PATH = "src/test/resources/xPathLinker/InterFile/";
46 + private static final String CASE_FILE_PATH = "src/test/resources/xPathLinker/Case/";
47 47
48 /** 48 /**
49 * Unit test case for intra file linking for single level container. 49 * Unit test case for intra file linking for single level container.
...@@ -230,7 +230,7 @@ public class YangXpathLinkerTest { ...@@ -230,7 +230,7 @@ public class YangXpathLinkerTest {
230 * 230 *
231 * @throws IOException when fails to do IO operations 231 * @throws IOException when fails to do IO operations
232 */ 232 */
233 - @Test(expected = LinkerException.class) 233 + @Test
234 public void processIntraFileLinkingInUsesSingleLevel() throws IOException { 234 public void processIntraFileLinkingInUsesSingleLevel() throws IOException {
235 235
236 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/")); 236 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/"));
...@@ -260,7 +260,7 @@ public class YangXpathLinkerTest { ...@@ -260,7 +260,7 @@ public class YangXpathLinkerTest {
260 * 260 *
261 * @throws IOException when fails to do IO operations 261 * @throws IOException when fails to do IO operations
262 */ 262 */
263 - @Test(expected = LinkerException.class) 263 + @Test
264 public void processIntraFileLinkingInUsesMultiLevel() throws IOException { 264 public void processIntraFileLinkingInUsesMultiLevel() throws IOException {
265 265
266 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/")); 266 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/"));
...@@ -449,6 +449,9 @@ public class YangXpathLinkerTest { ...@@ -449,6 +449,9 @@ public class YangXpathLinkerTest {
449 utilManager.createYangNodeSet(); 449 utilManager.createYangNodeSet();
450 linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); 450 linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
451 linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); 451 linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
452 + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
453 + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
454 + linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
452 455
453 YangNode targetNode = null; 456 YangNode targetNode = null;
454 String targetNodeName = null; 457 String targetNodeName = null;
...@@ -459,7 +462,7 @@ public class YangXpathLinkerTest { ...@@ -459,7 +462,7 @@ public class YangXpathLinkerTest {
459 for (YangAugment augment : augments) { 462 for (YangAugment augment : augments) {
460 targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() 463 targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
461 .getName(); 464 .getName();
462 - targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); 465 + targetNode = augment.getAugmentedNode();
463 } 466 }
464 } 467 }
465 468
...@@ -481,7 +484,7 @@ public class YangXpathLinkerTest { ...@@ -481,7 +484,7 @@ public class YangXpathLinkerTest {
481 linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); 484 linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
482 linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); 485 linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
483 linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); 486 linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
484 - 487 + linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
485 YangNode targetNode = null; 488 YangNode targetNode = null;
486 String targetNodeName = null; 489 String targetNodeName = null;
487 490
...@@ -491,7 +494,7 @@ public class YangXpathLinkerTest { ...@@ -491,7 +494,7 @@ public class YangXpathLinkerTest {
491 for (YangAugment augment : augments) { 494 for (YangAugment augment : augments) {
492 targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() 495 targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
493 .getName(); 496 .getName();
494 - targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); 497 + targetNode = augment.getAugmentedNode();
495 } 498 }
496 } 499 }
497 500
...@@ -523,7 +526,7 @@ public class YangXpathLinkerTest { ...@@ -523,7 +526,7 @@ public class YangXpathLinkerTest {
523 for (YangAugment augment : augments) { 526 for (YangAugment augment : augments) {
524 targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() 527 targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
525 .getName(); 528 .getName();
526 - targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); 529 + targetNode = augment.getAugmentedNode();
527 } 530 }
528 } 531 }
529 532
...@@ -538,11 +541,11 @@ public class YangXpathLinkerTest { ...@@ -538,11 +541,11 @@ public class YangXpathLinkerTest {
538 @Test 541 @Test
539 public void processInterFileLinkingInUsesInAugment() throws IOException { 542 public void processInterFileLinkingInUsesInAugment() throws IOException {
540 543
541 - /* FIXME: when uses cloning is done test it.
542 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleUses/")); 544 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleUses/"));
543 utilManager.parseYangFileInfoSet(); 545 utilManager.parseYangFileInfoSet();
544 utilManager.createYangNodeSet(); 546 utilManager.createYangNodeSet();
545 linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); 547 linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
548 + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
546 linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); 549 linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
547 linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); 550 linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
548 linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); 551 linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
...@@ -556,12 +559,12 @@ public class YangXpathLinkerTest { ...@@ -556,12 +559,12 @@ public class YangXpathLinkerTest {
556 for (YangAugment augment : augments) { 559 for (YangAugment augment : augments) {
557 targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1) 560 targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1)
558 .getNodeIdentifier().getName(); 561 .getNodeIdentifier().getName();
559 - targetNode = linker.processXpathLinking(augment.getTargetNode(), node); 562 + targetNode = augment.getAugmentedNode();
560 } 563 }
561 } 564 }
562 565
563 assertThat(true, is(targetNode.getName().equals(targetNodeName))); 566 assertThat(true, is(targetNode.getName().equals(targetNodeName)));
564 - */ 567 +
565 } 568 }
566 569
567 /** 570 /**
...@@ -569,7 +572,7 @@ public class YangXpathLinkerTest { ...@@ -569,7 +572,7 @@ public class YangXpathLinkerTest {
569 * 572 *
570 * @throws IOException when fails to do IO operations 573 * @throws IOException when fails to do IO operations
571 */ 574 */
572 - @Test(expected = LinkerException.class) 575 + @Test
573 public void processInterFileLinkingInUsesMultiLevel() throws IOException { 576 public void processInterFileLinkingInUsesMultiLevel() throws IOException {
574 577
575 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/")); 578 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/"));
...@@ -596,4 +599,72 @@ public class YangXpathLinkerTest { ...@@ -596,4 +599,72 @@ public class YangXpathLinkerTest {
596 assertThat(true, is(targetNode.getName().equals(targetNodeName))); 599 assertThat(true, is(targetNode.getName().equals(targetNodeName)));
597 } 600 }
598 601
602 + /**
603 + * Unit test case for inter file linking for multi level uses inside augment.
604 + *
605 + * @throws IOException when fails to do IO operations
606 + */
607 + @Test
608 + public void processInterFileLinkingInMultipleSubmodules() throws IOException {
609 +
610 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "submodule/"));
611 + utilManager.parseYangFileInfoSet();
612 + utilManager.createYangNodeSet();
613 + linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
614 + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
615 + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
616 + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
617 + linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
618 +
619 + YangNode targetNode = null;
620 + String targetNodeName = null;
621 +
622 + for (YangNode node : utilManager.getYangNodeSet()) {
623 + List<YangAugment> augments = linker.getListOfYangAugment(node);
624 +
625 + for (YangAugment augment : augments) {
626 + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1)
627 + .getNodeIdentifier().getName();
628 + targetNode = augment.getAugmentedNode();
629 + }
630 + }
631 +
632 + assertThat(true, is(targetNode.getName().equals(targetNodeName)));
633 +
634 + }
635 +
636 + /**
637 + * Unit test case for inter file linking for multi level uses inside augment.
638 + *
639 + * @throws IOException when fails to do IO operations
640 + */
641 + @Test
642 + public void processInterFileLinkingInMultipleUses() throws IOException {
643 +
644 + /** FIXME: once order of linking is done.
645 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "uses/"));
646 + utilManager.parseYangFileInfoSet();
647 + utilManager.createYangNodeSet();
648 + linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
649 + linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
650 + linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
651 + linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
652 + linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
653 +
654 + YangNode targetNode = null;
655 + String targetNodeName = null;
656 +
657 + for (YangNode node : utilManager.getYangNodeSet()) {
658 + List<YangAugment> augments = linker.getListOfYangAugment(node);
659 +
660 + for (YangAugment augment : augments) {
661 + targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1)
662 + .getNodeIdentifier().getName();
663 + targetNode = augment.getAugmentedNode();
664 + }
665 + }
666 +
667 + assertThat(true, is(targetNode.getName().equals(targetNodeName)));
668 + */
669 + }
599 } 670 }
......
...@@ -113,8 +113,6 @@ public final class JavaIdentifierSyntaxTest { ...@@ -113,8 +113,6 @@ public final class JavaIdentifierSyntaxTest {
113 private static final String BASE_DIR_PKG = "target.UnitTestCase."; 113 private static final String BASE_DIR_PKG = "target.UnitTestCase.";
114 private static final String DIR_PATH = "exist1.exist2.exist3"; 114 private static final String DIR_PATH = "exist1.exist2.exist3";
115 private static final String PKG_INFO = "package-info.java"; 115 private static final String PKG_INFO = "package-info.java";
116 - private static final String BASE_PKG = "target/UnitTestCase";
117 - private static final String TEST_DATA_1 = "This is to append a text to the file first1\n";
118 116
119 /** 117 /**
120 * Unit test for private constructor. 118 * Unit test for private constructor.
...@@ -319,5 +317,6 @@ public final class JavaIdentifierSyntaxTest { ...@@ -319,5 +317,6 @@ public final class JavaIdentifierSyntaxTest {
319 assertThat(true, is(doesPackageExist(strPath))); 317 assertThat(true, is(doesPackageExist(strPath)));
320 createDir.delete(); 318 createDir.delete();
321 deleteDirectory(createDir); 319 deleteDirectory(createDir);
320 + deleteDirectory(new File(BASE_DIR_PKG.replace(PERIOD, SLASH)));
322 } 321 }
323 } 322 }
......
...@@ -20,6 +20,8 @@ import java.io.File; ...@@ -20,6 +20,8 @@ import java.io.File;
20 import java.io.IOException; 20 import java.io.IOException;
21 import java.lang.reflect.Constructor; 21 import java.lang.reflect.Constructor;
22 import java.lang.reflect.InvocationTargetException; 22 import java.lang.reflect.InvocationTargetException;
23 +
24 +import org.apache.commons.io.FileUtils;
23 import org.junit.Test; 25 import org.junit.Test;
24 26
25 import static org.apache.commons.io.FileUtils.deleteDirectory; 27 import static org.apache.commons.io.FileUtils.deleteDirectory;
...@@ -84,5 +86,6 @@ public final class FileSystemUtilTest { ...@@ -84,5 +86,6 @@ public final class FileSystemUtilTest {
84 appendFileContents(createFile, createSourceFile); 86 appendFileContents(createFile, createSourceFile);
85 updateFileHandle(createFile, null, true); 87 updateFileHandle(createFile, null, true);
86 deleteDirectory(dir); 88 deleteDirectory(dir);
89 + FileUtils.deleteDirectory(new File(BASE_PKG));
87 } 90 }
88 } 91 }
......
...@@ -67,7 +67,7 @@ public final class YangIoUtilsTest { ...@@ -67,7 +67,7 @@ public final class YangIoUtilsTest {
67 addPackageInfo(dirPath, CHECK1, CREATE_PATH, false, getStubPluginConfig()); 67 addPackageInfo(dirPath, CHECK1, CREATE_PATH, false, getStubPluginConfig());
68 File filePath = new File(dirPath + File.separator + PKG_INFO); 68 File filePath = new File(dirPath + File.separator + PKG_INFO);
69 assertThat(filePath.isFile(), is(true)); 69 assertThat(filePath.isFile(), is(true));
70 - FileUtils.deleteDirectory(dirPath); 70 + FileUtils.deleteDirectory(new File(BASE_DIR));
71 } 71 }
72 72
73 /** 73 /**
...@@ -83,7 +83,7 @@ public final class YangIoUtilsTest { ...@@ -83,7 +83,7 @@ public final class YangIoUtilsTest {
83 addPackageInfo(dirPath, CHECK1, PATH + CREATE_PATH, false, getStubPluginConfig()); 83 addPackageInfo(dirPath, CHECK1, PATH + CREATE_PATH, false, getStubPluginConfig());
84 File filePath = new File(dirPath + File.separator + PKG_INFO); 84 File filePath = new File(dirPath + File.separator + PKG_INFO);
85 assertThat(filePath.isFile(), is(true)); 85 assertThat(filePath.isFile(), is(true));
86 - FileUtils.deleteDirectory(dirPath); 86 + FileUtils.deleteDirectory(new File(BASE_DIR));
87 } 87 }
88 88
89 /** 89 /**
...@@ -99,7 +99,7 @@ public final class YangIoUtilsTest { ...@@ -99,7 +99,7 @@ public final class YangIoUtilsTest {
99 addPackageInfo(dirPath, CHECK1, PATH + CREATE_PATH, true, getStubPluginConfig()); 99 addPackageInfo(dirPath, CHECK1, PATH + CREATE_PATH, true, getStubPluginConfig());
100 File filePath = new File(dirPath + File.separator + PKG_INFO); 100 File filePath = new File(dirPath + File.separator + PKG_INFO);
101 assertThat(filePath.isFile(), is(true)); 101 assertThat(filePath.isFile(), is(true));
102 - FileUtils.deleteDirectory(dirPath); 102 + FileUtils.deleteDirectory(new File(BASE_DIR));
103 } 103 }
104 104
105 /** 105 /**
...@@ -117,6 +117,7 @@ public final class YangIoUtilsTest { ...@@ -117,6 +117,7 @@ public final class YangIoUtilsTest {
117 File filePath1 = new File(dirPath + File.separator + PKG_INFO); 117 File filePath1 = new File(dirPath + File.separator + PKG_INFO);
118 assertThat(filePath1.isFile(), is(false)); 118 assertThat(filePath1.isFile(), is(false));
119 FileUtils.deleteDirectory(dirPath); 119 FileUtils.deleteDirectory(dirPath);
120 + FileUtils.deleteDirectory(new File(BASE_DIR));
120 } 121 }
121 122
122 /** 123 /**
...@@ -180,7 +181,7 @@ public final class YangIoUtilsTest { ...@@ -180,7 +181,7 @@ public final class YangIoUtilsTest {
180 181
181 File dirPath = createDirectories(CREATE_PATH); 182 File dirPath = createDirectories(CREATE_PATH);
182 assertThat(dirPath.isDirectory(), is(true)); 183 assertThat(dirPath.isDirectory(), is(true));
183 - FileUtils.deleteDirectory(dirPath); 184 + FileUtils.deleteDirectory(new File(BASE_DIR));
184 } 185 }
185 186
186 /** 187 /**
......
...@@ -3,9 +3,6 @@ submodule acme-types { ...@@ -3,9 +3,6 @@ submodule acme-types {
3 belongs-to "test" { 3 belongs-to "test" {
4 prefix "test"; 4 prefix "test";
5 } 5 }
6 - import test1{
7 - prefix test1;
8 - }
9 organization ""; 6 organization "";
10 contact ""; 7 contact "";
11 8
......
...@@ -1723,9 +1723,9 @@ ...@@ -1723,9 +1723,9 @@
1723 uses tet:te-link-state-derived; 1723 uses tet:te-link-state-derived;
1724 } 1724 }
1725 1725
1726 - /* 1726 +
1727 augment "/te-link-event/te-link-attributes/underlay" { 1727 augment "/te-link-event/te-link-attributes/underlay" {
1728 description "Add state attributes to te-link underlay."; 1728 description "Add state attributes to te-link underlay.";
1729 uses te-link-state-underlay-attributes; 1729 uses te-link-state-underlay-attributes;
1730 - } */ 1730 + }
1731 } 1731 }
......
1 +module test {
2 + namespace "xpath:intra:single";
3 + prefix test ;
4 +
5 + include test1;
6 + include test2;
7 + include test4;
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 /cont5/cont6 {
20 + leaf a {
21 + type int32;
22 + }
23 + }
24 +
25 + augment /cont3/cont4/cont8 {
26 + leaf a {
27 + type int32;
28 + }
29 + }
30 +}
31 +
1 +submodule test1 {
2 +
3 + belongs-to test {
4 + prefix test;
5 + }
6 +
7 + include test4;
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 cont1 {
20 + leaf leaf1 {
21 + type int32;
22 + }
23 + container cont2 {
24 + leaf leaf2 {
25 + type int32;
26 + }
27 + }
28 + }
29 +
30 + augment /cont1/cont2 {
31 + container cont4 {
32 + leaf leaf1 {
33 + type int32;
34 + }
35 + }
36 + }
37 +
38 + augment /cont3/cont4 {
39 + container cont8 {
40 + leaf leaf8 {
41 + type int32;
42 + }
43 + }
44 + }
45 +
46 +}
47 +
1 +submodule test2{
2 + belongs-to test {
3 + prefix test;
4 + }
5 +
6 + include test1;
7 + organization "";
8 + contact "";
9 +
10 + description
11 + "Defines basic service types for L3VPN service.";
12 +
13 + revision "2015-12-16" {
14 + reference "";
15 + }
16 +
17 + container cont5 {
18 + leaf leaf5 {
19 + type int32;
20 + }
21 + container cont6 {
22 + leaf leaf6 {
23 + type int32;
24 + }
25 + }
26 + }
27 +
28 + augment /cont1/cont2/cont4 {
29 + container cont10 {
30 + leaf leaf10 {
31 + type int32;
32 + }
33 + }
34 + }
35 +}
36 +
1 +submodule test4 {
2 +
3 + belongs-to test {
4 + prefix test;
5 + }
6 +
7 + organization "";
8 + contact "";
9 +
10 + description
11 + "Defines basic service types for L3VPN service.";
12 +
13 + revision "2015-12-16" {
14 + reference "";
15 + }
16 +
17 + container cont3 {
18 + leaf leaf3 {
19 + type int32;
20 + }
21 + container cont4 {
22 + leaf leaf4 {
23 + type int32;
24 + }
25 + }
26 + }
27 +}
28 +
1 +module test {
2 + namespace "xpath:intra:single";
3 + prefix test ;
4 +
5 + include test1;
6 + include test2;
7 + include test4;
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 /cont5/cont6/cont3/cont4 {
20 + leaf a {
21 + type int32;
22 + }
23 + }
24 +
25 + augment /group1/cont3/cont4/cont8 {
26 + leaf a {
27 + type int32;
28 + }
29 + }
30 +}
31 +
1 +submodule test1 {
2 +
3 + belongs-to test {
4 + prefix test;
5 + }
6 +
7 + include test4;
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 cont1 {
20 + leaf leaf1 {
21 + type int32;
22 + }
23 + container cont2 {
24 + leaf leaf2 {
25 + type int32;
26 + }
27 + }
28 + }
29 +
30 + augment /cont1/cont2 {
31 + container cont4 {
32 + leaf leaf1 {
33 + type int32;
34 + }
35 + }
36 + }
37 +
38 + augment /group1/cont3/cont4 {
39 + container cont8 {
40 + leaf leaf8 {
41 + type int32;
42 + }
43 + }
44 + }
45 +
46 +}
47 +
1 +submodule test2{
2 + belongs-to test {
3 + prefix test;
4 + }
5 +
6 + include test1;
7 + include test4;
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 + grouping group2 {
20 + container cont11 {
21 + }
22 + }
23 +
24 + container cont5 {
25 + leaf leaf5 {
26 + type int32;
27 + }
28 + container cont6 {
29 + leaf leaf6 {
30 + type int32;
31 + }
32 + uses group1;
33 + }
34 + }
35 +
36 + container ethernet {
37 + leaf leaf10 {
38 + type string;
39 + }
40 + }
41 +
42 +
43 + augment /ethernet {
44 + uses group2;
45 + }
46 +
47 + augment /cont1/cont2/cont4 {
48 + container cont10 {
49 + leaf leaf10 {
50 + type int32;
51 + }
52 +
53 + }
54 + }
55 +}
56 +
1 +submodule test4 {
2 +
3 + belongs-to test {
4 + prefix test;
5 + }
6 +
7 + include test2;
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 + grouping group1 {
19 + container cont3 {
20 + leaf leaf3 {
21 + type int32;
22 + }
23 + container cont4 {
24 + leaf leaf4 {
25 + type int32;
26 + }
27 + }
28 + }
29 + }
30 +
31 + augment /ethernet/cont11 {
32 + leaf leaf11 {
33 + type int32;
34 + }
35 + }
36 +
37 +}
...@@ -21,7 +21,7 @@ module test { ...@@ -21,7 +21,7 @@ module test {
21 } 21 }
22 22
23 augment /test2:cont1/test2:cont2/test2:cont3/test1:cont2 { 23 augment /test2:cont1/test2:cont2/test2:cont3/test1:cont2 {
24 - leaf a { 24 + leaf leaf8 {
25 type int32; 25 type int32;
26 } 26 }
27 } 27 }
......
...@@ -29,7 +29,7 @@ module test1 { ...@@ -29,7 +29,7 @@ module test1 {
29 type int32; 29 type int32;
30 } 30 }
31 container cont2 { 31 container cont2 {
32 - leaf leaf1 { 32 + leaf leaf3 {
33 type int32; 33 type int32;
34 } 34 }
35 } 35 }
...@@ -37,12 +37,12 @@ module test1 { ...@@ -37,12 +37,12 @@ module test1 {
37 } 37 }
38 38
39 augment /test2:cont1/test2:cont2/test2:cont3 { 39 augment /test2:cont1/test2:cont2/test2:cont3 {
40 - leaf a { 40 + leaf leaf2 {
41 type int32; 41 type int32;
42 } 42 }
43 43
44 container cont2 { 44 container cont2 {
45 - leaf leaf1 { 45 + leaf leaf4 {
46 type int32; 46 type int32;
47 } 47 }
48 } 48 }
......
...@@ -13,11 +13,11 @@ module test2 { ...@@ -13,11 +13,11 @@ module test2 {
13 } 13 }
14 14
15 container cont1 { 15 container cont1 {
16 - leaf leaf1 { 16 + leaf leaf5 {
17 type int32; 17 type int32;
18 } 18 }
19 container cont2 { 19 container cont2 {
20 - leaf leaf1 { 20 + leaf leaf6 {
21 type int32; 21 type int32;
22 } 22 }
23 } 23 }
...@@ -25,7 +25,7 @@ module test2 { ...@@ -25,7 +25,7 @@ module test2 {
25 25
26 augment /cont1/cont2 { 26 augment /cont1/cont2 {
27 container cont3 { 27 container cont3 {
28 - leaf a { 28 + leaf leaf7 {
29 type string; 29 type string;
30 } 30 }
31 } 31 }
......
...@@ -23,7 +23,7 @@ module test { ...@@ -23,7 +23,7 @@ module test {
23 uses test2:group1; 23 uses test2:group1;
24 } 24 }
25 25
26 - augment /cont2/group1/cont1/cont2 { 26 + augment /cont2/cont1/cont2 {
27 leaf a { 27 leaf a {
28 type int32; 28 type int32;
29 } 29 }
......
...@@ -19,14 +19,14 @@ module test { ...@@ -19,14 +19,14 @@ module test {
19 } 19 }
20 20
21 augment /test2:cont1/test2:cont2/cont2 { 21 augment /test2:cont1/test2:cont2/cont2 {
22 - leaf a { 22 + leaf leaf {
23 type int32; 23 type int32;
24 } 24 }
25 uses group1; 25 uses group1;
26 } 26 }
27 27
28 - augment /test2:cont1/test2:cont2/cont2/group1/cont1/cont2 { 28 + augment /test2:cont1/test2:cont2/cont2/cont1/cont2 {
29 - leaf a { 29 + leaf leaf1 {
30 type int32; 30 type int32;
31 } 31 }
32 } 32 }
......
...@@ -21,7 +21,7 @@ submodule test1 { ...@@ -21,7 +21,7 @@ submodule test1 {
21 grouping group1 { 21 grouping group1 {
22 container cont1 { 22 container cont1 {
23 container cont2 { 23 container cont2 {
24 - leaf a { 24 + leaf leaf2 {
25 type string; 25 type string;
26 } 26 }
27 } 27 }
...@@ -29,7 +29,7 @@ submodule test1 { ...@@ -29,7 +29,7 @@ submodule test1 {
29 } 29 }
30 30
31 augment /test2:cont1/test2:cont2 { 31 augment /test2:cont1/test2:cont2 {
32 - leaf a { 32 + leaf leaf3 {
33 type int32; 33 type int32;
34 } 34 }
35 container cont2 { 35 container cont2 {
......
...@@ -13,11 +13,11 @@ module test2 { ...@@ -13,11 +13,11 @@ module test2 {
13 } 13 }
14 14
15 container cont1 { 15 container cont1 {
16 - leaf leaf1 { 16 + leaf leaf4 {
17 type int32; 17 type int32;
18 } 18 }
19 container cont2 { 19 container cont2 {
20 - leaf leaf1 { 20 + leaf leaf5 {
21 type int32; 21 type int32;
22 } 22 }
23 } 23 }
......
...@@ -29,7 +29,7 @@ module test { ...@@ -29,7 +29,7 @@ module test {
29 uses group1; 29 uses group1;
30 } 30 }
31 31
32 - augment /cont2/group1/cont1/cont3 { 32 + augment /cont2/cont1/cont3 {
33 leaf a { 33 leaf a {
34 type int32; 34 type int32;
35 } 35 }
......
...@@ -24,7 +24,7 @@ module test { ...@@ -24,7 +24,7 @@ module test {
24 uses group1; 24 uses group1;
25 } 25 }
26 26
27 - augment /cont2/group1/cont1 { 27 + augment /cont2/cont1 {
28 leaf a { 28 leaf a {
29 type int32; 29 type int32;
30 } 30 }
......