Committed by
Gerrit Code Review
multiFileYangTranslator
Change-Id: I2adfef3acaec4bd74ba2c487404d2c655b800988
Showing
108 changed files
with
1039 additions
and
1261 deletions
... | @@ -34,7 +34,8 @@ public interface CollisionDetector { | ... | @@ -34,7 +34,8 @@ public interface CollisionDetector { |
34 | * @throws DataModelException if there is any collision in YANG rules in | 34 | * @throws DataModelException if there is any collision in YANG rules in |
35 | * parsed data, corresponding exception should be thrown | 35 | * parsed data, corresponding exception should be thrown |
36 | */ | 36 | */ |
37 | - void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException; | 37 | + void detectCollidingChild(String identifierName, YangConstructType dataType) |
38 | + throws DataModelException; | ||
38 | 39 | ||
39 | /** | 40 | /** |
40 | * Check for the self collision. | 41 | * Check for the self collision. |
... | @@ -46,5 +47,6 @@ public interface CollisionDetector { | ... | @@ -46,5 +47,6 @@ public interface CollisionDetector { |
46 | * @throws DataModelException if there is any collision in YANG rules in | 47 | * @throws DataModelException if there is any collision in YANG rules in |
47 | * parsed data, corresponding exception should be thrown | 48 | * parsed data, corresponding exception should be thrown |
48 | */ | 49 | */ |
49 | - void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException; | 50 | + void detectSelfCollision(String identifierName, YangConstructType dataType) |
51 | + throws DataModelException; | ||
50 | } | 52 | } | ... | ... |
... | @@ -19,5 +19,5 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -19,5 +19,5 @@ package org.onosproject.yangutils.datamodel; |
19 | /** | 19 | /** |
20 | * Represents class having rpc and notification. | 20 | * Represents class having rpc and notification. |
21 | */ | 21 | */ |
22 | -public interface HasRpcNotification { | 22 | +public interface RpcNotificationContainer { |
23 | } | 23 | } | ... | ... |
... | @@ -19,6 +19,8 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ... | @@ -19,6 +19,8 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * Represents information about entity being resolved. | 21 | * Represents information about entity being resolved. |
22 | + * | ||
23 | + * @param <T> type of entity being resolved, uses / grouping | ||
22 | */ | 24 | */ |
23 | public class YangEntityToResolveInfo<T> { | 25 | public class YangEntityToResolveInfo<T> { |
24 | 26 | ||
... | @@ -58,13 +60,19 @@ public class YangEntityToResolveInfo<T> { | ... | @@ -58,13 +60,19 @@ public class YangEntityToResolveInfo<T> { |
58 | /** | 60 | /** |
59 | * Sets parent node which contains the entity to be resolved. | 61 | * Sets parent node which contains the entity to be resolved. |
60 | * | 62 | * |
61 | - * @param holderOfEntityToResolve parent node which contains the entity to be resolved | 63 | + * @param holderOfEntityToResolve parent node which contains the entity to |
64 | + * be resolved | ||
62 | */ | 65 | */ |
63 | public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) { | 66 | public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) { |
64 | this.holderOfEntityToResolve = holderOfEntityToResolve; | 67 | this.holderOfEntityToResolve = holderOfEntityToResolve; |
65 | } | 68 | } |
66 | 69 | ||
67 | - | 70 | + /** |
71 | + * Retrieves the prefix of the entity. | ||
72 | + * | ||
73 | + * @return entities prefix | ||
74 | + * @throws DataModelException data model error | ||
75 | + */ | ||
68 | public String getEntityPrefix() | 76 | public String getEntityPrefix() |
69 | throws DataModelException { | 77 | throws DataModelException { |
70 | if (getEntityToResolve() == null) { | 78 | if (getEntityToResolve() == null) { |
... | @@ -72,11 +80,11 @@ public class YangEntityToResolveInfo<T> { | ... | @@ -72,11 +80,11 @@ public class YangEntityToResolveInfo<T> { |
72 | } | 80 | } |
73 | 81 | ||
74 | String prefix; | 82 | String prefix; |
75 | - T entityToResolve = getEntityToResolve(); | 83 | + T entityToBeResolved = getEntityToResolve(); |
76 | - if (entityToResolve instanceof YangType) { | 84 | + if (entityToBeResolved instanceof YangType) { |
77 | - prefix = ((YangType<?>) entityToResolve).getPrefix(); | 85 | + prefix = ((YangType<?>) entityToBeResolved).getPrefix(); |
78 | - } else if (entityToResolve instanceof YangUses) { | 86 | + } else if (entityToBeResolved instanceof YangUses) { |
79 | - prefix = ((YangUses) entityToResolve).getPrefix(); | 87 | + prefix = ((YangUses) entityToBeResolved).getPrefix(); |
80 | } else { | 88 | } else { |
81 | throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); | 89 | throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); |
82 | } | 90 | } | ... | ... |
... | @@ -53,10 +53,12 @@ import org.onosproject.yangutils.utils.YangConstructType; | ... | @@ -53,10 +53,12 @@ import org.onosproject.yangutils.utils.YangConstructType; |
53 | * | when | 7.19.5 | 0..1 | - TODO | | 53 | * | when | 7.19.5 | 0..1 | - TODO | |
54 | * +--------------+---------+-------------+------------------+ | 54 | * +--------------+---------+-------------+------------------+ |
55 | */ | 55 | */ |
56 | + | ||
56 | /** | 57 | /** |
57 | * Represents leaf data represented in YANG. | 58 | * Represents leaf data represented in YANG. |
58 | */ | 59 | */ |
59 | -public class YangLeaf implements YangCommonInfo, Parsable { | 60 | +public class YangLeaf |
61 | + implements YangCommonInfo, Parsable { | ||
60 | 62 | ||
61 | /** | 63 | /** |
62 | * Name of leaf. | 64 | * Name of leaf. |
... | @@ -109,7 +111,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -109,7 +111,7 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
109 | * | 111 | * |
110 | * @return the leaf name | 112 | * @return the leaf name |
111 | */ | 113 | */ |
112 | - public String getLeafName() { | 114 | + public String getName() { |
113 | return name; | 115 | return name; |
114 | } | 116 | } |
115 | 117 | ||
... | @@ -270,7 +272,8 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -270,7 +272,8 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
270 | * @throws DataModelException a violation of data model rules | 272 | * @throws DataModelException a violation of data model rules |
271 | */ | 273 | */ |
272 | @Override | 274 | @Override |
273 | - public void validateDataOnEntry() throws DataModelException { | 275 | + public void validateDataOnEntry() |
276 | + throws DataModelException { | ||
274 | // TODO auto-generated method stub, to be implemented by parser | 277 | // TODO auto-generated method stub, to be implemented by parser |
275 | 278 | ||
276 | } | 279 | } |
... | @@ -281,7 +284,8 @@ public class YangLeaf implements YangCommonInfo, Parsable { | ... | @@ -281,7 +284,8 @@ public class YangLeaf implements YangCommonInfo, Parsable { |
281 | * @throws DataModelException a violation of data model rules | 284 | * @throws DataModelException a violation of data model rules |
282 | */ | 285 | */ |
283 | @Override | 286 | @Override |
284 | - public void validateDataOnExit() throws DataModelException { | 287 | + public void validateDataOnExit() |
288 | + throws DataModelException { | ||
285 | // TODO auto-generated method stub, to be implemented by parser | 289 | // TODO auto-generated method stub, to be implemented by parser |
286 | 290 | ||
287 | } | 291 | } | ... | ... |
... | @@ -49,10 +49,12 @@ import org.onosproject.yangutils.utils.YangConstructType; | ... | @@ -49,10 +49,12 @@ import org.onosproject.yangutils.utils.YangConstructType; |
49 | * | when | 7.19.5 | 0..1 | -TODO | | 49 | * | when | 7.19.5 | 0..1 | -TODO | |
50 | * +--------------+---------+-------------+------------------+ | 50 | * +--------------+---------+-------------+------------------+ |
51 | */ | 51 | */ |
52 | + | ||
52 | /** | 53 | /** |
53 | * Represents leaf-list data represented in YANG. | 54 | * Represents leaf-list data represented in YANG. |
54 | */ | 55 | */ |
55 | -public class YangLeafList implements YangCommonInfo, Parsable { | 56 | +public class YangLeafList |
57 | + implements YangCommonInfo, Parsable { | ||
56 | 58 | ||
57 | /** | 59 | /** |
58 | * Name of leaf-list. | 60 | * Name of leaf-list. |
... | @@ -132,7 +134,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -132,7 +134,7 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
132 | * | 134 | * |
133 | * @return the leaf-list name | 135 | * @return the leaf-list name |
134 | */ | 136 | */ |
135 | - public String getLeafName() { | 137 | + public String getName() { |
136 | return name; | 138 | return name; |
137 | } | 139 | } |
138 | 140 | ||
... | @@ -311,7 +313,8 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -311,7 +313,8 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
311 | * @throws DataModelException a violation of data model rules | 313 | * @throws DataModelException a violation of data model rules |
312 | */ | 314 | */ |
313 | @Override | 315 | @Override |
314 | - public void validateDataOnEntry() throws DataModelException { | 316 | + public void validateDataOnEntry() |
317 | + throws DataModelException { | ||
315 | // TODO auto-generated method stub, to be implemented by parser | 318 | // TODO auto-generated method stub, to be implemented by parser |
316 | 319 | ||
317 | } | 320 | } |
... | @@ -322,7 +325,8 @@ public class YangLeafList implements YangCommonInfo, Parsable { | ... | @@ -322,7 +325,8 @@ public class YangLeafList implements YangCommonInfo, Parsable { |
322 | * @throws DataModelException a violation of data model rules | 325 | * @throws DataModelException a violation of data model rules |
323 | */ | 326 | */ |
324 | @Override | 327 | @Override |
325 | - public void validateDataOnExit() throws DataModelException { | 328 | + public void validateDataOnExit() |
329 | + throws DataModelException { | ||
326 | // TODO auto-generated method stub, to be implemented by parser | 330 | // TODO auto-generated method stub, to be implemented by parser |
327 | 331 | ||
328 | } | 332 | } | ... | ... |
... | @@ -541,7 +541,7 @@ public class YangList extends YangNode | ... | @@ -541,7 +541,7 @@ public class YangList extends YangNode |
541 | */ | 541 | */ |
542 | for (String key : keys) { | 542 | for (String key : keys) { |
543 | for (YangLeaf leaf : leaves) { | 543 | for (YangLeaf leaf : leaves) { |
544 | - if (key.equals(leaf.getLeafName())) { | 544 | + if (key.equals(leaf.getName())) { |
545 | if (leaf.getDataType().getDataType() == YangDataTypes.EMPTY) { | 545 | if (leaf.getDataType().getDataType() == YangDataTypes.EMPTY) { |
546 | throw new DataModelException(" A leaf that is part of the key must not be the built-in " + | 546 | throw new DataModelException(" A leaf that is part of the key must not be the built-in " + |
547 | "type \"empty\"."); | 547 | "type \"empty\"."); |
... | @@ -586,7 +586,7 @@ public class YangList extends YangNode | ... | @@ -586,7 +586,7 @@ public class YangList extends YangNode |
586 | */ | 586 | */ |
587 | for (String key : keys) { | 587 | for (String key : keys) { |
588 | for (YangLeafList leafList : leafLists) { | 588 | for (YangLeafList leafList : leafLists) { |
589 | - if (key.equals(leafList.getLeafName())) { | 589 | + if (key.equals(leafList.getName())) { |
590 | if (leafList.getDataType().getDataType() == YangDataTypes.EMPTY) { | 590 | if (leafList.getDataType().getDataType() == YangDataTypes.EMPTY) { |
591 | throw new DataModelException(" A leaf-list that is part of the key must not be the built-in " + | 591 | throw new DataModelException(" A leaf-list that is part of the key must not be the built-in " + |
592 | "type \"empty\"."); | 592 | "type \"empty\"."); | ... | ... |
... | @@ -17,6 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,6 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import java.util.LinkedList; | 18 | import java.util.LinkedList; |
19 | import java.util.List; | 19 | import java.util.List; |
20 | + | ||
20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
21 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
22 | import org.onosproject.yangutils.utils.YangConstructType; | 23 | import org.onosproject.yangutils.utils.YangConstructType; |
... | @@ -68,8 +69,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi | ... | @@ -68,8 +69,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi |
68 | * Represents data model node to maintain information defined in YANG module. | 69 | * Represents data model node to maintain information defined in YANG module. |
69 | */ | 70 | */ |
70 | public class YangModule extends YangNode | 71 | public class YangModule extends YangNode |
71 | - implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo, | 72 | + implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, |
72 | - HasRpcNotification { | 73 | + RpcNotificationContainer { |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * Name of the module. | 76 | * Name of the module. | ... | ... |
... | @@ -234,8 +234,10 @@ public abstract class YangNode | ... | @@ -234,8 +234,10 @@ public abstract class YangNode |
234 | * Clone the current node contents and create a new node. | 234 | * Clone the current node contents and create a new node. |
235 | * | 235 | * |
236 | * @return cloned node | 236 | * @return cloned node |
237 | - * @throws CloneNotSupportedException clone is not supported by the referred node | 237 | + * @throws CloneNotSupportedException clone is not supported by the referred |
238 | + * node | ||
238 | */ | 239 | */ |
240 | + @Override | ||
239 | public YangNode clone() | 241 | public YangNode clone() |
240 | throws CloneNotSupportedException { | 242 | throws CloneNotSupportedException { |
241 | YangNode clonedNode = (YangNode) super.clone(); | 243 | YangNode clonedNode = (YangNode) super.clone(); |
... | @@ -247,8 +249,9 @@ public abstract class YangNode | ... | @@ -247,8 +249,9 @@ public abstract class YangNode |
247 | } | 249 | } |
248 | 250 | ||
249 | /** | 251 | /** |
250 | - * Clone the subtree from the specified source node to the mentioned target node. | 252 | + * Clone the subtree from the specified source node to the mentioned target |
251 | - * The source and target root node cloning is carried out by the caller. | 253 | + * node. The source and target root node cloning is carried out by the |
254 | + * caller. | ||
252 | * | 255 | * |
253 | * @param srcRootNode source node for sub tree cloning | 256 | * @param srcRootNode source node for sub tree cloning |
254 | * @param dstRootNode destination node where the sub tree needs to be cloned | 257 | * @param dstRootNode destination node where the sub tree needs to be cloned |
... | @@ -260,7 +263,6 @@ public abstract class YangNode | ... | @@ -260,7 +263,6 @@ public abstract class YangNode |
260 | YangNode nextNodeToClone = srcRootNode; | 263 | YangNode nextNodeToClone = srcRootNode; |
261 | TraversalType curTraversal; | 264 | TraversalType curTraversal; |
262 | 265 | ||
263 | - | ||
264 | YangNode clonedTreeCurNode = dstRootNode; | 266 | YangNode clonedTreeCurNode = dstRootNode; |
265 | YangNode newNode = null; | 267 | YangNode newNode = null; |
266 | 268 | ||
... | @@ -286,6 +288,7 @@ public abstract class YangNode | ... | @@ -286,6 +288,7 @@ public abstract class YangNode |
286 | newNode = nextNodeToClone.clone(); | 288 | newNode = nextNodeToClone.clone(); |
287 | detectCollisionWhileCloning(clonedTreeCurNode, newNode, curTraversal); | 289 | detectCollisionWhileCloning(clonedTreeCurNode, newNode, curTraversal); |
288 | } | 290 | } |
291 | + | ||
289 | if (curTraversal == CHILD) { | 292 | if (curTraversal == CHILD) { |
290 | 293 | ||
291 | /** | 294 | /** |
... | @@ -294,7 +297,8 @@ public abstract class YangNode | ... | @@ -294,7 +297,8 @@ public abstract class YangNode |
294 | clonedTreeCurNode.addChild(newNode); | 297 | clonedTreeCurNode.addChild(newNode); |
295 | 298 | ||
296 | /** | 299 | /** |
297 | - * update the cloned tree's travesal current node as the new node. | 300 | + * update the cloned tree's traversal current node as the |
301 | + * new node. | ||
298 | */ | 302 | */ |
299 | clonedTreeCurNode = newNode; | 303 | clonedTreeCurNode = newNode; |
300 | } else if (curTraversal == SIBILING) { | 304 | } else if (curTraversal == SIBILING) { |
... | @@ -339,8 +343,8 @@ public abstract class YangNode | ... | @@ -339,8 +343,8 @@ public abstract class YangNode |
339 | */ | 343 | */ |
340 | private static void detectCollisionWhileCloning(YangNode currentNode, YangNode newNode, TraversalType addAs) | 344 | private static void detectCollisionWhileCloning(YangNode currentNode, YangNode newNode, TraversalType addAs) |
341 | throws DataModelException { | 345 | throws DataModelException { |
342 | - if ((!(currentNode instanceof CollisionDetector)) | 346 | + if (!(currentNode instanceof CollisionDetector) |
343 | - || (!(newNode instanceof Parsable))) { | 347 | + || !(newNode instanceof Parsable)) { |
344 | throw new DataModelException("Node in data model tree does not support collision detection"); | 348 | throw new DataModelException("Node in data model tree does not support collision detection"); |
345 | } | 349 | } |
346 | 350 | ||
... | @@ -376,9 +380,10 @@ public abstract class YangNode | ... | @@ -376,9 +380,10 @@ public abstract class YangNode |
376 | 380 | ||
377 | if (newSibling.getParent() == null) { | 381 | if (newSibling.getParent() == null) { |
378 | /** | 382 | /** |
379 | - * Since the siblings needs to have a common parent, set the parent as the current node's parent | 383 | + * Since the siblings needs to have a common parent, set the parent |
384 | + * as the current node's parent | ||
380 | */ | 385 | */ |
381 | - newSibling.setParent(this.getParent()); | 386 | + newSibling.setParent(getParent()); |
382 | 387 | ||
383 | } else { | 388 | } else { |
384 | throw new DataModelException("Node is already part of a tree, and cannot be added as a sibling"); | 389 | throw new DataModelException("Node is already part of a tree, and cannot be added as a sibling"); | ... | ... |
... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ... | @@ -23,7 +23,7 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
23 | * Abstraction of YANG dependency resolution information. Abstracted to obtain the | 23 | * Abstraction of YANG dependency resolution information. Abstracted to obtain the |
24 | * resolution information. | 24 | * resolution information. |
25 | */ | 25 | */ |
26 | -public interface HasResolutionInfo { | 26 | +public interface YangReferenceResolver { |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * Returns unresolved resolution list. | 29 | * Returns unresolved resolution list. | ... | ... |
... | @@ -17,6 +17,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,6 +17,7 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import java.util.LinkedList; | 18 | import java.util.LinkedList; |
19 | import java.util.List; | 19 | import java.util.List; |
20 | + | ||
20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
21 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
22 | import org.onosproject.yangutils.utils.YangConstructType; | 23 | import org.onosproject.yangutils.utils.YangConstructType; |
... | @@ -76,8 +77,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi | ... | @@ -76,8 +77,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi |
76 | * Represents data model node to maintain information defined in YANG sub-module. | 77 | * Represents data model node to maintain information defined in YANG sub-module. |
77 | */ | 78 | */ |
78 | public class YangSubModule extends YangNode | 79 | public class YangSubModule extends YangNode |
79 | - implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo, | 80 | + implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, |
80 | - HasRpcNotification { | 81 | + RpcNotificationContainer { |
81 | 82 | ||
82 | /** | 83 | /** |
83 | * Name of sub module. | 84 | * Name of sub module. | ... | ... |
... | @@ -21,7 +21,7 @@ import java.util.List; | ... | @@ -21,7 +21,7 @@ import java.util.List; |
21 | /** | 21 | /** |
22 | * Represents the holder with type(s). | 22 | * Represents the holder with type(s). |
23 | */ | 23 | */ |
24 | -public interface HasType { | 24 | +public interface YangTypeContainer { |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Returns type list. | 27 | * Returns type list. | ... | ... |
... | @@ -54,7 +54,7 @@ import org.onosproject.yangutils.utils.YangConstructType; | ... | @@ -54,7 +54,7 @@ import org.onosproject.yangutils.utils.YangConstructType; |
54 | /** | 54 | /** |
55 | * Represents data model node to maintain information defined in YANG typedef. | 55 | * Represents data model node to maintain information defined in YANG typedef. |
56 | */ | 56 | */ |
57 | -public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, HasType { | 57 | +public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, YangTypeContainer { |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Default value in string, needs to be converted to the target object, | 60 | * Default value in string, needs to be converted to the target object, | ... | ... |
... | @@ -47,7 +47,7 @@ import org.onosproject.yangutils.utils.YangConstructType; | ... | @@ -47,7 +47,7 @@ import org.onosproject.yangutils.utils.YangConstructType; |
47 | /** | 47 | /** |
48 | * Represents data model node to maintain information defined in YANG union. | 48 | * Represents data model node to maintain information defined in YANG union. |
49 | */ | 49 | */ |
50 | -public class YangUnion extends YangNode implements Parsable, HasType { | 50 | +public class YangUnion extends YangNode implements Parsable, YangTypeContainer { |
51 | 51 | ||
52 | // List of YANG type. | 52 | // List of YANG type. |
53 | private List<YangType<?>> typeList; | 53 | private List<YangType<?>> typeList; | ... | ... |
... | @@ -276,14 +276,14 @@ public class YangUses | ... | @@ -276,14 +276,14 @@ public class YangUses |
276 | YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode; | 276 | YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode; |
277 | if (referredGrouping.getListOfLeaf() != null) { | 277 | if (referredGrouping.getListOfLeaf() != null) { |
278 | for (YangLeaf leaf : referredGrouping.getListOfLeaf()) { | 278 | for (YangLeaf leaf : referredGrouping.getListOfLeaf()) { |
279 | - ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leaf.getLeafName(), | 279 | + ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leaf.getName(), |
280 | YangConstructType.LEAF_DATA); | 280 | YangConstructType.LEAF_DATA); |
281 | usesParentLeavesHolder.addLeaf(leaf); | 281 | usesParentLeavesHolder.addLeaf(leaf); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | if (referredGrouping.getListOfLeafList() != null) { | 284 | if (referredGrouping.getListOfLeafList() != null) { |
285 | for (YangLeafList leafList : referredGrouping.getListOfLeafList()) { | 285 | for (YangLeafList leafList : referredGrouping.getListOfLeafList()) { |
286 | - ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leafList.getLeafName(), | 286 | + ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leafList.getName(), |
287 | YangConstructType.LEAF_LIST_DATA); | 287 | YangConstructType.LEAF_LIST_DATA); |
288 | usesParentLeavesHolder.addLeafList(leafList); | 288 | usesParentLeavesHolder.addLeafList(leafList); |
289 | } | 289 | } | ... | ... |
... | @@ -19,7 +19,7 @@ package org.onosproject.yangutils.datamodel.utils; | ... | @@ -19,7 +19,7 @@ package org.onosproject.yangutils.datamodel.utils; |
19 | import java.util.List; | 19 | import java.util.List; |
20 | 20 | ||
21 | import org.onosproject.yangutils.datamodel.CollisionDetector; | 21 | import org.onosproject.yangutils.datamodel.CollisionDetector; |
22 | -import org.onosproject.yangutils.datamodel.HasResolutionInfo; | 22 | +import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
23 | import org.onosproject.yangutils.datamodel.YangImport; | 23 | import org.onosproject.yangutils.datamodel.YangImport; |
24 | import org.onosproject.yangutils.datamodel.YangLeaf; | 24 | import org.onosproject.yangutils.datamodel.YangLeaf; |
25 | import org.onosproject.yangutils.datamodel.YangLeafList; | 25 | import org.onosproject.yangutils.datamodel.YangLeafList; |
... | @@ -112,9 +112,9 @@ public final class DataModelUtils { | ... | @@ -112,9 +112,9 @@ public final class DataModelUtils { |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | for (YangLeaf leaf : listOfLeaf) { | 114 | for (YangLeaf leaf : listOfLeaf) { |
115 | - if (leaf.getLeafName().equals(identifierName)) { | 115 | + if (leaf.getName().equals(identifierName)) { |
116 | throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \"" | 116 | throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \"" |
117 | - + leaf.getLeafName() + "\""); | 117 | + + leaf.getName() + "\""); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
... | @@ -134,9 +134,9 @@ public final class DataModelUtils { | ... | @@ -134,9 +134,9 @@ public final class DataModelUtils { |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | for (YangLeafList leafList : listOfLeafList) { | 136 | for (YangLeafList leafList : listOfLeafList) { |
137 | - if (leafList.getLeafName().equals(identifierName)) { | 137 | + if (leafList.getName().equals(identifierName)) { |
138 | throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " + | 138 | throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " + |
139 | - "list \"" + leafList.getLeafName() + "\""); | 139 | + "list \"" + leafList.getName() + "\""); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
... | @@ -154,13 +154,13 @@ public final class DataModelUtils { | ... | @@ -154,13 +154,13 @@ public final class DataModelUtils { |
154 | /* get the module node to add maintain the list of nested reference */ | 154 | /* get the module node to add maintain the list of nested reference */ |
155 | YangNode curNode = resolutionInfo.getEntityToResolveInfo() | 155 | YangNode curNode = resolutionInfo.getEntityToResolveInfo() |
156 | .getHolderOfEntityToResolve(); | 156 | .getHolderOfEntityToResolve(); |
157 | - while (!(curNode instanceof HasResolutionInfo)) { | 157 | + while (!(curNode instanceof YangReferenceResolver)) { |
158 | curNode = curNode.getParent(); | 158 | curNode = curNode.getParent(); |
159 | if (curNode == null) { | 159 | if (curNode == null) { |
160 | throw new DataModelException("Internal datamodel error: Datamodel tree is not correct"); | 160 | throw new DataModelException("Internal datamodel error: Datamodel tree is not correct"); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | - HasResolutionInfo resolutionNode = (HasResolutionInfo) curNode; | 163 | + YangReferenceResolver resolutionNode = (YangReferenceResolver) curNode; |
164 | 164 | ||
165 | if (!isPrefixValid(resolutionInfo.getEntityToResolveInfo().getEntityPrefix(), | 165 | if (!isPrefixValid(resolutionInfo.getEntityToResolveInfo().getEntityPrefix(), |
166 | resolutionNode)) { | 166 | resolutionNode)) { |
... | @@ -176,7 +176,7 @@ public final class DataModelUtils { | ... | @@ -176,7 +176,7 @@ public final class DataModelUtils { |
176 | * @param resolutionNode uses/type node which has the prefix with it | 176 | * @param resolutionNode uses/type node which has the prefix with it |
177 | * @return whether prefix is valid or not | 177 | * @return whether prefix is valid or not |
178 | */ | 178 | */ |
179 | - private static boolean isPrefixValid(String entityPrefix, HasResolutionInfo resolutionNode) { | 179 | + private static boolean isPrefixValid(String entityPrefix, YangReferenceResolver resolutionNode) { |
180 | if (entityPrefix == null) { | 180 | if (entityPrefix == null) { |
181 | return true; | 181 | return true; |
182 | } | 182 | } |
... | @@ -215,7 +215,7 @@ public final class DataModelUtils { | ... | @@ -215,7 +215,7 @@ public final class DataModelUtils { |
215 | * @throws DataModelException a violation of data model rules | 215 | * @throws DataModelException a violation of data model rules |
216 | */ | 216 | */ |
217 | public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList, | 217 | public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList, |
218 | - HasResolutionInfo dataModelRootNode) | 218 | + YangReferenceResolver dataModelRootNode) |
219 | throws DataModelException { | 219 | throws DataModelException { |
220 | 220 | ||
221 | for (YangResolutionInfo resolutionInfo : resolutionList) { | 221 | for (YangResolutionInfo resolutionInfo : resolutionList) { | ... | ... |
... | @@ -20,38 +20,42 @@ import org.onosproject.yangutils.datamodel.YangCase; | ... | @@ -20,38 +20,42 @@ import org.onosproject.yangutils.datamodel.YangCase; |
20 | import org.onosproject.yangutils.datamodel.YangChoice; | 20 | import org.onosproject.yangutils.datamodel.YangChoice; |
21 | import org.onosproject.yangutils.datamodel.YangContainer; | 21 | import org.onosproject.yangutils.datamodel.YangContainer; |
22 | import org.onosproject.yangutils.datamodel.YangGrouping; | 22 | import org.onosproject.yangutils.datamodel.YangGrouping; |
23 | +import org.onosproject.yangutils.datamodel.YangInput; | ||
23 | import org.onosproject.yangutils.datamodel.YangLeaf; | 24 | import org.onosproject.yangutils.datamodel.YangLeaf; |
25 | +import org.onosproject.yangutils.datamodel.YangLeafList; | ||
24 | import org.onosproject.yangutils.datamodel.YangList; | 26 | import org.onosproject.yangutils.datamodel.YangList; |
25 | import org.onosproject.yangutils.datamodel.YangModule; | 27 | import org.onosproject.yangutils.datamodel.YangModule; |
28 | +import org.onosproject.yangutils.datamodel.YangNotification; | ||
29 | +import org.onosproject.yangutils.datamodel.YangOutput; | ||
30 | +import org.onosproject.yangutils.datamodel.YangRpc; | ||
26 | import org.onosproject.yangutils.datamodel.YangSubModule; | 31 | import org.onosproject.yangutils.datamodel.YangSubModule; |
32 | +import org.onosproject.yangutils.datamodel.YangType; | ||
27 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 33 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
28 | import org.onosproject.yangutils.datamodel.YangUnion; | 34 | import org.onosproject.yangutils.datamodel.YangUnion; |
29 | import org.onosproject.yangutils.datamodel.YangUses; | 35 | import org.onosproject.yangutils.datamodel.YangUses; |
30 | -import org.onosproject.yangutils.datamodel.YangNotification; | 36 | +import org.onosproject.yangutils.translator.exception.TranslatorException; |
31 | -import org.onosproject.yangutils.datamodel.YangRpc; | ||
32 | -import org.onosproject.yangutils.datamodel.YangInput; | ||
33 | -import org.onosproject.yangutils.datamodel.YangOutput; | ||
34 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; | 37 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; |
35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase; | 38 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase; |
36 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice; | 39 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice; |
37 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer; | 40 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer; |
38 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; | 41 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; |
39 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; | 42 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; |
43 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput; | ||
40 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf; | 44 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf; |
45 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeafList; | ||
41 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList; | 46 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList; |
42 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | 47 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
48 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification; | ||
49 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput; | ||
50 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaRpc; | ||
43 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | 51 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
52 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType; | ||
44 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; | 53 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; |
45 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnion; | 54 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnion; |
46 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUses; | 55 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUses; |
47 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification; | ||
48 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaRpc; | ||
49 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput; | ||
50 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput; | ||
51 | -import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
52 | 56 | ||
53 | /** | 57 | /** |
54 | - *Represents factory to create data model objects based on the target file type. | 58 | + * Represents factory to create data model objects based on the target file type. |
55 | */ | 59 | */ |
56 | public final class YangDataModelFactory { | 60 | public final class YangDataModelFactory { |
57 | 61 | ||
... | @@ -294,6 +298,25 @@ public final class YangDataModelFactory { | ... | @@ -294,6 +298,25 @@ public final class YangDataModelFactory { |
294 | } | 298 | } |
295 | } | 299 | } |
296 | } | 300 | } |
301 | + | ||
302 | + /** | ||
303 | + * Returns based on the target language generate the inherited data model node. | ||
304 | + * | ||
305 | + * @param targetLanguage target language in which YANG mapping needs to be | ||
306 | + * generated | ||
307 | + * @return the corresponding inherited node based on the target language | ||
308 | + */ | ||
309 | + public static YangLeafList getYangLeafList(GeneratedLanguage targetLanguage) { | ||
310 | + switch (targetLanguage) { | ||
311 | + case JAVA_GENERATION: { | ||
312 | + return new YangJavaLeafList(); | ||
313 | + } | ||
314 | + default: { | ||
315 | + throw new RuntimeException("Only YANG to Java is supported."); | ||
316 | + } | ||
317 | + } | ||
318 | + } | ||
319 | + | ||
297 | /** | 320 | /** |
298 | * Returns based on the target language generate the inherited data model node. | 321 | * Returns based on the target language generate the inherited data model node. |
299 | * | 322 | * |
... | @@ -365,4 +388,21 @@ public final class YangDataModelFactory { | ... | @@ -365,4 +388,21 @@ public final class YangDataModelFactory { |
365 | } | 388 | } |
366 | } | 389 | } |
367 | } | 390 | } |
391 | + /** | ||
392 | + * Returns based on the target language generate the inherited data model node. | ||
393 | + * | ||
394 | + * @param targetLanguage target language in which YANG mapping needs to be | ||
395 | + * generated | ||
396 | + * @return the corresponding inherited node based on the target language | ||
397 | + */ | ||
398 | + public static YangType getYangType(GeneratedLanguage targetLanguage) { | ||
399 | + switch (targetLanguage) { | ||
400 | + case JAVA_GENERATION: { | ||
401 | + return new YangJavaType(); | ||
402 | + } | ||
403 | + default: { | ||
404 | + throw new RuntimeException("Only YANG to Java is supported."); | ||
405 | + } | ||
406 | + } | ||
407 | + } | ||
368 | } | 408 | } | ... | ... |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | package org.onosproject.yangutils.linker; | 17 | package org.onosproject.yangutils.linker; |
18 | 18 | ||
19 | import java.util.Map; | 19 | import java.util.Map; |
20 | -import org.onosproject.yangutils.datamodel.HasResolutionInfo; | 20 | +import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Abstraction of entity which provides linking service of YANG files. | 23 | * Abstraction of entity which provides linking service of YANG files. |
... | @@ -30,6 +30,6 @@ public interface YangLinker { | ... | @@ -30,6 +30,6 @@ public interface YangLinker { |
30 | * | 30 | * |
31 | * @param fileMapEntry map entry for which resolution is to be done | 31 | * @param fileMapEntry map entry for which resolution is to be done |
32 | * @param yangFilesMap map of dependent file and resolution information*/ | 32 | * @param yangFilesMap map of dependent file and resolution information*/ |
33 | - void resolveDependencies(Map.Entry<String, HasResolutionInfo> fileMapEntry, Map<String, | 33 | + void resolveDependencies(Map.Entry<String, YangReferenceResolver> fileMapEntry, Map<String, |
34 | - HasResolutionInfo> yangFilesMap); | 34 | + YangReferenceResolver> yangFilesMap); |
35 | } | 35 | } | ... | ... |
... | @@ -52,8 +52,8 @@ import org.onosproject.yangutils.parser.impl.listeners.MandatoryListener; | ... | @@ -52,8 +52,8 @@ import org.onosproject.yangutils.parser.impl.listeners.MandatoryListener; |
52 | import org.onosproject.yangutils.parser.impl.listeners.MaxElementsListener; | 52 | import org.onosproject.yangutils.parser.impl.listeners.MaxElementsListener; |
53 | import org.onosproject.yangutils.parser.impl.listeners.MinElementsListener; | 53 | import org.onosproject.yangutils.parser.impl.listeners.MinElementsListener; |
54 | import org.onosproject.yangutils.parser.impl.listeners.ModuleListener; | 54 | import org.onosproject.yangutils.parser.impl.listeners.ModuleListener; |
55 | -import org.onosproject.yangutils.parser.impl.listeners.NamespaceListener; | ||
56 | import org.onosproject.yangutils.parser.impl.listeners.NotificationListener; | 55 | import org.onosproject.yangutils.parser.impl.listeners.NotificationListener; |
56 | +import org.onosproject.yangutils.parser.impl.listeners.NamespaceListener; | ||
57 | import org.onosproject.yangutils.parser.impl.listeners.OrganizationListener; | 57 | import org.onosproject.yangutils.parser.impl.listeners.OrganizationListener; |
58 | import org.onosproject.yangutils.parser.impl.listeners.OutputListener; | 58 | import org.onosproject.yangutils.parser.impl.listeners.OutputListener; |
59 | import org.onosproject.yangutils.parser.impl.listeners.PatternRestrictionListener; | 59 | import org.onosproject.yangutils.parser.impl.listeners.PatternRestrictionListener; | ... | ... |
... | @@ -96,10 +96,10 @@ public final class BitsListener { | ... | @@ -96,10 +96,10 @@ public final class BitsListener { |
96 | 96 | ||
97 | switch (tmpData.getYangConstructType()) { | 97 | switch (tmpData.getYangConstructType()) { |
98 | case LEAF_DATA: | 98 | case LEAF_DATA: |
99 | - bitsNode.setBitsName(((YangLeaf) tmpData).getLeafName()); | 99 | + bitsNode.setBitsName(((YangLeaf) tmpData).getName()); |
100 | break; | 100 | break; |
101 | case LEAF_LIST_DATA: | 101 | case LEAF_LIST_DATA: |
102 | - bitsNode.setBitsName(((YangLeafList) tmpData).getLeafName()); | 102 | + bitsNode.setBitsName(((YangLeafList) tmpData).getName()); |
103 | break; | 103 | break; |
104 | // TODO typedef, union, deviate. | 104 | // TODO typedef, union, deviate. |
105 | default: | 105 | default: | ... | ... |
... | @@ -112,7 +112,7 @@ public final class EnumerationListener { | ... | @@ -112,7 +112,7 @@ public final class EnumerationListener { |
112 | switch (tmpData.getYangConstructType()) { | 112 | switch (tmpData.getYangConstructType()) { |
113 | case LEAF_DATA: | 113 | case LEAF_DATA: |
114 | // Set the name of enumeration same as leaf. | 114 | // Set the name of enumeration same as leaf. |
115 | - enumerationNode.setName(((YangLeaf) tmpData).getLeafName() + ENUMERATION_CLASS_SUFFIX); | 115 | + enumerationNode.setName(((YangLeaf) tmpData).getName() + ENUMERATION_CLASS_SUFFIX); |
116 | // Pop the stack entry to obtain the parent YANG node. | 116 | // Pop the stack entry to obtain the parent YANG node. |
117 | Parsable leaf = listener.getParsedDataStack().pop(); | 117 | Parsable leaf = listener.getParsedDataStack().pop(); |
118 | // Add the enumeration node to the parent holder of leaf. | 118 | // Add the enumeration node to the parent holder of leaf. |
... | @@ -122,7 +122,7 @@ public final class EnumerationListener { | ... | @@ -122,7 +122,7 @@ public final class EnumerationListener { |
122 | break; | 122 | break; |
123 | case LEAF_LIST_DATA: | 123 | case LEAF_LIST_DATA: |
124 | // Set the name of enumeration same as leaf list. | 124 | // Set the name of enumeration same as leaf list. |
125 | - enumerationNode.setName(((YangLeafList) tmpData).getLeafName() + ENUMERATION_CLASS_SUFFIX); | 125 | + enumerationNode.setName(((YangLeafList) tmpData).getName() + ENUMERATION_CLASS_SUFFIX); |
126 | // Pop the stack entry to obtain the parent YANG node. | 126 | // Pop the stack entry to obtain the parent YANG node. |
127 | Parsable leafList = listener.getParsedDataStack().pop(); | 127 | Parsable leafList = listener.getParsedDataStack().pop(); |
128 | // Add the enumeration node to the parent holder of leaf. | 128 | // Add the enumeration node to the parent holder of leaf. | ... | ... |
... | @@ -46,10 +46,12 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp | ... | @@ -46,10 +46,12 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp |
46 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; | 46 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; |
47 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 47 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
48 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; | 48 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; |
49 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds; | ||
49 | import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; | 50 | import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; |
50 | import static org.onosproject.yangutils.utils.YangConstructType.GROUPING_DATA; | 51 | import static org.onosproject.yangutils.utils.YangConstructType.GROUPING_DATA; |
51 | import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; | 52 | import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; |
52 | import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; | 53 | import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; |
54 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA; | ||
53 | 55 | ||
54 | /* | 56 | /* |
55 | * Reference: RFC6020 and YANG ANTLR Grammar | 57 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -166,5 +168,7 @@ public final class GroupingListener { | ... | @@ -166,5 +168,7 @@ public final class GroupingListener { |
166 | validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, GROUPING_DATA, | 168 | validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, GROUPING_DATA, |
167 | ctx.identifier().getText()); | 169 | ctx.identifier().getText()); |
168 | validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, GROUPING_DATA, ctx.identifier().getText()); | 170 | validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, GROUPING_DATA, ctx.identifier().getText()); |
171 | + validateMutuallyExclusiveChilds(ctx.typedefStatement(), TYPEDEF_DATA, ctx.groupingStatement(), GROUPING_DATA, | ||
172 | + GROUPING_DATA, ctx.identifier().getText()); | ||
169 | } | 173 | } |
170 | } | 174 | } | ... | ... |
... | @@ -29,15 +29,15 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G | ... | @@ -29,15 +29,15 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G |
29 | import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangInputNode; | 29 | import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangInputNode; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
32 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | 32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction |
33 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 33 | + .constructExtendedListenerErrorMessage; |
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction | ||
35 | + .constructListenerErrorMessage; | ||
34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; | 39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; |
38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 40 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
39 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonZero; | ||
40 | -import static org.onosproject.yangutils.utils.YangConstructType.DATA_DEF_DATA; | ||
41 | import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA; | 41 | import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA; |
42 | 42 | ||
43 | /* | 43 | /* |
... | @@ -88,9 +88,6 @@ public final class InputListener { | ... | @@ -88,9 +88,6 @@ public final class InputListener { |
88 | // Check for stack to be non empty. | 88 | // Check for stack to be non empty. |
89 | checkStackIsNotEmpty(listener, MISSING_HOLDER, INPUT_DATA, "", ENTRY); | 89 | checkStackIsNotEmpty(listener, MISSING_HOLDER, INPUT_DATA, "", ENTRY); |
90 | 90 | ||
91 | - validateCardinalityNonZero(ctx.dataDefStatement(), DATA_DEF_DATA, | ||
92 | - INPUT_DATA, "", ctx); | ||
93 | - | ||
94 | Parsable curData = listener.getParsedDataStack().peek(); | 91 | Parsable curData = listener.getParsedDataStack().peek(); |
95 | if (curData instanceof YangRpc) { | 92 | if (curData instanceof YangRpc) { |
96 | 93 | ... | ... |
... | @@ -23,10 +23,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,10 +23,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
25 | 25 | ||
26 | +import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION; | ||
27 | +import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangLeafList; | ||
26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; |
27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
29 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction |
32 | + .constructListenerErrorMessage; | ||
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
... | @@ -106,7 +109,7 @@ public final class LeafListListener { | ... | @@ -106,7 +109,7 @@ public final class LeafListListener { |
106 | int charPositionInLine = ctx.getStart().getCharPositionInLine(); | 109 | int charPositionInLine = ctx.getStart().getCharPositionInLine(); |
107 | detectCollidingChildUtil(listener, line, charPositionInLine, identifier, LEAF_LIST_DATA); | 110 | detectCollidingChildUtil(listener, line, charPositionInLine, identifier, LEAF_LIST_DATA); |
108 | 111 | ||
109 | - YangLeafList leafList = new YangLeafList(); | 112 | + YangLeafList leafList = getYangLeafList(JAVA_GENERATION); |
110 | leafList.setLeafName(identifier); | 113 | leafList.setLeafName(identifier); |
111 | 114 | ||
112 | Parsable tmpData = listener.getParsedDataStack().peek(); | 115 | Parsable tmpData = listener.getParsedDataStack().peek(); | ... | ... |
... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.parser.impl.listeners; | 17 | package org.onosproject.yangutils.parser.impl.listeners; |
18 | 18 | ||
19 | -import org.onosproject.yangutils.datamodel.HasResolutionInfo; | 19 | +import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
20 | import org.onosproject.yangutils.datamodel.YangModule; | 20 | import org.onosproject.yangutils.datamodel.YangModule; |
21 | import org.onosproject.yangutils.datamodel.YangRevision; | 21 | import org.onosproject.yangutils.datamodel.YangRevision; |
22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
... | @@ -116,7 +116,7 @@ public final class ModuleListener { | ... | @@ -116,7 +116,7 @@ public final class ModuleListener { |
116 | ctx.identifier().getText(), EXIT)); | 116 | ctx.identifier().getText(), EXIT)); |
117 | } | 117 | } |
118 | try { | 118 | try { |
119 | - ((HasResolutionInfo) listener.getParsedDataStack().peek()).resolveSelfFileLinking(); | 119 | + ((YangReferenceResolver) listener.getParsedDataStack().peek()).resolveSelfFileLinking(); |
120 | } catch (DataModelException e) { | 120 | } catch (DataModelException e) { |
121 | ParserException parserException = new ParserException(e.getMessage()); | 121 | ParserException parserException = new ParserException(e.getMessage()); |
122 | parserException.setLine(e.getLineNumber()); | 122 | parserException.setLine(e.getLineNumber()); | ... | ... |
... | @@ -40,10 +40,13 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp | ... | @@ -40,10 +40,13 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp |
40 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; | 40 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; |
41 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 41 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
42 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; | 42 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; |
43 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds; | ||
43 | import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; | 44 | import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; |
45 | +import static org.onosproject.yangutils.utils.YangConstructType.GROUPING_DATA; | ||
44 | import static org.onosproject.yangutils.utils.YangConstructType.NOTIFICATION_DATA; | 46 | import static org.onosproject.yangutils.utils.YangConstructType.NOTIFICATION_DATA; |
45 | import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; | 47 | import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; |
46 | import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; | 48 | import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; |
49 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA; | ||
47 | 50 | ||
48 | /* | 51 | /* |
49 | * Reference: RFC6020 and YANG ANTLR Grammar | 52 | * Reference: RFC6020 and YANG ANTLR Grammar |
... | @@ -156,5 +159,7 @@ public final class NotificationListener { | ... | @@ -156,5 +159,7 @@ public final class NotificationListener { |
156 | ctx.identifier().getText()); | 159 | ctx.identifier().getText()); |
157 | validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, NOTIFICATION_DATA, | 160 | validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, NOTIFICATION_DATA, |
158 | ctx.identifier().getText()); | 161 | ctx.identifier().getText()); |
162 | + validateMutuallyExclusiveChilds(ctx.typedefStatement(), TYPEDEF_DATA, ctx.groupingStatement(), GROUPING_DATA, | ||
163 | + NOTIFICATION_DATA, ctx.identifier().getText()); | ||
159 | } | 164 | } |
160 | } | 165 | } | ... | ... |
... | @@ -29,15 +29,15 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G | ... | @@ -29,15 +29,15 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G |
29 | import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangOutputNode; | 29 | import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangOutputNode; |
30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
32 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | 32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction |
33 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 33 | + .constructExtendedListenerErrorMessage; |
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction | ||
35 | + .constructListenerErrorMessage; | ||
34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; | 39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; |
38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 40 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
39 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonZero; | ||
40 | -import static org.onosproject.yangutils.utils.YangConstructType.DATA_DEF_DATA; | ||
41 | import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA; | 41 | import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA; |
42 | 42 | ||
43 | /* | 43 | /* |
... | @@ -88,9 +88,6 @@ public final class OutputListener { | ... | @@ -88,9 +88,6 @@ public final class OutputListener { |
88 | // Check for stack to be non empty. | 88 | // Check for stack to be non empty. |
89 | checkStackIsNotEmpty(listener, MISSING_HOLDER, OUTPUT_DATA, "", ENTRY); | 89 | checkStackIsNotEmpty(listener, MISSING_HOLDER, OUTPUT_DATA, "", ENTRY); |
90 | 90 | ||
91 | - validateCardinalityNonZero(ctx.dataDefStatement(), DATA_DEF_DATA, | ||
92 | - OUTPUT_DATA, "", ctx); | ||
93 | - | ||
94 | Parsable curData = listener.getParsedDataStack().peek(); | 91 | Parsable curData = listener.getParsedDataStack().peek(); |
95 | if (curData instanceof YangRpc) { | 92 | if (curData instanceof YangRpc) { |
96 | 93 | ... | ... |
... | @@ -37,9 +37,12 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp | ... | @@ -37,9 +37,12 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp |
37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; | 37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; |
38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; | 39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; |
40 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds; | ||
40 | import static org.onosproject.yangutils.utils.YangConstructType.RPC_DATA; | 41 | import static org.onosproject.yangutils.utils.YangConstructType.RPC_DATA; |
41 | import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA; | 42 | import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA; |
42 | import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA; | 43 | import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA; |
44 | +import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA; | ||
45 | +import static org.onosproject.yangutils.utils.YangConstructType.GROUPING_DATA; | ||
43 | import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; | 46 | import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA; |
44 | import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; | 47 | import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA; |
45 | import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; | 48 | import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA; |
... | @@ -154,6 +157,8 @@ public final class RpcListener { | ... | @@ -154,6 +157,8 @@ public final class RpcListener { |
154 | validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, RPC_DATA, ctx.identifier().getText()); | 157 | validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, RPC_DATA, ctx.identifier().getText()); |
155 | validateCardinalityMaxOne(ctx.inputStatement(), INPUT_DATA, RPC_DATA, ctx.identifier().getText()); | 158 | validateCardinalityMaxOne(ctx.inputStatement(), INPUT_DATA, RPC_DATA, ctx.identifier().getText()); |
156 | validateCardinalityMaxOne(ctx.outputStatement(), OUTPUT_DATA, RPC_DATA, ctx.identifier().getText()); | 159 | validateCardinalityMaxOne(ctx.outputStatement(), OUTPUT_DATA, RPC_DATA, ctx.identifier().getText()); |
160 | + validateMutuallyExclusiveChilds(ctx.typedefStatement(), TYPEDEF_DATA, ctx.groupingStatement(), GROUPING_DATA, | ||
161 | + RPC_DATA, ctx.identifier().getText()); | ||
157 | } | 162 | } |
158 | 163 | ||
159 | } | 164 | } | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.parser.impl.listeners; | 17 | package org.onosproject.yangutils.parser.impl.listeners; |
18 | 18 | ||
19 | -import org.onosproject.yangutils.datamodel.HasResolutionInfo; | 19 | +import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
20 | import org.onosproject.yangutils.datamodel.YangRevision; | 20 | import org.onosproject.yangutils.datamodel.YangRevision; |
21 | import org.onosproject.yangutils.datamodel.YangSubModule; | 21 | import org.onosproject.yangutils.datamodel.YangSubModule; |
22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
... | @@ -121,7 +121,7 @@ public final class SubModuleListener { | ... | @@ -121,7 +121,7 @@ public final class SubModuleListener { |
121 | ctx.identifier().getText(), EXIT)); | 121 | ctx.identifier().getText(), EXIT)); |
122 | } | 122 | } |
123 | try { | 123 | try { |
124 | - ((HasResolutionInfo) listener.getParsedDataStack().peek()).resolveSelfFileLinking(); | 124 | + ((YangReferenceResolver) listener.getParsedDataStack().peek()).resolveSelfFileLinking(); |
125 | } catch (DataModelException e) { | 125 | } catch (DataModelException e) { |
126 | ParserException parserException = new ParserException(e.getMessage()); | 126 | ParserException parserException = new ParserException(e.getMessage()); |
127 | parserException.setLine(e.getLineNumber()); | 127 | parserException.setLine(e.getLineNumber()); | ... | ... |
... | @@ -34,6 +34,8 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ... | @@ -34,6 +34,8 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
34 | 34 | ||
35 | import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED; | 35 | import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED; |
36 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo; | 36 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo; |
37 | +import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION; | ||
38 | +import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangType; | ||
37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 40 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction | 41 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction |
... | @@ -95,7 +97,7 @@ public final class TypeListener { | ... | @@ -95,7 +97,7 @@ public final class TypeListener { |
95 | YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText()); | 97 | YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText()); |
96 | 98 | ||
97 | // Create YANG type object and fill the values. | 99 | // Create YANG type object and fill the values. |
98 | - YangType<?> type = new YangType(); | 100 | + YangType<?> type = getYangType(JAVA_GENERATION); |
99 | type.setNodeIdentifier(nodeIdentifier); | 101 | type.setNodeIdentifier(nodeIdentifier); |
100 | type.setDataType(yangDataTypes); | 102 | type.setDataType(yangDataTypes); |
101 | 103 | ... | ... |
... | @@ -108,7 +108,7 @@ public final class UnionListener { | ... | @@ -108,7 +108,7 @@ public final class UnionListener { |
108 | switch (tmpData.getYangConstructType()) { | 108 | switch (tmpData.getYangConstructType()) { |
109 | case LEAF_DATA: | 109 | case LEAF_DATA: |
110 | // Set the name of union same as leaf. | 110 | // Set the name of union same as leaf. |
111 | - unionNode.setName(((YangLeaf) tmpData).getLeafName() + UNION_CLASS_SUFFIX); | 111 | + unionNode.setName(((YangLeaf) tmpData).getName() + UNION_CLASS_SUFFIX); |
112 | // Pop the stack entry to obtain the parent YANG node. | 112 | // Pop the stack entry to obtain the parent YANG node. |
113 | Parsable leaf = listener.getParsedDataStack().pop(); | 113 | Parsable leaf = listener.getParsedDataStack().pop(); |
114 | // Add the union node to the parent holder of leaf. | 114 | // Add the union node to the parent holder of leaf. |
... | @@ -118,7 +118,7 @@ public final class UnionListener { | ... | @@ -118,7 +118,7 @@ public final class UnionListener { |
118 | break; | 118 | break; |
119 | case LEAF_LIST_DATA: | 119 | case LEAF_LIST_DATA: |
120 | // Set the name of union same as leaf list. | 120 | // Set the name of union same as leaf list. |
121 | - unionNode.setName(((YangLeafList) tmpData).getLeafName() + UNION_CLASS_SUFFIX); | 121 | + unionNode.setName(((YangLeafList) tmpData).getName() + UNION_CLASS_SUFFIX); |
122 | // Pop the stack entry to obtain the parent YANG node. | 122 | // Pop the stack entry to obtain the parent YANG node. |
123 | Parsable leafList = listener.getParsedDataStack().pop(); | 123 | Parsable leafList = listener.getParsedDataStack().pop(); |
124 | // Add the union node to the parent holder of leaf. | 124 | // Add the union node to the parent holder of leaf. | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedJavaFileType.java
... | @@ -44,7 +44,8 @@ public final class GeneratedJavaFileType { | ... | @@ -44,7 +44,8 @@ public final class GeneratedJavaFileType { |
44 | /** | 44 | /** |
45 | * Interface and class file. | 45 | * Interface and class file. |
46 | */ | 46 | */ |
47 | - public static final int GENERATE_INTERFACE_WITH_BUILDER = 15; | 47 | + public static final int GENERATE_INTERFACE_WITH_BUILDER = INTERFACE_MASK |
48 | + | BUILDER_INTERFACE_MASK | BUILDER_CLASS_MASK | IMPL_CLASS_MASK; | ||
48 | 49 | ||
49 | /** | 50 | /** |
50 | * Java interface corresponding to rpc. | 51 | * Java interface corresponding to rpc. |
... | @@ -54,24 +55,31 @@ public final class GeneratedJavaFileType { | ... | @@ -54,24 +55,31 @@ public final class GeneratedJavaFileType { |
54 | /** | 55 | /** |
55 | * Interface, class file and rpc. | 56 | * Interface, class file and rpc. |
56 | */ | 57 | */ |
57 | - public static final int GENERATE_MANAGER_WITH_RPC = 31; | 58 | + public static final int GENERATE_MANAGER_WITH_RPC = GENERATE_INTERFACE_WITH_BUILDER |
59 | + | GENERATE_RPC_INTERFACE; | ||
58 | 60 | ||
59 | // TODO RPC implementation to be integrated with notification. | 61 | // TODO RPC implementation to be integrated with notification. |
60 | 62 | ||
61 | /** | 63 | /** |
62 | * Java class corresponding to YANG enumeration. | 64 | * Java class corresponding to YANG enumeration. |
63 | */ | 65 | */ |
64 | - public static final int GENERATE_ENUM_CLASS = 64; | 66 | + public static final int GENERATE_ENUM_CLASS = 32; |
65 | 67 | ||
66 | /** | 68 | /** |
67 | * Java class corresponding to typedef. | 69 | * Java class corresponding to typedef. |
68 | */ | 70 | */ |
69 | - public static final int GENERATE_TYPEDEF_CLASS = 1024; | 71 | + public static final int GENERATE_TYPEDEF_CLASS = 64; |
70 | 72 | ||
71 | /** | 73 | /** |
72 | * Java class corresponding to union. | 74 | * Java class corresponding to union. |
73 | */ | 75 | */ |
74 | - public static final int GENERATE_UNION_CLASS = 2048; | 76 | + public static final int GENERATE_UNION_CLASS = 128; |
77 | + | ||
78 | + /** | ||
79 | + * Java class corresponding to typedef. | ||
80 | + */ | ||
81 | + public static final int GENERATE_TYPE_CLASS = GENERATE_TYPEDEF_CLASS | ||
82 | + | GENERATE_UNION_CLASS; | ||
75 | 83 | ||
76 | /** | 84 | /** |
77 | * Creates an instance of generate java file type. | 85 | * Creates an instance of generate java file type. | ... | ... |
... | @@ -16,16 +16,9 @@ | ... | @@ -16,16 +16,9 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.translator.tojava; | 17 | package org.onosproject.yangutils.translator.tojava; |
18 | 18 | ||
19 | -import org.onosproject.yangutils.datamodel.YangNode; | ||
20 | import org.onosproject.yangutils.datamodel.YangType; | 19 | import org.onosproject.yangutils.datamodel.YangType; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 20 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | 21 | ||
23 | -import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getIsQualifiedAccessOrAddToImportList; | ||
24 | -import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedInfoOfFromString; | ||
25 | -import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfAttribute; | ||
26 | -import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; | ||
27 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | ||
28 | - | ||
29 | /** | 22 | /** |
30 | * Represents the attribute info corresponding to class/interface generated. | 23 | * Represents the attribute info corresponding to class/interface generated. |
31 | */ | 24 | */ |
... | @@ -44,12 +37,12 @@ public final class JavaAttributeInfo { | ... | @@ -44,12 +37,12 @@ public final class JavaAttributeInfo { |
44 | /** | 37 | /** |
45 | * If the added attribute is a list of info. | 38 | * If the added attribute is a list of info. |
46 | */ | 39 | */ |
47 | - private boolean isListAttr = false; | 40 | + private boolean isListAttr; |
48 | 41 | ||
49 | /** | 42 | /** |
50 | * If the added attribute has to be accessed in a fully qualified manner. | 43 | * If the added attribute has to be accessed in a fully qualified manner. |
51 | */ | 44 | */ |
52 | - private boolean isQualifiedName = false; | 45 | + private boolean isQualifiedName; |
53 | 46 | ||
54 | /** | 47 | /** |
55 | * The class info will be used to set the attribute type and package info | 48 | * The class info will be used to set the attribute type and package info |
... | @@ -79,75 +72,6 @@ public final class JavaAttributeInfo { | ... | @@ -79,75 +72,6 @@ public final class JavaAttributeInfo { |
79 | } | 72 | } |
80 | 73 | ||
81 | /** | 74 | /** |
82 | - * Creates an attribute info object corresponding to the passed type's attribute | ||
83 | - * information and return it. | ||
84 | - * | ||
85 | - * @param curNode current data model node for which the java file is being generated | ||
86 | - * @param referredTypesAttrInfo attribute of referred type | ||
87 | - * @return JavaAttributeInfo attribute details required to add in temporary files | ||
88 | - */ | ||
89 | - public static JavaAttributeInfo getFromStringAttributeInfo(YangNode curNode, | ||
90 | - JavaAttributeInfo referredTypesAttrInfo) { | ||
91 | - | ||
92 | - JavaQualifiedTypeInfo qualifiedInfoOfFromString = getQualifiedInfoOfFromString(referredTypesAttrInfo); | ||
93 | - /* | ||
94 | - * Create a new java attribute info with qualified information of | ||
95 | - * wrapper classes. | ||
96 | - */ | ||
97 | - return getAttributeInfoForTheData(qualifiedInfoOfFromString, referredTypesAttrInfo.getAttributeName(), | ||
98 | - referredTypesAttrInfo.getAttributeType(), curNode, false); | ||
99 | - } | ||
100 | - | ||
101 | - /** | ||
102 | - * Creates an attribute info object corresponding to the passed type attribute | ||
103 | - * information and return it. | ||
104 | - * | ||
105 | - * @param curNode current data model node for which the java file is being | ||
106 | - * generated | ||
107 | - * @param attributeType leaf data type | ||
108 | - * @param attributeName leaf name | ||
109 | - * @param isListAttribute is the current added attribute needs to be a list | ||
110 | - * @return AttributeInfo attribute details required to add in temporary | ||
111 | - * files | ||
112 | - */ | ||
113 | - public static JavaAttributeInfo getAttributeInfoOfType(YangNode curNode, | ||
114 | - YangType<?> attributeType, String attributeName, | ||
115 | - boolean isListAttribute) { | ||
116 | - /* | ||
117 | - * Get the import info corresponding to the attribute for import in | ||
118 | - * generated java files or qualified access | ||
119 | - */ | ||
120 | - JavaQualifiedTypeInfo importInfo = getQualifiedTypeInfoOfAttribute(curNode, | ||
121 | - attributeType, attributeName, isListAttribute); | ||
122 | - | ||
123 | - return getAttributeInfoForTheData(importInfo, attributeName, attributeType, curNode, isListAttribute); | ||
124 | - } | ||
125 | - | ||
126 | - /** | ||
127 | - * Creates an attribute info object corresponding to the passed enumeration attribute | ||
128 | - * information and return it. | ||
129 | - * | ||
130 | - * @param curNode current data model node for which the java file is being | ||
131 | - * generated | ||
132 | - * @param attributeName attribute name | ||
133 | - * @return AttributeInfo attribute details required to add in temporary | ||
134 | - * files | ||
135 | - */ | ||
136 | - public static JavaAttributeInfo getAttributeInfoOfEnumAttribute(YangNode curNode, String attributeName) { | ||
137 | - | ||
138 | - String curNodeName = ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName(); | ||
139 | - | ||
140 | - /* | ||
141 | - * Get the import info corresponding to the attribute for import in | ||
142 | - * generated java files or qualified access | ||
143 | - */ | ||
144 | - JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, | ||
145 | - curNodeName, false); | ||
146 | - | ||
147 | - return getAttributeInfoForTheData(qualifiedTypeInfo, attributeName, null, curNode, false); | ||
148 | - } | ||
149 | - | ||
150 | - /** | ||
151 | * Returns the data type info of attribute. | 75 | * Returns the data type info of attribute. |
152 | * | 76 | * |
153 | * @return the data type info of attribute | 77 | * @return the data type info of attribute |
... | @@ -251,102 +175,25 @@ public final class JavaAttributeInfo { | ... | @@ -251,102 +175,25 @@ public final class JavaAttributeInfo { |
251 | } | 175 | } |
252 | 176 | ||
253 | /** | 177 | /** |
254 | - * Creates an attribute info object corresponding to the passed leaf | ||
255 | - * information and return it. | ||
256 | - * | ||
257 | - * @param curNode current data model node for which the java file is being | ||
258 | - * generated | ||
259 | - * @param attributeType leaf data type | ||
260 | - * @param attributeName leaf name | ||
261 | - * @param isListAttribute is the current added attribute needs to be a list | ||
262 | - * @return AttributeInfo attribute details required to add in temporary | ||
263 | - * files | ||
264 | - */ | ||
265 | - public static JavaAttributeInfo getAttributeInfoOfLeaf(YangNode curNode, | ||
266 | - YangType<?> attributeType, String attributeName, | ||
267 | - boolean isListAttribute) { | ||
268 | - | ||
269 | - /* | ||
270 | - * Get the import info corresponding to the attribute for import in | ||
271 | - * generated java files or qualified access | ||
272 | - */ | ||
273 | - JavaQualifiedTypeInfo importInfo = getQualifiedTypeInfoOfAttribute(curNode, | ||
274 | - attributeType, attributeName, isListAttribute); | ||
275 | - | ||
276 | - return getAttributeInfoForTheData(importInfo, attributeName, attributeType, curNode, isListAttribute); | ||
277 | - } | ||
278 | - | ||
279 | - /** | ||
280 | - * Creates an attribute info object corresponding to a data model node and | ||
281 | - * return it. | ||
282 | - * | ||
283 | - * @param curNode current data model node for which the java code generation | ||
284 | - * is being handled | ||
285 | - * @param parentNode parent node in which the current node is an attribute | ||
286 | - * @param isListNode is the current added attribute needs to be a list | ||
287 | - * @return AttributeInfo attribute details required to add in temporary | ||
288 | - * files | ||
289 | - */ | ||
290 | - public static JavaAttributeInfo getCurNodeAsAttributeInParent( | ||
291 | - YangNode curNode, YangNode parentNode, boolean isListNode) { | ||
292 | - | ||
293 | - String curNodeName = ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName(); | ||
294 | - | ||
295 | - /* | ||
296 | - * Get the import info corresponding to the attribute for import in | ||
297 | - * generated java files or qualified access | ||
298 | - */ | ||
299 | - JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(parentNode, | ||
300 | - curNodeName, isListNode); | ||
301 | - | ||
302 | - return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, parentNode, isListNode); | ||
303 | - } | ||
304 | - | ||
305 | - /** | ||
306 | - * Creates an attribute info object corresponding to a data model node and | ||
307 | - * return it. | ||
308 | - * | ||
309 | - * @param parentNode parent node in which the current node is an attribute | ||
310 | - * @param isListNode is the current added attribute needs to be a list | ||
311 | - * @param curNodeName is the current added attribute needs to be a list | ||
312 | - * @return AttributeInfo attribute details required to add in temporary | ||
313 | - * files | ||
314 | - */ | ||
315 | - public static JavaAttributeInfo getCurNodeAsAttributeInParent(YangNode parentNode, boolean isListNode, | ||
316 | - String curNodeName) { | ||
317 | - | ||
318 | - /* | ||
319 | - * Get the import info corresponding to the attribute for import in | ||
320 | - * generated java files or qualified access | ||
321 | - */ | ||
322 | - JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(parentNode, | ||
323 | - curNodeName, isListNode); | ||
324 | - | ||
325 | - return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, parentNode, isListNode); | ||
326 | - } | ||
327 | - | ||
328 | - | ||
329 | - /** | ||
330 | * Returns java attribute info. | 178 | * Returns java attribute info. |
331 | * | 179 | * |
332 | * @param importInfo java qualified type info | 180 | * @param importInfo java qualified type info |
333 | * @param attributeName attribute name | 181 | * @param attributeName attribute name |
334 | * @param attributeType attribute type | 182 | * @param attributeType attribute type |
335 | - * @param curNode current YANG node | 183 | + * @param isQualifiedAccess is the attribute a qualified access |
336 | * @param isListAttribute is list attribute | 184 | * @param isListAttribute is list attribute |
337 | * @return java attribute info. | 185 | * @return java attribute info. |
338 | */ | 186 | */ |
339 | - private static JavaAttributeInfo getAttributeInfoForTheData(JavaQualifiedTypeInfo importInfo, String attributeName, | 187 | + public static JavaAttributeInfo getAttributeInfoForTheData(JavaQualifiedTypeInfo importInfo, String attributeName, |
340 | - YangType<?> attributeType, YangNode curNode, | 188 | + YangType<?> attributeType, boolean isQualifiedAccess, |
341 | boolean isListAttribute) { | 189 | boolean isListAttribute) { |
342 | 190 | ||
343 | JavaAttributeInfo newAttr = new JavaAttributeInfo(); | 191 | JavaAttributeInfo newAttr = new JavaAttributeInfo(); |
344 | newAttr.setImportInfo(importInfo); | 192 | newAttr.setImportInfo(importInfo); |
345 | - newAttr.setIsQualifiedAccess(getIsQualifiedAccessOrAddToImportList(curNode, importInfo)); | 193 | + newAttr.setAttributeName(attributeName); |
346 | - newAttr.setAttributeName(getCamelCase(attributeName, null)); | ||
347 | - newAttr.setListAttr(isListAttribute); | ||
348 | - newAttr.setImportInfo(importInfo); | ||
349 | newAttr.setAttributeType(attributeType); | 194 | newAttr.setAttributeType(attributeType); |
195 | + newAttr.setIsQualifiedAccess(isQualifiedAccess); | ||
196 | + newAttr.setListAttr(isListAttribute); | ||
350 | 197 | ||
351 | return newAttr; | 198 | return newAttr; |
352 | } | 199 | } | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
... | @@ -39,7 +39,7 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -39,7 +39,7 @@ public final class JavaCodeGeneratorUtil { |
39 | private static YangNode curNode; | 39 | private static YangNode curNode; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | - * Creates a java code generator util object. | 42 | + * Creates a java code generator utility object. |
43 | */ | 43 | */ |
44 | private JavaCodeGeneratorUtil() { | 44 | private JavaCodeGeneratorUtil() { |
45 | } | 45 | } |
... | @@ -70,27 +70,28 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -70,27 +70,28 @@ public final class JavaCodeGeneratorUtil { |
70 | * @throws IOException when fails to generate java code file the current | 70 | * @throws IOException when fails to generate java code file the current |
71 | * node | 71 | * node |
72 | */ | 72 | */ |
73 | - public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin) throws IOException { | 73 | + public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin) |
74 | + throws IOException { | ||
74 | 75 | ||
75 | - YangNode curNode = rootNode; | 76 | + YangNode codeGenNode = rootNode; |
76 | TraversalType curTraversal = ROOT; | 77 | TraversalType curTraversal = ROOT; |
77 | 78 | ||
78 | - while (curNode != null) { | 79 | + while (codeGenNode != null) { |
79 | if (curTraversal != PARENT) { | 80 | if (curTraversal != PARENT) { |
80 | - setCurNode(curNode); | 81 | + setCurNode(codeGenNode); |
81 | - generateCodeEntry(curNode, yangPlugin); | 82 | + generateCodeEntry(codeGenNode, yangPlugin); |
82 | } | 83 | } |
83 | - if (curTraversal != PARENT && curNode.getChild() != null) { | 84 | + if (curTraversal != PARENT && codeGenNode.getChild() != null) { |
84 | curTraversal = CHILD; | 85 | curTraversal = CHILD; |
85 | - curNode = curNode.getChild(); | 86 | + codeGenNode = codeGenNode.getChild(); |
86 | - } else if (curNode.getNextSibling() != null) { | 87 | + } else if (codeGenNode.getNextSibling() != null) { |
87 | - generateCodeExit(curNode); | 88 | + generateCodeExit(codeGenNode); |
88 | curTraversal = SIBILING; | 89 | curTraversal = SIBILING; |
89 | - curNode = curNode.getNextSibling(); | 90 | + codeGenNode = codeGenNode.getNextSibling(); |
90 | } else { | 91 | } else { |
91 | - generateCodeExit(curNode); | 92 | + generateCodeExit(codeGenNode); |
92 | curTraversal = PARENT; | 93 | curTraversal = PARENT; |
93 | - curNode = curNode.getParent(); | 94 | + codeGenNode = codeGenNode.getParent(); |
94 | } | 95 | } |
95 | } | 96 | } |
96 | } | 97 | } |
... | @@ -98,15 +99,16 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -98,15 +99,16 @@ public final class JavaCodeGeneratorUtil { |
98 | /** | 99 | /** |
99 | * Generates the current nodes code snippet. | 100 | * Generates the current nodes code snippet. |
100 | * | 101 | * |
101 | - * @param curNode current data model node for which the code needs to be | 102 | + * @param codeGenNode current data model node for which the code needs to be |
102 | * generated | 103 | * generated |
103 | * @param yangPlugin YANG plugin config | 104 | * @param yangPlugin YANG plugin config |
104 | * @throws IOException IO operation exception | 105 | * @throws IOException IO operation exception |
105 | */ | 106 | */ |
106 | - private static void generateCodeEntry(YangNode curNode, YangPluginConfig yangPlugin) throws IOException { | 107 | + private static void generateCodeEntry(YangNode codeGenNode, YangPluginConfig yangPlugin) |
108 | + throws IOException { | ||
107 | 109 | ||
108 | - if (curNode instanceof JavaCodeGenerator) { | 110 | + if (codeGenNode instanceof JavaCodeGenerator) { |
109 | - ((JavaCodeGenerator) curNode).generateCodeEntry(yangPlugin); | 111 | + ((JavaCodeGenerator) codeGenNode).generateCodeEntry(yangPlugin); |
110 | } else { | 112 | } else { |
111 | throw new TranslatorException( | 113 | throw new TranslatorException( |
112 | "Generated data model node cannot be translated to target language code"); | 114 | "Generated data model node cannot be translated to target language code"); |
... | @@ -116,14 +118,15 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -116,14 +118,15 @@ public final class JavaCodeGeneratorUtil { |
116 | /** | 118 | /** |
117 | * Generates the current nodes code target code from the snippet. | 119 | * Generates the current nodes code target code from the snippet. |
118 | * | 120 | * |
119 | - * @param curNode current data model node for which the code needs to be | 121 | + * @param codeGenNode current data model node for which the code needs to be |
120 | * generated | 122 | * generated |
121 | * @throws IOException IO operation exception | 123 | * @throws IOException IO operation exception |
122 | */ | 124 | */ |
123 | - private static void generateCodeExit(YangNode curNode) throws IOException { | 125 | + private static void generateCodeExit(YangNode codeGenNode) |
126 | + throws IOException { | ||
124 | 127 | ||
125 | - if (curNode instanceof JavaCodeGenerator) { | 128 | + if (codeGenNode instanceof JavaCodeGenerator) { |
126 | - ((JavaCodeGenerator) curNode).generateCodeExit(); | 129 | + ((JavaCodeGenerator) codeGenNode).generateCodeExit(); |
127 | } else { | 130 | } else { |
128 | throw new TranslatorException( | 131 | throw new TranslatorException( |
129 | "Generated data model node cannot be translated to target language code"); | 132 | "Generated data model node cannot be translated to target language code"); |
... | @@ -131,31 +134,35 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -131,31 +134,35 @@ public final class JavaCodeGeneratorUtil { |
131 | } | 134 | } |
132 | 135 | ||
133 | /** | 136 | /** |
134 | - * Free other YANG nodes of data-model tree when error occurs while file generation of current node. | 137 | + * Free other YANG nodes of data-model tree when error occurs while file |
138 | + * generation of current node. | ||
139 | + * | ||
140 | + * @throws DataModelException when fails to do datamodel operations | ||
135 | */ | 141 | */ |
136 | - public static void freeRestResources() { | 142 | + private static void freeRestResources() |
143 | + throws DataModelException { | ||
137 | 144 | ||
138 | - YangNode curNode = getCurNode(); | 145 | + YangNode freedNode = getCurNode(); |
139 | - YangNode tempNode = curNode; | 146 | + YangNode tempNode = freedNode; |
140 | TraversalType curTraversal = ROOT; | 147 | TraversalType curTraversal = ROOT; |
141 | 148 | ||
142 | - while (curNode != tempNode.getParent()) { | 149 | + while (freedNode != tempNode.getParent()) { |
143 | 150 | ||
144 | - if (curTraversal != PARENT && curNode.getChild() != null) { | 151 | + if (curTraversal != PARENT && freedNode.getChild() != null) { |
145 | curTraversal = CHILD; | 152 | curTraversal = CHILD; |
146 | - curNode = curNode.getChild(); | 153 | + freedNode = freedNode.getChild(); |
147 | - } else if (curNode.getNextSibling() != null) { | 154 | + } else if (freedNode.getNextSibling() != null) { |
148 | curTraversal = SIBILING; | 155 | curTraversal = SIBILING; |
149 | - if (curNode != tempNode) { | 156 | + if (freedNode != tempNode) { |
150 | - free(curNode); | 157 | + free(freedNode); |
151 | } | 158 | } |
152 | - curNode = curNode.getNextSibling(); | 159 | + freedNode = freedNode.getNextSibling(); |
153 | } else { | 160 | } else { |
154 | curTraversal = PARENT; | 161 | curTraversal = PARENT; |
155 | - if (curNode != tempNode) { | 162 | + if (freedNode != tempNode) { |
156 | - free(curNode); | 163 | + free(freedNode); |
157 | } | 164 | } |
158 | - curNode = curNode.getParent(); | 165 | + freedNode = freedNode.getParent(); |
159 | } | 166 | } |
160 | } | 167 | } |
161 | } | 168 | } |
... | @@ -185,7 +192,8 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -185,7 +192,8 @@ public final class JavaCodeGeneratorUtil { |
185 | * @throws IOException when fails to delete java code file the current node | 192 | * @throws IOException when fails to delete java code file the current node |
186 | * @throws DataModelException when fails to do datamodel operations | 193 | * @throws DataModelException when fails to do datamodel operations |
187 | */ | 194 | */ |
188 | - public static void translatorErrorHandler(YangNode rootNode) throws IOException, DataModelException { | 195 | + public static void translatorErrorHandler(YangNode rootNode) |
196 | + throws IOException, DataModelException { | ||
189 | 197 | ||
190 | /** | 198 | /** |
191 | * Free other resources where translator has failed. | 199 | * Free other resources where translator has failed. |
... | @@ -195,24 +203,24 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -195,24 +203,24 @@ public final class JavaCodeGeneratorUtil { |
195 | /** | 203 | /** |
196 | * Start removing all open files. | 204 | * Start removing all open files. |
197 | */ | 205 | */ |
198 | - YangNode curNode = rootNode; | 206 | + YangNode tempNode = rootNode; |
199 | - setCurNode(curNode.getChild()); | 207 | + setCurNode(tempNode.getChild()); |
200 | TraversalType curTraversal = ROOT; | 208 | TraversalType curTraversal = ROOT; |
201 | 209 | ||
202 | - while (curNode != null) { | 210 | + while (tempNode != null) { |
203 | 211 | ||
204 | if (curTraversal != PARENT) { | 212 | if (curTraversal != PARENT) { |
205 | - close(curNode); | 213 | + close(tempNode); |
206 | } | 214 | } |
207 | - if (curTraversal != PARENT && curNode.getChild() != null) { | 215 | + if (curTraversal != PARENT && tempNode.getChild() != null) { |
208 | curTraversal = CHILD; | 216 | curTraversal = CHILD; |
209 | - curNode = curNode.getChild(); | 217 | + tempNode = tempNode.getChild(); |
210 | - } else if (curNode.getNextSibling() != null) { | 218 | + } else if (tempNode.getNextSibling() != null) { |
211 | curTraversal = SIBILING; | 219 | curTraversal = SIBILING; |
212 | - curNode = curNode.getNextSibling(); | 220 | + tempNode = tempNode.getNextSibling(); |
213 | } else { | 221 | } else { |
214 | curTraversal = PARENT; | 222 | curTraversal = PARENT; |
215 | - curNode = curNode.getParent(); | 223 | + tempNode = tempNode.getParent(); |
216 | } | 224 | } |
217 | } | 225 | } |
218 | 226 | ||
... | @@ -220,15 +228,17 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -220,15 +228,17 @@ public final class JavaCodeGeneratorUtil { |
220 | } | 228 | } |
221 | 229 | ||
222 | /** | 230 | /** |
223 | - * Closes all the current open file handles of node and delete all generated files. | 231 | + * Closes all the current open file handles of node and delete all generated |
232 | + * files. | ||
224 | * | 233 | * |
225 | - * @param curNode current YANG node | 234 | + * @param node current YANG node |
226 | * @throws IOException when fails to do IO operations | 235 | * @throws IOException when fails to do IO operations |
227 | */ | 236 | */ |
228 | - private static void close(YangNode curNode) throws IOException { | 237 | + private static void close(YangNode node) |
238 | + throws IOException { | ||
229 | 239 | ||
230 | - if (((HasTempJavaCodeFragmentFiles) curNode).getTempJavaCodeFragmentFiles() != null) { | 240 | + if (((TempJavaCodeFragmentFilesContainer) node).getTempJavaCodeFragmentFiles() != null) { |
231 | - ((HasTempJavaCodeFragmentFiles) curNode).getTempJavaCodeFragmentFiles().close(true); | 241 | + ((TempJavaCodeFragmentFilesContainer) node).getTempJavaCodeFragmentFiles().close(true); |
232 | } | 242 | } |
233 | } | 243 | } |
234 | } | 244 | } | ... | ... |
... | @@ -19,7 +19,7 @@ package org.onosproject.yangutils.translator.tojava; | ... | @@ -19,7 +19,7 @@ package org.onosproject.yangutils.translator.tojava; |
19 | * Represents data model nodes which are required to generate java classes, need to support | 19 | * Represents data model nodes which are required to generate java classes, need to support |
20 | * java file info. | 20 | * java file info. |
21 | */ | 21 | */ |
22 | -public interface HasJavaFileInfo { | 22 | +public interface JavaFileInfoContainer { |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * Returns the generated java file information. | 25 | * Returns the generated java file information. | ... | ... |
... | @@ -19,10 +19,6 @@ import java.util.ArrayList; | ... | @@ -19,10 +19,6 @@ import java.util.ArrayList; |
19 | import java.util.List; | 19 | import java.util.List; |
20 | import java.util.SortedSet; | 20 | import java.util.SortedSet; |
21 | import java.util.TreeSet; | 21 | import java.util.TreeSet; |
22 | -import static java.util.Collections.sort; | ||
23 | - | ||
24 | -import org.onosproject.yangutils.datamodel.YangNode; | ||
25 | -import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
26 | 22 | ||
27 | import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST; | 23 | import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST; |
28 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO_CLASS_IMPORT_CLASS; | 24 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO_CLASS_IMPORT_CLASS; |
... | @@ -42,6 +38,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | ... | @@ -42,6 +38,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
42 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
43 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
44 | 40 | ||
41 | +import static java.util.Collections.sort; | ||
42 | + | ||
45 | /** | 43 | /** |
46 | * Represents that generated Java file can contain imports. | 44 | * Represents that generated Java file can contain imports. |
47 | */ | 45 | */ |
... | @@ -112,33 +110,29 @@ public class JavaImportData { | ... | @@ -112,33 +110,29 @@ public class JavaImportData { |
112 | * denote, it is not added to import collection and needs to be accessed in | 110 | * denote, it is not added to import collection and needs to be accessed in |
113 | * a qualified manner. | 111 | * a qualified manner. |
114 | * | 112 | * |
115 | - * @param curNode current data model node | ||
116 | * @param newImportInfo class/interface info being imported | 113 | * @param newImportInfo class/interface info being imported |
117 | * @return status of new addition of class/interface to the import set | 114 | * @return status of new addition of class/interface to the import set |
118 | */ | 115 | */ |
119 | - public boolean addImportInfo(YangNode curNode, JavaQualifiedTypeInfo newImportInfo) { | 116 | + public boolean addImportInfo(JavaQualifiedTypeInfo newImportInfo) { |
120 | 117 | ||
121 | - if (!(curNode instanceof HasJavaImportData)) { | 118 | + for (JavaQualifiedTypeInfo curImportInfo : getImportSet()) { |
122 | - throw new TranslatorException("missing import info in data model node"); | ||
123 | - } | ||
124 | - for (JavaQualifiedTypeInfo curImportInfo : ((HasJavaImportData) curNode).getJavaImportData().getImportSet()) { | ||
125 | if (curImportInfo.getClassInfo() | 119 | if (curImportInfo.getClassInfo() |
126 | .contentEquals(newImportInfo.getClassInfo())) { | 120 | .contentEquals(newImportInfo.getClassInfo())) { |
127 | return curImportInfo.getPkgInfo() | 121 | return curImportInfo.getPkgInfo() |
128 | .contentEquals(newImportInfo.getPkgInfo()); | 122 | .contentEquals(newImportInfo.getPkgInfo()); |
129 | } | 123 | } |
130 | } | 124 | } |
131 | - ((HasJavaImportData) curNode).getJavaImportData().getImportSet().add(newImportInfo); | 125 | + |
126 | + getImportSet().add(newImportInfo); | ||
132 | return true; | 127 | return true; |
133 | } | 128 | } |
134 | 129 | ||
135 | /** | 130 | /** |
136 | * Returns import for class. | 131 | * Returns import for class. |
137 | * | 132 | * |
138 | - * @param attr java attribute info | ||
139 | * @return imports for class | 133 | * @return imports for class |
140 | */ | 134 | */ |
141 | - public List<String> getImports(JavaAttributeInfo attr) { | 135 | + public List<String> getImports() { |
142 | 136 | ||
143 | String importString; | 137 | String importString; |
144 | List<String> imports = new ArrayList<>(); | 138 | List<String> imports = new ArrayList<>(); |
... | @@ -153,7 +147,7 @@ public class JavaImportData { | ... | @@ -153,7 +147,7 @@ public class JavaImportData { |
153 | } | 147 | } |
154 | } | 148 | } |
155 | 149 | ||
156 | - if (attr.isListAttr()) { | 150 | + if (isListToImport) { |
157 | imports.add(getImportForList()); | 151 | imports.add(getImportForList()); |
158 | } | 152 | } |
159 | 153 | ||
... | @@ -162,29 +156,6 @@ public class JavaImportData { | ... | @@ -162,29 +156,6 @@ public class JavaImportData { |
162 | } | 156 | } |
163 | 157 | ||
164 | /** | 158 | /** |
165 | - * Returns import for class. | ||
166 | - * | ||
167 | - * @return imports for class | ||
168 | - */ | ||
169 | - public List<String> getImports() { | ||
170 | - String importString; | ||
171 | - List<String> imports = new ArrayList<>(); | ||
172 | - | ||
173 | - for (JavaQualifiedTypeInfo importInfo : getImportSet()) { | ||
174 | - if (!importInfo.getPkgInfo().equals(EMPTY_STRING) && importInfo.getClassInfo() != null | ||
175 | - && !importInfo.getPkgInfo().equals(JAVA_LANG)) { | ||
176 | - importString = IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN | ||
177 | - + NEW_LINE; | ||
178 | - | ||
179 | - imports.add(importString); | ||
180 | - } | ||
181 | - } | ||
182 | - | ||
183 | - sort(imports); | ||
184 | - return imports; | ||
185 | - } | ||
186 | - | ||
187 | - /** | ||
188 | * Returns import for hash and equals method. | 159 | * Returns import for hash and equals method. |
189 | * | 160 | * |
190 | * @return import for hash and equals method | 161 | * @return import for hash and equals method | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava; |
18 | /** | 18 | /** |
19 | * Represents the information of the java import data. | 19 | * Represents the information of the java import data. |
20 | */ | 20 | */ |
21 | -public interface HasJavaImportData { | 21 | +public interface JavaImportDataContainer { |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Returns the data of java imports to be included in generated file. | 24 | * Returns the data of java imports to be included in generated file. | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
... | @@ -17,10 +17,12 @@ | ... | @@ -17,10 +17,12 @@ |
17 | package org.onosproject.yangutils.translator.tojava; | 17 | package org.onosproject.yangutils.translator.tojava; |
18 | 18 | ||
19 | import java.util.Objects; | 19 | import java.util.Objects; |
20 | + | ||
20 | import org.onosproject.yangutils.datamodel.YangNode; | 21 | import org.onosproject.yangutils.datamodel.YangNode; |
21 | -import org.onosproject.yangutils.datamodel.YangType; | ||
22 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
23 | +import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; | ||
23 | import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType; | 24 | import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType; |
25 | + | ||
24 | import com.google.common.base.MoreObjects; | 26 | import com.google.common.base.MoreObjects; |
25 | 27 | ||
26 | import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass; | 28 | import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass; |
... | @@ -29,8 +31,8 @@ import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDa | ... | @@ -29,8 +31,8 @@ import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDa |
29 | /** | 31 | /** |
30 | * Represents the information about individual imports in the generated file. | 32 | * Represents the information about individual imports in the generated file. |
31 | */ | 33 | */ |
32 | -public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> { | 34 | +public class JavaQualifiedTypeInfo |
33 | - | 35 | + implements Comparable<JavaQualifiedTypeInfo> { |
34 | /** | 36 | /** |
35 | * Package location where the imported class/interface is defined. | 37 | * Package location where the imported class/interface is defined. |
36 | */ | 38 | */ |
... | @@ -84,40 +86,31 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> | ... | @@ -84,40 +86,31 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> |
84 | } | 86 | } |
85 | 87 | ||
86 | /** | 88 | /** |
87 | - * Returns the import info for an attribute, which needs to be used for code | 89 | + * Updates the leaf's java information. |
88 | - * generation for import or for qualified access. | ||
89 | * | 90 | * |
90 | - * @param curNode current data model node for which the java file is being | 91 | + * @param leaf leaf whose jave information is being updated |
91 | - * generated | ||
92 | - * @param attrType type of attribute being added, it will be null, when the | ||
93 | - * child class is added as an attribute | ||
94 | - * @param attributeName name of the attribute being added, it will used in | ||
95 | - * import info for child class | ||
96 | - * @param isListAttr is the added attribute going to be used as a list | ||
97 | - * @return return the import info for this attribute | ||
98 | */ | 92 | */ |
99 | - public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfAttribute(YangNode curNode, | 93 | + public static void updateLeavesJavaQualifiedInfo(JavaLeafInfoContainer leaf) { |
100 | - YangType<?> attrType, String attributeName, | ||
101 | - boolean isListAttr) { | ||
102 | 94 | ||
103 | - JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo(); | 95 | + JavaQualifiedTypeInfo importInfo = leaf.getJavaQualifiedInfo(); |
104 | 96 | ||
105 | - if (attrType == null) { | 97 | + if (leaf.getDataType() == null) { |
106 | - throw new TranslatorException("missing data type of leaf " + attributeName); | 98 | + throw new TranslatorException("missing data type of leaf " + leaf.getName()); |
107 | } | 99 | } |
108 | 100 | ||
109 | /* | 101 | /* |
110 | * Current leaves holder is adding a leaf info as a attribute to the | 102 | * Current leaves holder is adding a leaf info as a attribute to the |
111 | * current class. | 103 | * current class. |
112 | */ | 104 | */ |
113 | - String className = getJavaImportClass(attrType, isListAttr); | 105 | + String className = AttributesJavaDataType.getJavaImportClass(leaf.getDataType(), leaf.isLeafList()); |
114 | if (className != null) { | 106 | if (className != null) { |
115 | /* | 107 | /* |
116 | * Corresponding to the attribute type a class needs to be imported, | 108 | * Corresponding to the attribute type a class needs to be imported, |
117 | * since it can be a derived type or a usage of wrapper classes. | 109 | * since it can be a derived type or a usage of wrapper classes. |
118 | */ | 110 | */ |
119 | importInfo.setClassInfo(className); | 111 | importInfo.setClassInfo(className); |
120 | - String classPkg = getJavaImportPackage(attrType, isListAttr, className); | 112 | + String classPkg = AttributesJavaDataType.getJavaImportPackage(leaf.getDataType(), |
113 | + leaf.isLeafList(), className); | ||
121 | if (classPkg == null) { | 114 | if (classPkg == null) { |
122 | throw new TranslatorException("import package cannot be null when the class is used"); | 115 | throw new TranslatorException("import package cannot be null when the class is used"); |
123 | } | 116 | } |
... | @@ -127,13 +120,12 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> | ... | @@ -127,13 +120,12 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> |
127 | * The attribute does not need a class to be imported, for example | 120 | * The attribute does not need a class to be imported, for example |
128 | * built in java types. | 121 | * built in java types. |
129 | */ | 122 | */ |
130 | - String dataTypeName = AttributesJavaDataType.getJavaDataType(attrType); | 123 | + String dataTypeName = AttributesJavaDataType.getJavaDataType(leaf.getDataType()); |
131 | if (dataTypeName == null) { | 124 | if (dataTypeName == null) { |
132 | throw new TranslatorException("not supported data type"); | 125 | throw new TranslatorException("not supported data type"); |
133 | } | 126 | } |
134 | importInfo.setClassInfo(dataTypeName); | 127 | importInfo.setClassInfo(dataTypeName); |
135 | } | 128 | } |
136 | - return importInfo; | ||
137 | } | 129 | } |
138 | 130 | ||
139 | /** | 131 | /** |
... | @@ -144,15 +136,14 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> | ... | @@ -144,15 +136,14 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> |
144 | * generated | 136 | * generated |
145 | * @param attributeName name of the attribute being added, it will used in | 137 | * @param attributeName name of the attribute being added, it will used in |
146 | * import info for child class | 138 | * import info for child class |
147 | - * @param isListAttr is the added attribute going to be used as a list | ||
148 | * @return return the import info for this attribute | 139 | * @return return the import info for this attribute |
149 | */ | 140 | */ |
150 | public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfCurNode(YangNode curNode, | 141 | public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfCurNode(YangNode curNode, |
151 | - String attributeName, boolean isListAttr) { | 142 | + String attributeName) { |
152 | 143 | ||
153 | JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo(); | 144 | JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo(); |
154 | 145 | ||
155 | - if (!(curNode instanceof HasJavaFileInfo)) { | 146 | + if (!(curNode instanceof JavaFileInfoContainer)) { |
156 | throw new TranslatorException("missing java file information to get the package details " | 147 | throw new TranslatorException("missing java file information to get the package details " |
157 | + "of attribute corresponding to child node"); | 148 | + "of attribute corresponding to child node"); |
158 | } | 149 | } |
... | @@ -162,8 +153,8 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> | ... | @@ -162,8 +153,8 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> |
162 | * classes package with current classes name. | 153 | * classes package with current classes name. |
163 | */ | 154 | */ |
164 | importInfo.setClassInfo(attributeName); | 155 | importInfo.setClassInfo(attributeName); |
165 | - importInfo.setPkgInfo((((HasJavaFileInfo) curNode).getJavaFileInfo().getPackage() + "." | 156 | + importInfo.setPkgInfo((((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackage() + "." |
166 | - + ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName()).toLowerCase()); | 157 | + + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()).toLowerCase()); |
167 | 158 | ||
168 | return importInfo; | 159 | return importInfo; |
169 | } | 160 | } |
... | @@ -187,82 +178,6 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> | ... | @@ -187,82 +178,6 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> |
187 | return qualifiedInfoOfFromString; | 178 | return qualifiedInfoOfFromString; |
188 | } | 179 | } |
189 | 180 | ||
190 | - /** | ||
191 | - * Returns if the attribute needs to be accessed in a qualified manner or not, | ||
192 | - * if it needs to be imported, then the same needs to be done. | ||
193 | - * | ||
194 | - * @param curNode current cache of the data model node for which java file | ||
195 | - * is bing generated | ||
196 | - * @param importInfo import info for the current attribute being added | ||
197 | - * @return status of the qualified access to the attribute | ||
198 | - */ | ||
199 | - public static boolean getIsQualifiedAccessOrAddToImportList(YangNode curNode, | ||
200 | - JavaQualifiedTypeInfo importInfo) { | ||
201 | - | ||
202 | - boolean isImportPkgEqualCurNodePkg; | ||
203 | - if (!(curNode instanceof HasJavaFileInfo)) { | ||
204 | - throw new TranslatorException("missing java file info for getting the qualified access"); | ||
205 | - } | ||
206 | - if (importInfo.getClassInfo().contentEquals( | ||
207 | - ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName())) { | ||
208 | - /* | ||
209 | - * if the current class name is same as the attribute class name, | ||
210 | - * then the attribute must be accessed in a qualified manner. | ||
211 | - */ | ||
212 | - return true; | ||
213 | - } else if (importInfo.getPkgInfo() != null) { | ||
214 | - /* | ||
215 | - * If the attribute type is having the package info, it is contender | ||
216 | - * for import list and also need to check if it needs to be a | ||
217 | - * qualified access. | ||
218 | - */ | ||
219 | - isImportPkgEqualCurNodePkg = isImportPkgEqualCurNodePkg(curNode, importInfo); | ||
220 | - if (!isImportPkgEqualCurNodePkg) { | ||
221 | - /* | ||
222 | - * If the package of the attribute added is not same as the | ||
223 | - * current class package, then it must either be imported for | ||
224 | - * access or it must be a qualified access. | ||
225 | - */ | ||
226 | - if (!(curNode instanceof HasJavaImportData)) { | ||
227 | - /* | ||
228 | - * If the current data model node is not supposed to import | ||
229 | - * data, then this is a usage issue and needs to be fixed. | ||
230 | - */ | ||
231 | - throw new TranslatorException("Current node needs to support Imports"); | ||
232 | - } | ||
233 | - | ||
234 | - boolean isImportAdded = ((HasJavaImportData) curNode).getJavaImportData() | ||
235 | - .addImportInfo(curNode, importInfo); | ||
236 | - if (!isImportAdded) { | ||
237 | - /* | ||
238 | - * If the attribute type info is not imported, then it must | ||
239 | - * be a qualified access. | ||
240 | - */ | ||
241 | - return true; | ||
242 | - } | ||
243 | - } | ||
244 | - } | ||
245 | - return false; | ||
246 | - } | ||
247 | - | ||
248 | - /** | ||
249 | - * Checks if the import info is same as the package of the current generated | ||
250 | - * java file. | ||
251 | - * | ||
252 | - * @param curNode Java identifier of the current data model node | ||
253 | - * @param importInfo import info for an attribute | ||
254 | - * @return true if the import info is same as the current nodes package | ||
255 | - * false otherwise | ||
256 | - */ | ||
257 | - public static boolean isImportPkgEqualCurNodePkg( | ||
258 | - YangNode curNode, JavaQualifiedTypeInfo importInfo) { | ||
259 | - | ||
260 | - if (!(curNode instanceof HasJavaFileInfo)) { | ||
261 | - throw new TranslatorException("missing java file info for the data model node"); | ||
262 | - } | ||
263 | - return ((HasJavaFileInfo) curNode).getJavaFileInfo().getPackage() | ||
264 | - .contentEquals(importInfo.getPkgInfo()); | ||
265 | - } | ||
266 | 181 | ||
267 | @Override | 182 | @Override |
268 | public int hashCode() { | 183 | public int hashCode() { | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava; |
18 | /** | 18 | /** |
19 | * Maintain the java qualified access details for an attribute or a class. | 19 | * Maintain the java qualified access details for an attribute or a class. |
20 | */ | 20 | */ |
21 | -public interface HasJavaQualifiedTypeInfo { | 21 | +public interface JavaQualifiedTypeInfoContainer { |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Obtain the java qualified details. | 24 | * Obtain the java qualified details. | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.translator.tojava; | ||
18 | + | ||
19 | +import java.io.IOException; | ||
20 | + | ||
21 | +/** | ||
22 | + * Represents implementation of java bean code fragments temporary implementations. | ||
23 | + */ | ||
24 | +public class TempJavaBeanFragmentFiles | ||
25 | + extends TempJavaFragmentFiles { | ||
26 | + | ||
27 | + /** | ||
28 | + * Creates an instance of temporary java code fragment. | ||
29 | + * | ||
30 | + * @param javaFileInfo generated java file info | ||
31 | + * @throws IOException when fails to create new file handle | ||
32 | + */ | ||
33 | + public TempJavaBeanFragmentFiles(JavaFileInfo javaFileInfo) | ||
34 | + throws IOException { | ||
35 | + super(javaFileInfo); | ||
36 | + } | ||
37 | +} |
This diff is collapsed. Click to expand it.
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava; |
18 | /** | 18 | /** |
19 | * Represents Has temporary file handle. | 19 | * Represents Has temporary file handle. |
20 | */ | 20 | */ |
21 | -public interface HasTempJavaCodeFragmentFiles { | 21 | +public interface TempJavaCodeFragmentFilesContainer { |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Returns the temporary file handle. | 24 | * Returns the temporary file handle. | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.translator.tojava; | ||
17 | + | ||
18 | +import java.io.IOException; | ||
19 | + | ||
20 | +/** | ||
21 | + * Represents implementation of java code fragments temporary implementations. | ||
22 | + */ | ||
23 | +public class TempJavaEnumerationFragmentFiles | ||
24 | + extends TempJavaFragmentFiles { | ||
25 | + | ||
26 | + /** | ||
27 | + * Creates an instance of temporary java code fragment. | ||
28 | + * | ||
29 | + * @param javaFileInfo generated java file info | ||
30 | + * @throws IOException when fails to create new file handle | ||
31 | + */ | ||
32 | + public TempJavaEnumerationFragmentFiles(JavaFileInfo javaFileInfo) | ||
33 | + throws IOException { | ||
34 | + super(javaFileInfo); | ||
35 | + } | ||
36 | +} |
utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
0 → 100644
This diff is collapsed. Click to expand it.
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.translator.tojava; | ||
18 | + | ||
19 | +import java.io.IOException; | ||
20 | + | ||
21 | +/** | ||
22 | + * Represents implementation of java service code fragments temporary implementations. | ||
23 | + */ | ||
24 | +public class TempJavaServiceFragmentFiles | ||
25 | + extends TempJavaFragmentFiles { | ||
26 | + | ||
27 | + /** | ||
28 | + * Creates an instance of temporary java code fragment. | ||
29 | + * | ||
30 | + * @param javaFileInfo generated file information | ||
31 | + * @throws IOException when fails to create new file handle | ||
32 | + */ | ||
33 | + public TempJavaServiceFragmentFiles(JavaFileInfo javaFileInfo) | ||
34 | + throws IOException { | ||
35 | + super(javaFileInfo); | ||
36 | + } | ||
37 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.translator.tojava; | ||
18 | + | ||
19 | +import java.io.IOException; | ||
20 | + | ||
21 | +/** | ||
22 | + * Represents implementation of java data type code fragments temporary implementations. | ||
23 | + */ | ||
24 | +public class TempJavaTypeFragmentFiles | ||
25 | + extends TempJavaFragmentFiles { | ||
26 | + | ||
27 | + /** | ||
28 | + * Creates an instance of temporary java code fragment. | ||
29 | + * | ||
30 | + * @param javaFileInfo generated java file info | ||
31 | + * @throws IOException when fails to create new file handle | ||
32 | + */ | ||
33 | + public TempJavaTypeFragmentFiles(JavaFileInfo javaFileInfo) | ||
34 | + throws IOException { | ||
35 | + super(javaFileInfo); | ||
36 | + } | ||
37 | + | ||
38 | +} |
... | @@ -16,9 +16,8 @@ | ... | @@ -16,9 +16,8 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.translator.tojava.javamodel; | 17 | package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | 18 | ||
19 | -import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo; | 19 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
20 | -import org.onosproject.yangutils.translator.tojava.HasJavaImportData; | 20 | +import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
21 | -import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles; | ||
22 | 21 | ||
23 | /** | 22 | /** |
24 | * Represents YANG java info containing interface for java code generator, java | 23 | * Represents YANG java info containing interface for java code generator, java |
... | @@ -26,5 +25,6 @@ import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles; | ... | @@ -26,5 +25,6 @@ import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles; |
26 | * interface serves as a generic interface and help to unify the generate code | 25 | * interface serves as a generic interface and help to unify the generate code |
27 | * entry function. | 26 | * entry function. |
28 | */ | 27 | */ |
29 | -public interface JavaCodeGeneratorInfo extends HasJavaFileInfo, HasTempJavaCodeFragmentFiles, HasJavaImportData { | 28 | +public interface JavaCodeGeneratorInfo |
29 | + extends JavaFileInfoContainer, TempJavaCodeFragmentFilesContainer { | ||
30 | } | 30 | } | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.translator.tojava.javamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.YangType; | ||
19 | +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer; | ||
20 | +import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | ||
21 | + | ||
22 | + | ||
23 | +/** | ||
24 | + * Represent java based identification of the YANG leaves. | ||
25 | + */ | ||
26 | +public interface JavaLeafInfoContainer | ||
27 | + extends JavaQualifiedTypeInfoContainer { | ||
28 | + /** | ||
29 | + * Retreives the data type of the leaf. | ||
30 | + * | ||
31 | + * @return data type of the leaf | ||
32 | + */ | ||
33 | + YangType<?> getDataType(); | ||
34 | + | ||
35 | + /** | ||
36 | + * Retreives the name of the leaf. | ||
37 | + * | ||
38 | + * @return name of the leaf | ||
39 | + */ | ||
40 | + String getName(); | ||
41 | + | ||
42 | + /** | ||
43 | + * Retreives the java name of the leaf. | ||
44 | + * | ||
45 | + * @param conflictResolveConfig user config to resolve conflicts | ||
46 | + * @return name of the leaf | ||
47 | + */ | ||
48 | + String getJavaName(YangToJavaNamingConflictUtil conflictResolveConfig); | ||
49 | + | ||
50 | + | ||
51 | + /** | ||
52 | + * Identifies if object is a leaf-list. | ||
53 | + * | ||
54 | + * @return true if leaf-list false otherwise | ||
55 | + */ | ||
56 | + boolean isLeafList(); | ||
57 | + | ||
58 | + /** | ||
59 | + * updates the qualified info. | ||
60 | + */ | ||
61 | + void updateJavaQualifiedInfo(); | ||
62 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.translator.tojava.javamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer; | ||
19 | + | ||
20 | + | ||
21 | +/** | ||
22 | + * Represent java based identification of the YANG leaves. | ||
23 | + */ | ||
24 | +public interface JavaQualifiedTypeResolver | ||
25 | + extends JavaQualifiedTypeInfoContainer { | ||
26 | + | ||
27 | + /** | ||
28 | + * updates the qualified access details of the type. | ||
29 | + */ | ||
30 | + void updateJavaQualifiedInfo(); | ||
31 | +} |
... | @@ -21,17 +21,18 @@ import org.onosproject.yangutils.datamodel.YangAugment; | ... | @@ -21,17 +21,18 @@ import org.onosproject.yangutils.datamodel.YangAugment; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
27 | 26 | ||
28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
29 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | 28 | +import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode; |
30 | 29 | ||
31 | /** | 30 | /** |
32 | * Represents augment information extended to support java code generation. | 31 | * Represents augment information extended to support java code generation. |
33 | */ | 32 | */ |
34 | -public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 33 | +public class YangJavaAugment |
34 | + extends YangAugment | ||
35 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
35 | 36 | ||
36 | /** | 37 | /** |
37 | * Contains the information of the java file being generated. | 38 | * Contains the information of the java file being generated. |
... | @@ -39,12 +40,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf | ... | @@ -39,12 +40,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf |
39 | private JavaFileInfo javaFileInfo; | 40 | private JavaFileInfo javaFileInfo; |
40 | 41 | ||
41 | /** | 42 | /** |
42 | - * Contains information of the imports to be inserted in the java file | ||
43 | - * generated. | ||
44 | - */ | ||
45 | - private JavaImportData javaImportData; | ||
46 | - | ||
47 | - /** | ||
48 | * File handle to maintain temporary java code fragments as per the code | 43 | * File handle to maintain temporary java code fragments as per the code |
49 | * snippet types. | 44 | * snippet types. |
50 | */ | 45 | */ |
... | @@ -56,7 +51,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf | ... | @@ -56,7 +51,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf |
56 | public YangJavaAugment() { | 51 | public YangJavaAugment() { |
57 | super(); | 52 | super(); |
58 | setJavaFileInfo(new JavaFileInfo()); | 53 | setJavaFileInfo(new JavaFileInfo()); |
59 | - setJavaImportData(new JavaImportData()); | ||
60 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 54 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
61 | } | 55 | } |
62 | 56 | ||
... | @@ -85,27 +79,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf | ... | @@ -85,27 +79,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf |
85 | } | 79 | } |
86 | 80 | ||
87 | /** | 81 | /** |
88 | - * Returns the data of java imports to be included in generated file. | ||
89 | - * | ||
90 | - * @return data of java imports to be included in generated file | ||
91 | - */ | ||
92 | - @Override | ||
93 | - public JavaImportData getJavaImportData() { | ||
94 | - return javaImportData; | ||
95 | - } | ||
96 | - | ||
97 | - /** | ||
98 | - * Sets the data of java imports to be included in generated file. | ||
99 | - * | ||
100 | - * @param javaImportData data of java imports to be included in generated | ||
101 | - * file | ||
102 | - */ | ||
103 | - @Override | ||
104 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
105 | - this.javaImportData = javaImportData; | ||
106 | - } | ||
107 | - | ||
108 | - /** | ||
109 | * Returns the temporary file handle. | 82 | * Returns the temporary file handle. |
110 | * | 83 | * |
111 | * @return temporary file handle | 84 | * @return temporary file handle |
... | @@ -133,8 +106,9 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf | ... | @@ -133,8 +106,9 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf |
133 | * @throws IOException IO operation fail | 106 | * @throws IOException IO operation fail |
134 | */ | 107 | */ |
135 | @Override | 108 | @Override |
136 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 109 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
137 | - generateCodeOfNode(this, yangPlugin, false); | 110 | + throws IOException { |
111 | + generateCodeOfAugmentableNode(this, yangPlugin); | ||
138 | } | 112 | } |
139 | 113 | ||
140 | /** | 114 | /** |
... | @@ -143,7 +117,8 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf | ... | @@ -143,7 +117,8 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf |
143 | * @throws IOException when failed to do IO operations | 117 | * @throws IOException when failed to do IO operations |
144 | */ | 118 | */ |
145 | @Override | 119 | @Override |
146 | - public void generateCodeExit() throws IOException { | 120 | + public void generateCodeExit() |
121 | + throws IOException { | ||
147 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | 122 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); |
148 | } | 123 | } |
149 | } | 124 | } | ... | ... |
... | @@ -16,21 +16,23 @@ | ... | @@ -16,21 +16,23 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangCase; | 20 | import org.onosproject.yangutils.datamodel.YangCase; |
20 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
22 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
23 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
26 | 26 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | 28 | +import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode; |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Represents case information extended to support java code generation. | 31 | * Represents case information extended to support java code generation. |
32 | */ | 32 | */ |
33 | -public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 33 | +public class YangJavaCase |
34 | + extends YangCase | ||
35 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
34 | 36 | ||
35 | /** | 37 | /** |
36 | * Contains the information of the java file being generated. | 38 | * Contains the information of the java file being generated. |
... | @@ -38,12 +40,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav | ... | @@ -38,12 +40,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav |
38 | private JavaFileInfo javaFileInfo; | 40 | private JavaFileInfo javaFileInfo; |
39 | 41 | ||
40 | /** | 42 | /** |
41 | - * Contains information of the imports to be inserted in the java file | ||
42 | - * generated. | ||
43 | - */ | ||
44 | - private JavaImportData javaImportData; | ||
45 | - | ||
46 | - /** | ||
47 | * File handle to maintain temporary java code fragments as per the code | 43 | * File handle to maintain temporary java code fragments as per the code |
48 | * snippet types. | 44 | * snippet types. |
49 | */ | 45 | */ |
... | @@ -55,7 +51,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav | ... | @@ -55,7 +51,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav |
55 | public YangJavaCase() { | 51 | public YangJavaCase() { |
56 | super(); | 52 | super(); |
57 | setJavaFileInfo(new JavaFileInfo()); | 53 | setJavaFileInfo(new JavaFileInfo()); |
58 | - setJavaImportData(new JavaImportData()); | ||
59 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 54 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
60 | } | 55 | } |
61 | 56 | ||
... | @@ -83,27 +78,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav | ... | @@ -83,27 +78,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav |
83 | } | 78 | } |
84 | 79 | ||
85 | /** | 80 | /** |
86 | - * Returns the data of java imports to be included in generated file. | ||
87 | - * | ||
88 | - * @return data of java imports to be included in generated file | ||
89 | - */ | ||
90 | - @Override | ||
91 | - public JavaImportData getJavaImportData() { | ||
92 | - return javaImportData; | ||
93 | - } | ||
94 | - | ||
95 | - /** | ||
96 | - * Sets the data of java imports to be included in generated file. | ||
97 | - * | ||
98 | - * @param javaImportData data of java imports to be included in generated | ||
99 | - * file | ||
100 | - */ | ||
101 | - @Override | ||
102 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
103 | - this.javaImportData = javaImportData; | ||
104 | - } | ||
105 | - | ||
106 | - /** | ||
107 | * Returns the temporary file handle. | 81 | * Returns the temporary file handle. |
108 | * | 82 | * |
109 | * @return temporary file handle | 83 | * @return temporary file handle |
... | @@ -131,15 +105,17 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav | ... | @@ -131,15 +105,17 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav |
131 | * @throws IOException IO operation fail | 105 | * @throws IOException IO operation fail |
132 | */ | 106 | */ |
133 | @Override | 107 | @Override |
134 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 108 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
135 | - generateCodeOfNode(this, yangPlugin, false); | 109 | + throws IOException { |
110 | + generateCodeOfAugmentableNode(this, yangPlugin); | ||
136 | } | 111 | } |
137 | 112 | ||
138 | /** | 113 | /** |
139 | * Creates a java file using the YANG case info. | 114 | * Creates a java file using the YANG case info. |
140 | */ | 115 | */ |
141 | @Override | 116 | @Override |
142 | - public void generateCodeExit() throws IOException { | 117 | + public void generateCodeExit() |
118 | + throws IOException { | ||
143 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | 119 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); |
144 | } | 120 | } |
145 | } | 121 | } | ... | ... |
... | @@ -16,21 +16,23 @@ | ... | @@ -16,21 +16,23 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangChoice; | 20 | import org.onosproject.yangutils.datamodel.YangChoice; |
20 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
22 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
23 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | +import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils; | ||
25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
26 | 27 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | ||
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Represents choice information extended to support java code generation. | 31 | * Represents choice information extended to support java code generation. |
32 | */ | 32 | */ |
33 | -public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 33 | +public class YangJavaChoice |
34 | + extends YangChoice | ||
35 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
34 | 36 | ||
35 | /** | 37 | /** |
36 | * Contains the information of the java file being generated. | 38 | * Contains the information of the java file being generated. |
... | @@ -38,12 +40,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, | ... | @@ -38,12 +40,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, |
38 | private JavaFileInfo javaFileInfo; | 40 | private JavaFileInfo javaFileInfo; |
39 | 41 | ||
40 | /** | 42 | /** |
41 | - * Contains information of the imports to be inserted in the java file | ||
42 | - * generated. | ||
43 | - */ | ||
44 | - private JavaImportData javaImportData; | ||
45 | - | ||
46 | - /** | ||
47 | * File handle to maintain temporary java code fragments as per the code | 43 | * File handle to maintain temporary java code fragments as per the code |
48 | * snippet types. | 44 | * snippet types. |
49 | */ | 45 | */ |
... | @@ -55,7 +51,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, | ... | @@ -55,7 +51,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, |
55 | public YangJavaChoice() { | 51 | public YangJavaChoice() { |
56 | super(); | 52 | super(); |
57 | setJavaFileInfo(new JavaFileInfo()); | 53 | setJavaFileInfo(new JavaFileInfo()); |
58 | - setJavaImportData(new JavaImportData()); | ||
59 | getJavaFileInfo().setGeneratedFileTypes(INTERFACE_MASK); | 54 | getJavaFileInfo().setGeneratedFileTypes(INTERFACE_MASK); |
60 | } | 55 | } |
61 | 56 | ||
... | @@ -83,27 +78,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, | ... | @@ -83,27 +78,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, |
83 | } | 78 | } |
84 | 79 | ||
85 | /** | 80 | /** |
86 | - * Returns the data of java imports to be included in generated file. | ||
87 | - * | ||
88 | - * @return data of java imports to be included in generated file | ||
89 | - */ | ||
90 | - @Override | ||
91 | - public JavaImportData getJavaImportData() { | ||
92 | - return javaImportData; | ||
93 | - } | ||
94 | - | ||
95 | - /** | ||
96 | - * Sets the data of java imports to be included in generated file. | ||
97 | - * | ||
98 | - * @param javaImportData data of java imports to be included in generated | ||
99 | - * file | ||
100 | - */ | ||
101 | - @Override | ||
102 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
103 | - this.javaImportData = javaImportData; | ||
104 | - } | ||
105 | - | ||
106 | - /** | ||
107 | * Returns the temporary file handle. | 81 | * Returns the temporary file handle. |
108 | * | 82 | * |
109 | * @return temporary file handle | 83 | * @return temporary file handle |
... | @@ -131,15 +105,17 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, | ... | @@ -131,15 +105,17 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, |
131 | * @throws IOException IO operation fail | 105 | * @throws IOException IO operation fail |
132 | */ | 106 | */ |
133 | @Override | 107 | @Override |
134 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 108 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
135 | - generateCodeOfNode(this, yangPlugin, false); | 109 | + throws IOException { |
110 | + YangJavaModelUtils.generateCodeAndUpdateInParent(this, yangPlugin, false); | ||
136 | } | 111 | } |
137 | 112 | ||
138 | /** | 113 | /** |
139 | * Creates a java file using the YANG choice info. | 114 | * Creates a java file using the YANG choice info. |
140 | */ | 115 | */ |
141 | @Override | 116 | @Override |
142 | - public void generateCodeExit() throws IOException { | 117 | + public void generateCodeExit() |
118 | + throws IOException { | ||
143 | getTempJavaCodeFragmentFiles().generateJavaFile(INTERFACE_MASK, this); | 119 | getTempJavaCodeFragmentFiles().generateJavaFile(INTERFACE_MASK, this); |
144 | } | 120 | } |
145 | } | 121 | } | ... | ... |
... | @@ -16,21 +16,23 @@ | ... | @@ -16,21 +16,23 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangContainer; | 20 | import org.onosproject.yangutils.datamodel.YangContainer; |
20 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
22 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
23 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
26 | 26 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | 28 | +import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent; |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Represents container information extended to support java code generation. | 31 | * Represents container information extended to support java code generation. |
32 | */ | 32 | */ |
33 | -public class YangJavaContainer extends YangContainer implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 33 | +public class YangJavaContainer |
34 | + extends YangContainer | ||
35 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
34 | 36 | ||
35 | /** | 37 | /** |
36 | * Contains the information of the java file being generated. | 38 | * Contains the information of the java file being generated. |
... | @@ -38,12 +40,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato | ... | @@ -38,12 +40,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato |
38 | private JavaFileInfo javaFileInfo; | 40 | private JavaFileInfo javaFileInfo; |
39 | 41 | ||
40 | /** | 42 | /** |
41 | - * Contains information of the imports to be inserted in the java file | ||
42 | - * generated. | ||
43 | - */ | ||
44 | - private JavaImportData javaImportData; | ||
45 | - | ||
46 | - /** | ||
47 | * File handle to maintain temporary java code fragments as per the code | 43 | * File handle to maintain temporary java code fragments as per the code |
48 | * snippet types. | 44 | * snippet types. |
49 | */ | 45 | */ |
... | @@ -55,7 +51,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato | ... | @@ -55,7 +51,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato |
55 | public YangJavaContainer() { | 51 | public YangJavaContainer() { |
56 | super(); | 52 | super(); |
57 | setJavaFileInfo(new JavaFileInfo()); | 53 | setJavaFileInfo(new JavaFileInfo()); |
58 | - setJavaImportData(new JavaImportData()); | ||
59 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 54 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
60 | } | 55 | } |
61 | 56 | ||
... | @@ -83,27 +78,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato | ... | @@ -83,27 +78,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato |
83 | } | 78 | } |
84 | 79 | ||
85 | /** | 80 | /** |
86 | - * Returns the data of java imports to be included in generated file. | ||
87 | - * | ||
88 | - * @return data of java imports to be included in generated file | ||
89 | - */ | ||
90 | - @Override | ||
91 | - public JavaImportData getJavaImportData() { | ||
92 | - return javaImportData; | ||
93 | - } | ||
94 | - | ||
95 | - /** | ||
96 | - * Sets the data of java imports to be included in generated file. | ||
97 | - * | ||
98 | - * @param javaImportData data of java imports to be included in generated | ||
99 | - * file | ||
100 | - */ | ||
101 | - @Override | ||
102 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
103 | - this.javaImportData = javaImportData; | ||
104 | - } | ||
105 | - | ||
106 | - /** | ||
107 | * Returns the temporary file handle. | 81 | * Returns the temporary file handle. |
108 | * | 82 | * |
109 | * @return temporary file handle | 83 | * @return temporary file handle |
... | @@ -131,8 +105,9 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato | ... | @@ -131,8 +105,9 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato |
131 | * @throws IOException IO operation fail | 105 | * @throws IOException IO operation fail |
132 | */ | 106 | */ |
133 | @Override | 107 | @Override |
134 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 108 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
135 | - generateCodeOfNode(this, yangPlugin, false); | 109 | + throws IOException { |
110 | + generateCodeAndUpdateInParent(this, yangPlugin, false); | ||
136 | } | 111 | } |
137 | 112 | ||
138 | /** | 113 | /** |
... | @@ -141,7 +116,8 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato | ... | @@ -141,7 +116,8 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato |
141 | * @throws IOException IO operation fail | 116 | * @throws IOException IO operation fail |
142 | */ | 117 | */ |
143 | @Override | 118 | @Override |
144 | - public void generateCodeExit() throws IOException { | 119 | + public void generateCodeExit() |
120 | + throws IOException { | ||
145 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | 121 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); |
146 | } | 122 | } |
147 | 123 | ... | ... |
... | @@ -17,11 +17,11 @@ | ... | @@ -17,11 +17,11 @@ |
17 | package org.onosproject.yangutils.translator.tojava.javamodel; | 17 | package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | + | ||
20 | import org.onosproject.yangutils.datamodel.YangEnumeration; | 21 | import org.onosproject.yangutils.datamodel.YangEnumeration; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
27 | 27 | ||
... | @@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti | ... | @@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti |
31 | /** | 31 | /** |
32 | * Represents YANG java enumeration information extended to support java code generation. | 32 | * Represents YANG java enumeration information extended to support java code generation. |
33 | */ | 33 | */ |
34 | -public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGenerator, JavaCodeGeneratorInfo { | 34 | +public class YangJavaEnumeration |
35 | + extends YangEnumeration | ||
36 | + implements JavaCodeGenerator, JavaCodeGeneratorInfo { | ||
35 | 37 | ||
36 | /** | 38 | /** |
37 | * Contains the information of the java file being generated. | 39 | * Contains the information of the java file being generated. |
... | @@ -39,12 +41,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene | ... | @@ -39,12 +41,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene |
39 | private JavaFileInfo javaFileInfo; | 41 | private JavaFileInfo javaFileInfo; |
40 | 42 | ||
41 | /** | 43 | /** |
42 | - * Contains information of the imports to be inserted in the java file | ||
43 | - * generated. | ||
44 | - */ | ||
45 | - private JavaImportData javaImportData; | ||
46 | - | ||
47 | - /** | ||
48 | * File handle to maintain temporary java code fragments as per the code | 44 | * File handle to maintain temporary java code fragments as per the code |
49 | * snippet types. | 45 | * snippet types. |
50 | */ | 46 | */ |
... | @@ -56,7 +52,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene | ... | @@ -56,7 +52,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene |
56 | public YangJavaEnumeration() { | 52 | public YangJavaEnumeration() { |
57 | super(); | 53 | super(); |
58 | setJavaFileInfo(new JavaFileInfo()); | 54 | setJavaFileInfo(new JavaFileInfo()); |
59 | - setJavaImportData(new JavaImportData()); | ||
60 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_ENUM_CLASS); | 55 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_ENUM_CLASS); |
61 | } | 56 | } |
62 | 57 | ||
... | @@ -86,29 +81,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene | ... | @@ -86,29 +81,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene |
86 | } | 81 | } |
87 | 82 | ||
88 | /** | 83 | /** |
89 | - * Returns the data of java imports to be included in generated file. | ||
90 | - * | ||
91 | - * @return data of java imports to be included in generated file | ||
92 | - */ | ||
93 | - @Override | ||
94 | - public JavaImportData getJavaImportData() { | ||
95 | - | ||
96 | - return javaImportData; | ||
97 | - } | ||
98 | - | ||
99 | - /** | ||
100 | - * Sets the data of java imports to be included in generated file. | ||
101 | - * | ||
102 | - * @param javaImportData data of java imports to be included in generated | ||
103 | - * file | ||
104 | - */ | ||
105 | - @Override | ||
106 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
107 | - | ||
108 | - this.javaImportData = javaImportData; | ||
109 | - } | ||
110 | - | ||
111 | - /** | ||
112 | * Returns the temporary file handle. | 84 | * Returns the temporary file handle. |
113 | * | 85 | * |
114 | * @return temporary file handle | 86 | * @return temporary file handle |
... | @@ -138,7 +110,8 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene | ... | @@ -138,7 +110,8 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene |
138 | * @throws IOException IO operations fails | 110 | * @throws IOException IO operations fails |
139 | */ | 111 | */ |
140 | @Override | 112 | @Override |
141 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 113 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
114 | + throws IOException { | ||
142 | generateCodeOfNode(this, yangPlugin); | 115 | generateCodeOfNode(this, yangPlugin); |
143 | } | 116 | } |
144 | 117 | ||
... | @@ -148,7 +121,8 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene | ... | @@ -148,7 +121,8 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene |
148 | * @throws IOException IO operation fail | 121 | * @throws IOException IO operation fail |
149 | */ | 122 | */ |
150 | @Override | 123 | @Override |
151 | - public void generateCodeExit() throws IOException { | 124 | + public void generateCodeExit() |
125 | + throws IOException { | ||
152 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ENUM_CLASS, this); | 126 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ENUM_CLASS, this); |
153 | } | 127 | } |
154 | 128 | ... | ... |
... | @@ -16,131 +16,34 @@ | ... | @@ -16,131 +16,34 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangGrouping; | 20 | import org.onosproject.yangutils.datamodel.YangGrouping; |
20 | -import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
22 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ||
23 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
24 | -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | ||
25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 22 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
26 | 23 | ||
27 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | ||
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | ||
29 | - | ||
30 | /** | 24 | /** |
31 | * Represents grouping information extended to support java code generation. | 25 | * Represents grouping information extended to support java code generation. |
32 | */ | 26 | */ |
33 | -public class YangJavaGrouping extends YangGrouping implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 27 | +public class YangJavaGrouping |
34 | - | 28 | + extends YangGrouping |
35 | - /** | 29 | + implements JavaCodeGenerator { |
36 | - * Contains the information of the java file being generated. | ||
37 | - */ | ||
38 | - private JavaFileInfo javaFileInfo; | ||
39 | - | ||
40 | - /** | ||
41 | - * Contains information of the imports to be inserted in the java file | ||
42 | - * generated. | ||
43 | - */ | ||
44 | - private JavaImportData javaImportData; | ||
45 | - | ||
46 | - /** | ||
47 | - * File handle to maintain temporary java code fragments as per the code | ||
48 | - * snippet types. | ||
49 | - */ | ||
50 | - private TempJavaCodeFragmentFiles tempFileHandle; | ||
51 | 30 | ||
52 | /** | 31 | /** |
53 | - * Creates YANG java grouping object. | 32 | + * Creates YANG Java grouping object. |
54 | */ | 33 | */ |
55 | public YangJavaGrouping() { | 34 | public YangJavaGrouping() { |
56 | super(); | 35 | super(); |
57 | - setJavaFileInfo(new JavaFileInfo()); | ||
58 | - setJavaImportData(new JavaImportData()); | ||
59 | - getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | ||
60 | - } | ||
61 | - | ||
62 | - /** | ||
63 | - * Returns the generated java file information. | ||
64 | - * | ||
65 | - * @return generated java file information | ||
66 | - */ | ||
67 | - @Override | ||
68 | - public JavaFileInfo getJavaFileInfo() { | ||
69 | - if (javaFileInfo == null) { | ||
70 | - throw new TranslatorException("Missing java info in java datamodel node"); | ||
71 | - } | ||
72 | - return javaFileInfo; | ||
73 | - } | ||
74 | - | ||
75 | - /** | ||
76 | - * Sets the java file info object. | ||
77 | - * | ||
78 | - * @param javaInfo java file info object | ||
79 | - */ | ||
80 | - @Override | ||
81 | - public void setJavaFileInfo(JavaFileInfo javaInfo) { | ||
82 | - javaFileInfo = javaInfo; | ||
83 | - } | ||
84 | - | ||
85 | - /** | ||
86 | - * Returns the data of java imports to be included in generated file. | ||
87 | - * | ||
88 | - * @return data of java imports to be included in generated file | ||
89 | - */ | ||
90 | - @Override | ||
91 | - public JavaImportData getJavaImportData() { | ||
92 | - return javaImportData; | ||
93 | } | 36 | } |
94 | 37 | ||
95 | - /** | ||
96 | - * Sets the data of java imports to be included in generated file. | ||
97 | - * | ||
98 | - * @param javaImportData data of java imports to be included in generated | ||
99 | - * file | ||
100 | - */ | ||
101 | @Override | 38 | @Override |
102 | - public void setJavaImportData(JavaImportData javaImportData) { | 39 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
103 | - this.javaImportData = javaImportData; | 40 | + throws IOException { |
41 | + /*Do nothing, the uses will copy the contents to the used location*/ | ||
104 | } | 42 | } |
105 | 43 | ||
106 | - /** | ||
107 | - * Returns the temporary file handle. | ||
108 | - * | ||
109 | - * @return temporary file handle | ||
110 | - */ | ||
111 | @Override | 44 | @Override |
112 | - public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() { | 45 | + public void generateCodeExit() |
113 | - return tempFileHandle; | 46 | + throws IOException { |
114 | - } | 47 | + /*Do nothing, the uses will copy the contents to the used location*/ |
115 | - | ||
116 | - /** | ||
117 | - * Sets temporary file handle. | ||
118 | - * | ||
119 | - * @param fileHandle temporary file handle | ||
120 | - */ | ||
121 | - @Override | ||
122 | - public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) { | ||
123 | - tempFileHandle = fileHandle; | ||
124 | - } | ||
125 | - | ||
126 | - /** | ||
127 | - * Prepare the information for java code generation corresponding to YANG | ||
128 | - * grouping info. | ||
129 | - * | ||
130 | - * @param yangPlugin YANG plugin config | ||
131 | - * @throws IOException IO operation fail | ||
132 | - */ | ||
133 | - @Override | ||
134 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | ||
135 | - generateCodeOfNode(this, yangPlugin, false); | ||
136 | - } | ||
137 | - | ||
138 | - /** | ||
139 | - * Creates a java file using the YANG grouping info. | ||
140 | - */ | ||
141 | - @Override | ||
142 | - public void generateCodeExit() { | ||
143 | - // TODO Auto-generated method stub | ||
144 | - | ||
145 | } | 48 | } |
146 | } | 49 | } | ... | ... |
... | @@ -17,11 +17,11 @@ | ... | @@ -17,11 +17,11 @@ |
17 | package org.onosproject.yangutils.translator.tojava.javamodel; | 17 | package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | + | ||
20 | import org.onosproject.yangutils.datamodel.YangInput; | 21 | import org.onosproject.yangutils.datamodel.YangInput; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
27 | 27 | ||
... | @@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti | ... | @@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti |
31 | /** | 31 | /** |
32 | * Represents input information extended to support java code generation. | 32 | * Represents input information extended to support java code generation. |
33 | */ | 33 | */ |
34 | -public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 34 | +public class YangJavaInput |
35 | + extends YangInput | ||
36 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
35 | 37 | ||
36 | /** | 38 | /** |
37 | * Contains information of the java file being generated. | 39 | * Contains information of the java file being generated. |
... | @@ -39,12 +41,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J | ... | @@ -39,12 +41,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J |
39 | private JavaFileInfo javaFileInfo; | 41 | private JavaFileInfo javaFileInfo; |
40 | 42 | ||
41 | /** | 43 | /** |
42 | - * Contains information of the imports to be inserted in the java file | ||
43 | - * generated. | ||
44 | - */ | ||
45 | - private JavaImportData javaImportData; | ||
46 | - | ||
47 | - /** | ||
48 | * File handle to maintain temporary java code fragments as per the code | 44 | * File handle to maintain temporary java code fragments as per the code |
49 | * snippet types. | 45 | * snippet types. |
50 | */ | 46 | */ |
... | @@ -56,7 +52,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J | ... | @@ -56,7 +52,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J |
56 | public YangJavaInput() { | 52 | public YangJavaInput() { |
57 | super(); | 53 | super(); |
58 | setJavaFileInfo(new JavaFileInfo()); | 54 | setJavaFileInfo(new JavaFileInfo()); |
59 | - setJavaImportData(new JavaImportData()); | ||
60 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 55 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
61 | } | 56 | } |
62 | 57 | ||
... | @@ -84,27 +79,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J | ... | @@ -84,27 +79,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J |
84 | } | 79 | } |
85 | 80 | ||
86 | /** | 81 | /** |
87 | - * Returns the data of java imports to be included in generated file. | ||
88 | - * | ||
89 | - * @return data of java imports to be included in generated file | ||
90 | - */ | ||
91 | - @Override | ||
92 | - public JavaImportData getJavaImportData() { | ||
93 | - return javaImportData; | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * Sets the data of java imports to be included in generated file. | ||
98 | - * | ||
99 | - * @param javaImportData data of java imports to be included in generated | ||
100 | - * file | ||
101 | - */ | ||
102 | - @Override | ||
103 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
104 | - this.javaImportData = javaImportData; | ||
105 | - } | ||
106 | - | ||
107 | - /** | ||
108 | * Returns the temporary file handle. | 82 | * Returns the temporary file handle. |
109 | * | 83 | * |
110 | * @return temporary file handle | 84 | * @return temporary file handle |
... | @@ -132,7 +106,8 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J | ... | @@ -132,7 +106,8 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J |
132 | * @throws IOException IO operation fail | 106 | * @throws IOException IO operation fail |
133 | */ | 107 | */ |
134 | @Override | 108 | @Override |
135 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 109 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
110 | + throws IOException { | ||
136 | generateCodeOfNode(this, yangPlugin); | 111 | generateCodeOfNode(this, yangPlugin); |
137 | } | 112 | } |
138 | 113 | ||
... | @@ -142,7 +117,8 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J | ... | @@ -142,7 +117,8 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J |
142 | * @throws IOException IO operation fail | 117 | * @throws IOException IO operation fail |
143 | */ | 118 | */ |
144 | @Override | 119 | @Override |
145 | - public void generateCodeExit() throws IOException { | 120 | + public void generateCodeExit() |
121 | + throws IOException { | ||
146 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | 122 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); |
147 | } | 123 | } |
148 | } | 124 | } | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2016 Open Networking Laboratory | 2 | + * Copyright 2016-present Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -16,19 +16,23 @@ | ... | @@ -16,19 +16,23 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.YangLeaf; | 18 | import org.onosproject.yangutils.datamodel.YangLeaf; |
19 | -import org.onosproject.yangutils.translator.tojava.HasJavaQualifiedTypeInfo; | ||
20 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
20 | +import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | ||
21 | + | ||
22 | +import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo; | ||
23 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | ||
21 | 24 | ||
22 | /** | 25 | /** |
23 | - * Maintains java information corresponding to the YANG leaf. | 26 | + * Represents java information corresponding to the YANG leaf. |
24 | */ | 27 | */ |
25 | -public class YangJavaLeaf extends YangLeaf | 28 | +public class YangJavaLeaf |
26 | - implements HasJavaQualifiedTypeInfo { | 29 | + extends YangLeaf |
30 | + implements JavaLeafInfoContainer { | ||
27 | 31 | ||
28 | private JavaQualifiedTypeInfo javaQualifiedAccess; | 32 | private JavaQualifiedTypeInfo javaQualifiedAccess; |
29 | 33 | ||
30 | /** | 34 | /** |
31 | - * Create a YANG leaf object with java qualified access details. | 35 | + * Returns a new YANG leaf object with java qualified access details. |
32 | */ | 36 | */ |
33 | public YangJavaLeaf() { | 37 | public YangJavaLeaf() { |
34 | super(); | 38 | super(); |
... | @@ -46,4 +50,17 @@ public class YangJavaLeaf extends YangLeaf | ... | @@ -46,4 +50,17 @@ public class YangJavaLeaf extends YangLeaf |
46 | 50 | ||
47 | } | 51 | } |
48 | 52 | ||
53 | + public String getJavaName(YangToJavaNamingConflictUtil conflictResolveConfig) { | ||
54 | + return getCamelCase(getName(), conflictResolveConfig); | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public boolean isLeafList() { | ||
59 | + return false; | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public void updateJavaQualifiedInfo() { | ||
64 | + updateLeavesJavaQualifiedInfo(this); | ||
65 | + } | ||
49 | } | 66 | } | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.translator.tojava.javamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.YangLeafList; | ||
19 | +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | ||
20 | +import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | ||
21 | + | ||
22 | +import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo; | ||
23 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | ||
24 | + | ||
25 | +/** | ||
26 | + * Represents java information corresponding to the YANG leaf-list. | ||
27 | + */ | ||
28 | +public class YangJavaLeafList | ||
29 | + extends YangLeafList | ||
30 | + implements JavaLeafInfoContainer { | ||
31 | + private JavaQualifiedTypeInfo javaQualifiedAccess; | ||
32 | + | ||
33 | + /** | ||
34 | + * Returns a new YANG leaf object with java qualified access details. | ||
35 | + */ | ||
36 | + public YangJavaLeafList() { | ||
37 | + super(); | ||
38 | + setJavaQualifiedInfo(new JavaQualifiedTypeInfo()); | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public String getJavaName(YangToJavaNamingConflictUtil conflictResolveConfig) { | ||
43 | + return getCamelCase(getName(), conflictResolveConfig); | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public boolean isLeafList() { | ||
48 | + return true; | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public void updateJavaQualifiedInfo() { | ||
53 | + updateLeavesJavaQualifiedInfo(this); | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public JavaQualifiedTypeInfo getJavaQualifiedInfo() { | ||
58 | + return javaQualifiedAccess; | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public void setJavaQualifiedInfo(JavaQualifiedTypeInfo typeInfo) { | ||
63 | + javaQualifiedAccess = typeInfo; | ||
64 | + } | ||
65 | +} |
... | @@ -16,21 +16,23 @@ | ... | @@ -16,21 +16,23 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangList; | 20 | import org.onosproject.yangutils.datamodel.YangList; |
20 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
22 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
23 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
26 | 26 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | 28 | +import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent; |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Represents YANG list information extended to support java code generation. | 31 | * Represents YANG list information extended to support java code generation. |
32 | */ | 32 | */ |
33 | -public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 33 | +public class YangJavaList |
34 | + extends YangList | ||
35 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
34 | 36 | ||
35 | /** | 37 | /** |
36 | * Contains the information of the java file being generated. | 38 | * Contains the information of the java file being generated. |
... | @@ -38,12 +40,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav | ... | @@ -38,12 +40,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav |
38 | private JavaFileInfo javaFileInfo; | 40 | private JavaFileInfo javaFileInfo; |
39 | 41 | ||
40 | /** | 42 | /** |
41 | - * Contains information of the imports to be inserted in the java file | ||
42 | - * generated. | ||
43 | - */ | ||
44 | - private JavaImportData javaImportData; | ||
45 | - | ||
46 | - /** | ||
47 | * File handle to maintain temporary java code fragments as per the code | 43 | * File handle to maintain temporary java code fragments as per the code |
48 | * snippet types. | 44 | * snippet types. |
49 | */ | 45 | */ |
... | @@ -55,7 +51,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav | ... | @@ -55,7 +51,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav |
55 | public YangJavaList() { | 51 | public YangJavaList() { |
56 | super(); | 52 | super(); |
57 | setJavaFileInfo(new JavaFileInfo()); | 53 | setJavaFileInfo(new JavaFileInfo()); |
58 | - setJavaImportData(new JavaImportData()); | ||
59 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 54 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
60 | } | 55 | } |
61 | 56 | ||
... | @@ -83,27 +78,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav | ... | @@ -83,27 +78,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav |
83 | } | 78 | } |
84 | 79 | ||
85 | /** | 80 | /** |
86 | - * Returns the data of java imports to be included in generated file. | ||
87 | - * | ||
88 | - * @return data of java imports to be included in generated file | ||
89 | - */ | ||
90 | - @Override | ||
91 | - public JavaImportData getJavaImportData() { | ||
92 | - return javaImportData; | ||
93 | - } | ||
94 | - | ||
95 | - /** | ||
96 | - * Sets the data of java imports to be included in generated file. | ||
97 | - * | ||
98 | - * @param javaImportData data of java imports to be included in generated | ||
99 | - * file | ||
100 | - */ | ||
101 | - @Override | ||
102 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
103 | - this.javaImportData = javaImportData; | ||
104 | - } | ||
105 | - | ||
106 | - /** | ||
107 | * Returns the temporary file handle. | 81 | * Returns the temporary file handle. |
108 | * | 82 | * |
109 | * @return temporary file handle | 83 | * @return temporary file handle |
... | @@ -131,8 +105,9 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav | ... | @@ -131,8 +105,9 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav |
131 | * @throws IOException IO operation fail | 105 | * @throws IOException IO operation fail |
132 | */ | 106 | */ |
133 | @Override | 107 | @Override |
134 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 108 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
135 | - generateCodeOfNode(this, yangPlugin, true); | 109 | + throws IOException { |
110 | + generateCodeAndUpdateInParent(this, yangPlugin, true); | ||
136 | } | 111 | } |
137 | 112 | ||
138 | /** | 113 | /** |
... | @@ -141,7 +116,8 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav | ... | @@ -141,7 +116,8 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav |
141 | * @throws IOException IO operation fail | 116 | * @throws IOException IO operation fail |
142 | */ | 117 | */ |
143 | @Override | 118 | @Override |
144 | - public void generateCodeExit() throws IOException { | 119 | + public void generateCodeExit() |
120 | + throws IOException { | ||
145 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | 121 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); |
146 | } | 122 | } |
147 | } | 123 | } | ... | ... |
... | @@ -16,22 +16,25 @@ | ... | @@ -16,22 +16,25 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangModule; | 20 | import org.onosproject.yangutils.datamodel.YangModule; |
20 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
22 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
23 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils; | 25 | import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils; |
26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | import org.onosproject.yangutils.translator.tojava.utils.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_MANAGER_WITH_RPC; | 29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_MANAGER_WITH_RPC; |
29 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 30 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
30 | 31 | ||
31 | /** | 32 | /** |
32 | * Represents module information extended to support java code generation. | 33 | * Represents module information extended to support java code generation. |
33 | */ | 34 | */ |
34 | -public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 35 | +public class YangJavaModule |
36 | + extends YangModule | ||
37 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
35 | 38 | ||
36 | /** | 39 | /** |
37 | * Contains the information of the java file being generated. | 40 | * Contains the information of the java file being generated. |
... | @@ -39,12 +42,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, | ... | @@ -39,12 +42,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, |
39 | private JavaFileInfo javaFileInfo; | 42 | private JavaFileInfo javaFileInfo; |
40 | 43 | ||
41 | /** | 44 | /** |
42 | - * Contains information of the imports to be inserted in the java file | ||
43 | - * generated. | ||
44 | - */ | ||
45 | - private JavaImportData javaImportData; | ||
46 | - | ||
47 | - /** | ||
48 | * File handle to maintain temporary java code fragments as per the code | 45 | * File handle to maintain temporary java code fragments as per the code |
49 | * snippet types. | 46 | * snippet types. |
50 | */ | 47 | */ |
... | @@ -56,7 +53,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, | ... | @@ -56,7 +53,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, |
56 | public YangJavaModule() { | 53 | public YangJavaModule() { |
57 | super(); | 54 | super(); |
58 | setJavaFileInfo(new JavaFileInfo()); | 55 | setJavaFileInfo(new JavaFileInfo()); |
59 | - setJavaImportData(new JavaImportData()); | ||
60 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_MANAGER_WITH_RPC); | 56 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_MANAGER_WITH_RPC); |
61 | } | 57 | } |
62 | 58 | ||
... | @@ -84,27 +80,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, | ... | @@ -84,27 +80,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, |
84 | } | 80 | } |
85 | 81 | ||
86 | /** | 82 | /** |
87 | - * Returns the data of java imports to be included in generated file. | ||
88 | - * | ||
89 | - * @return data of java imports to be included in generated file | ||
90 | - */ | ||
91 | - @Override | ||
92 | - public JavaImportData getJavaImportData() { | ||
93 | - return javaImportData; | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * Sets the data of java imports to be included in generated file. | ||
98 | - * | ||
99 | - * @param javaImportData data of java imports to be included in generated | ||
100 | - * file | ||
101 | - */ | ||
102 | - @Override | ||
103 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
104 | - this.javaImportData = javaImportData; | ||
105 | - } | ||
106 | - | ||
107 | - /** | ||
108 | * Returns the temporary file handle. | 83 | * Returns the temporary file handle. |
109 | * | 84 | * |
110 | * @return temporary file handle | 85 | * @return temporary file handle |
... | @@ -131,7 +106,8 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, | ... | @@ -131,7 +106,8 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, |
131 | * @throws IOException when fails to generate the source files | 106 | * @throws IOException when fails to generate the source files |
132 | */ | 107 | */ |
133 | @Override | 108 | @Override |
134 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 109 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
110 | + throws IOException { | ||
135 | String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate()); | 111 | String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate()); |
136 | YangJavaModelUtils.generateCodeOfRootNode(this, yangPlugin, modulePkg); | 112 | YangJavaModelUtils.generateCodeOfRootNode(this, yangPlugin, modulePkg); |
137 | } | 113 | } |
... | @@ -140,7 +116,8 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, | ... | @@ -140,7 +116,8 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, |
140 | * Creates a java file using the YANG module info. | 116 | * Creates a java file using the YANG module info. |
141 | */ | 117 | */ |
142 | @Override | 118 | @Override |
143 | - public void generateCodeExit() throws IOException { | 119 | + public void generateCodeExit() |
144 | - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_MANAGER_WITH_RPC, this); | 120 | + throws IOException { |
121 | + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | ||
145 | } | 122 | } |
146 | } | 123 | } | ... | ... |
... | @@ -20,28 +20,19 @@ import java.io.IOException; | ... | @@ -20,28 +20,19 @@ import java.io.IOException; |
20 | 20 | ||
21 | import org.onosproject.yangutils.datamodel.YangNotification; | 21 | import org.onosproject.yangutils.datamodel.YangNotification; |
22 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
23 | -import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo; | ||
24 | -import org.onosproject.yangutils.translator.tojava.HasJavaImportData; | ||
25 | -import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles; | ||
26 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
27 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
28 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
30 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
31 | 27 | ||
32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
33 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | ||
34 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase; | ||
35 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage; | ||
36 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | ||
37 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; | ||
38 | 29 | ||
39 | /** | 30 | /** |
40 | * Represents notification information extended to support java code generation. | 31 | * Represents notification information extended to support java code generation. |
41 | */ | 32 | */ |
42 | -public class YangJavaNotification extends YangNotification | 33 | +public class YangJavaNotification |
43 | - implements JavaCodeGenerator, HasJavaFileInfo, | 34 | + extends YangNotification |
44 | - HasJavaImportData, HasTempJavaCodeFragmentFiles { | 35 | + implements JavaCodeGenerator, JavaCodeGeneratorInfo { |
45 | 36 | ||
46 | /** | 37 | /** |
47 | * Contains information of the java file being generated. | 38 | * Contains information of the java file being generated. |
... | @@ -49,12 +40,6 @@ public class YangJavaNotification extends YangNotification | ... | @@ -49,12 +40,6 @@ public class YangJavaNotification extends YangNotification |
49 | private JavaFileInfo javaFileInfo; | 40 | private JavaFileInfo javaFileInfo; |
50 | 41 | ||
51 | /** | 42 | /** |
52 | - * Contains information of the imports to be inserted in the java file | ||
53 | - * generated. | ||
54 | - */ | ||
55 | - private JavaImportData javaImportData; | ||
56 | - | ||
57 | - /** | ||
58 | * File handle to maintain temporary java code fragments as per the code | 43 | * File handle to maintain temporary java code fragments as per the code |
59 | * snippet types. | 44 | * snippet types. |
60 | */ | 45 | */ |
... | @@ -66,7 +51,6 @@ public class YangJavaNotification extends YangNotification | ... | @@ -66,7 +51,6 @@ public class YangJavaNotification extends YangNotification |
66 | public YangJavaNotification() { | 51 | public YangJavaNotification() { |
67 | super(); | 52 | super(); |
68 | setJavaFileInfo(new JavaFileInfo()); | 53 | setJavaFileInfo(new JavaFileInfo()); |
69 | - setJavaImportData(new JavaImportData()); | ||
70 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 54 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
71 | } | 55 | } |
72 | 56 | ||
... | @@ -95,27 +79,6 @@ public class YangJavaNotification extends YangNotification | ... | @@ -95,27 +79,6 @@ public class YangJavaNotification extends YangNotification |
95 | } | 79 | } |
96 | 80 | ||
97 | /** | 81 | /** |
98 | - * Returns the data of java imports to be included in generated file. | ||
99 | - * | ||
100 | - * @return data of java imports to be included in generated file | ||
101 | - */ | ||
102 | - @Override | ||
103 | - public JavaImportData getJavaImportData() { | ||
104 | - return javaImportData; | ||
105 | - } | ||
106 | - | ||
107 | - /** | ||
108 | - * Sets the data of java imports to be included in generated file. | ||
109 | - * | ||
110 | - * @param javaImportData data of java imports to be included in generated | ||
111 | - * file | ||
112 | - */ | ||
113 | - @Override | ||
114 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
115 | - this.javaImportData = javaImportData; | ||
116 | - } | ||
117 | - | ||
118 | - /** | ||
119 | * Returns the temporary file handle. | 82 | * Returns the temporary file handle. |
120 | * | 83 | * |
121 | * @return temporary file handle | 84 | * @return temporary file handle |
... | @@ -143,25 +106,10 @@ public class YangJavaNotification extends YangNotification | ... | @@ -143,25 +106,10 @@ public class YangJavaNotification extends YangNotification |
143 | * @throws IOException IO operation fail | 106 | * @throws IOException IO operation fail |
144 | */ | 107 | */ |
145 | @Override | 108 | @Override |
146 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 109 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
147 | - | 110 | + throws IOException { |
148 | - getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName(), yangPlugin.getConflictResolver()))); | ||
149 | - getJavaFileInfo().setPackage(getCurNodePackage(this)); | ||
150 | - getJavaFileInfo().setPackageFilePath( | ||
151 | - getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage())); | ||
152 | - getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getCodeGenDir()); | ||
153 | - | ||
154 | - String absolutePath = getAbsolutePackagePath( | ||
155 | - getJavaFileInfo().getBaseCodeGenPath(), | ||
156 | - getJavaFileInfo().getPackageFilePath()); | ||
157 | - | ||
158 | - setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles( | ||
159 | - getJavaFileInfo().getGeneratedFileTypes(), absolutePath, | ||
160 | - getJavaFileInfo().getJavaName())); | ||
161 | - | ||
162 | - getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this); | ||
163 | 111 | ||
164 | - getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false); | 112 | + //TODO: implement the event listener for notifications. |
165 | } | 113 | } |
166 | 114 | ||
167 | /** | 115 | /** | ... | ... |
... | @@ -17,11 +17,11 @@ | ... | @@ -17,11 +17,11 @@ |
17 | package org.onosproject.yangutils.translator.tojava.javamodel; | 17 | package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | + | ||
20 | import org.onosproject.yangutils.datamodel.YangOutput; | 21 | import org.onosproject.yangutils.datamodel.YangOutput; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
27 | 27 | ||
... | @@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti | ... | @@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti |
31 | /** | 31 | /** |
32 | * Represents output information extended to support java code generation. | 32 | * Represents output information extended to support java code generation. |
33 | */ | 33 | */ |
34 | -public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 34 | +public class YangJavaOutput |
35 | + extends YangOutput | ||
36 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
35 | 37 | ||
36 | /** | 38 | /** |
37 | * Contains information of the java file being generated. | 39 | * Contains information of the java file being generated. |
... | @@ -39,12 +41,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, | ... | @@ -39,12 +41,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, |
39 | private JavaFileInfo javaFileInfo; | 41 | private JavaFileInfo javaFileInfo; |
40 | 42 | ||
41 | /** | 43 | /** |
42 | - * Contains information of the imports to be inserted in the java file | ||
43 | - * generated. | ||
44 | - */ | ||
45 | - private JavaImportData javaImportData; | ||
46 | - | ||
47 | - /** | ||
48 | * File handle to maintain temporary java code fragments as per the code | 44 | * File handle to maintain temporary java code fragments as per the code |
49 | * snippet types. | 45 | * snippet types. |
50 | */ | 46 | */ |
... | @@ -56,7 +52,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, | ... | @@ -56,7 +52,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, |
56 | public YangJavaOutput() { | 52 | public YangJavaOutput() { |
57 | super(); | 53 | super(); |
58 | setJavaFileInfo(new JavaFileInfo()); | 54 | setJavaFileInfo(new JavaFileInfo()); |
59 | - setJavaImportData(new JavaImportData()); | ||
60 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | 55 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); |
61 | } | 56 | } |
62 | 57 | ||
... | @@ -84,27 +79,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, | ... | @@ -84,27 +79,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, |
84 | } | 79 | } |
85 | 80 | ||
86 | /** | 81 | /** |
87 | - * Returns the data of java imports to be included in generated file. | ||
88 | - * | ||
89 | - * @return data of java imports to be included in generated file | ||
90 | - */ | ||
91 | - @Override | ||
92 | - public JavaImportData getJavaImportData() { | ||
93 | - return javaImportData; | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * Sets the data of java imports to be included in generated file. | ||
98 | - * | ||
99 | - * @param javaImportData data of java imports to be included in generated | ||
100 | - * file | ||
101 | - */ | ||
102 | - @Override | ||
103 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
104 | - this.javaImportData = javaImportData; | ||
105 | - } | ||
106 | - | ||
107 | - /** | ||
108 | * Returns the temporary file handle. | 82 | * Returns the temporary file handle. |
109 | * | 83 | * |
110 | * @return temporary file handle | 84 | * @return temporary file handle |
... | @@ -132,8 +106,10 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, | ... | @@ -132,8 +106,10 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, |
132 | * @throws IOException IO operation fail | 106 | * @throws IOException IO operation fail |
133 | */ | 107 | */ |
134 | @Override | 108 | @Override |
135 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 109 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
110 | + throws IOException { | ||
136 | generateCodeOfNode(this, yangPlugin); | 111 | generateCodeOfNode(this, yangPlugin); |
112 | + | ||
137 | } | 113 | } |
138 | 114 | ||
139 | /** | 115 | /** |
... | @@ -142,7 +118,8 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, | ... | @@ -142,7 +118,8 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, |
142 | * @throws IOException IO operation fail | 118 | * @throws IOException IO operation fail |
143 | */ | 119 | */ |
144 | @Override | 120 | @Override |
145 | - public void generateCodeExit() throws IOException { | 121 | + public void generateCodeExit() |
122 | + throws IOException { | ||
146 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); | 123 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); |
147 | } | 124 | } |
148 | } | 125 | } | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
... | @@ -17,27 +17,31 @@ | ... | @@ -17,27 +17,31 @@ |
17 | package org.onosproject.yangutils.translator.tojava.javamodel; | 17 | package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | -import org.onosproject.yangutils.datamodel.HasRpcNotification; | 20 | + |
21 | +import org.onosproject.yangutils.datamodel.RpcNotificationContainer; | ||
21 | import org.onosproject.yangutils.datamodel.YangInput; | 22 | import org.onosproject.yangutils.datamodel.YangInput; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 23 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.datamodel.YangOutput; | 24 | import org.onosproject.yangutils.datamodel.YangOutput; |
24 | import org.onosproject.yangutils.datamodel.YangRpc; | 25 | import org.onosproject.yangutils.datamodel.YangRpc; |
25 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 26 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
26 | -import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo; | 27 | +import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
27 | -import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles; | ||
28 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; | 28 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; |
29 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 29 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
30 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 30 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
31 | +import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | ||
31 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 32 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
32 | 33 | ||
33 | -import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getCurNodeAsAttributeInParent; | 34 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_RPC_INTERFACE; |
35 | +import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getCurNodeAsAttributeInParent; | ||
34 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode; | 36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode; |
35 | import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo; | 37 | import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo; |
36 | 38 | ||
37 | /** | 39 | /** |
38 | * Represents rpc information extended to support java code generation. | 40 | * Represents rpc information extended to support java code generation. |
39 | */ | 41 | */ |
40 | -public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFileInfo { | 42 | +public class YangJavaRpc |
43 | + extends YangRpc | ||
44 | + implements JavaCodeGenerator, JavaCodeGeneratorInfo { | ||
41 | 45 | ||
42 | /** | 46 | /** |
43 | * Contains the information of the java file being generated. | 47 | * Contains the information of the java file being generated. |
... | @@ -45,35 +49,57 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi | ... | @@ -45,35 +49,57 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi |
45 | private JavaFileInfo javaFileInfo; | 49 | private JavaFileInfo javaFileInfo; |
46 | 50 | ||
47 | /** | 51 | /** |
52 | + * Temproary file for code generation. | ||
53 | + */ | ||
54 | + private TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles; | ||
55 | + | ||
56 | + /** | ||
48 | * Creates an instance of YANG java rpc. | 57 | * Creates an instance of YANG java rpc. |
49 | */ | 58 | */ |
50 | public YangJavaRpc() { | 59 | public YangJavaRpc() { |
51 | super(); | 60 | super(); |
52 | setJavaFileInfo(new JavaFileInfo()); | 61 | setJavaFileInfo(new JavaFileInfo()); |
62 | + getJavaFileInfo().setGeneratedFileTypes(GENERATE_RPC_INTERFACE); | ||
63 | + try { | ||
64 | + setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(getJavaFileInfo())); | ||
65 | + } catch (IOException e) { | ||
66 | + throw new RuntimeException("Failed to create temporary RPC file handle"); | ||
67 | + } | ||
53 | } | 68 | } |
54 | 69 | ||
55 | /** | 70 | /** |
56 | * Prepares the information for java code generation corresponding to YANG | 71 | * Prepares the information for java code generation corresponding to YANG |
57 | - * rpc info. | 72 | + * RPC info. |
58 | * | 73 | * |
59 | * @param yangPlugin YANG plugin config | 74 | * @param yangPlugin YANG plugin config |
60 | * @throws IOException IO operations fails | 75 | * @throws IOException IO operations fails |
61 | */ | 76 | */ |
62 | @Override | 77 | @Override |
63 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 78 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
79 | + throws IOException { | ||
64 | 80 | ||
65 | - if (!(this instanceof YangNode)) { | 81 | + if (!(this instanceof JavaCodeGeneratorInfo)) { |
66 | // TODO:throw exception | 82 | // TODO:throw exception |
67 | } | 83 | } |
68 | 84 | ||
69 | // Add package information for rpc and create corresponding folder. | 85 | // Add package information for rpc and create corresponding folder. |
70 | - updatePackageInfo(this, yangPlugin); | 86 | + updatePackageInfo((JavaCodeGeneratorInfo) this, yangPlugin); |
87 | + | ||
88 | + } | ||
71 | 89 | ||
90 | + /** | ||
91 | + * Creates a java file using the YANG RPC info. | ||
92 | + * | ||
93 | + * @throws IOException IO operations fails | ||
94 | + */ | ||
95 | + @Override | ||
96 | + public void generateCodeExit() | ||
97 | + throws IOException { | ||
72 | // Get the parent module/sub-module. | 98 | // Get the parent module/sub-module. |
73 | YangNode parent = getParentNodeInGenCode((YangNode) this); | 99 | YangNode parent = getParentNodeInGenCode((YangNode) this); |
74 | 100 | ||
75 | // Parent should be holder of rpc or notification. | 101 | // Parent should be holder of rpc or notification. |
76 | - if (!(parent instanceof HasRpcNotification)) { | 102 | + if (!(parent instanceof RpcNotificationContainer)) { |
77 | throw new TranslatorException("parent node of rpc can only be module or sub-module"); | 103 | throw new TranslatorException("parent node of rpc can only be module or sub-module"); |
78 | } | 104 | } |
79 | 105 | ||
... | @@ -89,35 +115,26 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi | ... | @@ -89,35 +115,26 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi |
89 | YangNode yangNode = this.getChild(); | 115 | YangNode yangNode = this.getChild(); |
90 | while (yangNode != null) { | 116 | while (yangNode != null) { |
91 | if (yangNode instanceof YangInput) { | 117 | if (yangNode instanceof YangInput) { |
92 | - javaAttributeInfoOfInput = getCurNodeAsAttributeInParent(parent, false, yangNode.getName()); | 118 | + javaAttributeInfoOfInput = getCurNodeAsAttributeInParent(yangNode, this, false); |
93 | } else if (yangNode instanceof YangOutput) { | 119 | } else if (yangNode instanceof YangOutput) { |
94 | - javaAttributeInfoOfOutput = getCurNodeAsAttributeInParent(parent, false, yangNode.getName()); | 120 | + javaAttributeInfoOfOutput = getCurNodeAsAttributeInParent(yangNode, this, false); |
95 | } else { | 121 | } else { |
96 | // TODO throw exception | 122 | // TODO throw exception |
97 | } | 123 | } |
98 | yangNode = yangNode.getNextSibling(); | 124 | yangNode = yangNode.getNextSibling(); |
99 | } | 125 | } |
100 | 126 | ||
101 | - if (!(parent instanceof HasTempJavaCodeFragmentFiles)) { | 127 | + if (!(parent instanceof TempJavaCodeFragmentFilesContainer)) { |
102 | throw new TranslatorException("missing parent temp file handle"); | 128 | throw new TranslatorException("missing parent temp file handle"); |
103 | } | 129 | } |
104 | 130 | ||
105 | /* | 131 | /* |
106 | * Add the rpc information to the parent's service temp file. | 132 | * Add the rpc information to the parent's service temp file. |
107 | */ | 133 | */ |
108 | - ((HasTempJavaCodeFragmentFiles) parent) | 134 | + ((TempJavaCodeFragmentFilesContainer) parent) |
109 | - .getTempJavaCodeFragmentFiles() | 135 | + .getTempJavaCodeFragmentFiles().getServiceTempFiles() |
110 | .addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfoOfInput, javaAttributeInfoOfOutput, | 136 | .addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfoOfInput, javaAttributeInfoOfOutput, |
111 | ((YangNode) this).getName()); | 137 | ((YangNode) this).getName()); |
112 | - } | ||
113 | - | ||
114 | - /** | ||
115 | - * Creates a java file using the YANG rpc info. | ||
116 | - * | ||
117 | - * @throws IOException IO operations fails | ||
118 | - */ | ||
119 | - @Override | ||
120 | - public void generateCodeExit() throws IOException { | ||
121 | // No file will be generated during RPC exit. | 138 | // No file will be generated during RPC exit. |
122 | } | 139 | } |
123 | 140 | ||
... | @@ -144,5 +161,15 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi | ... | @@ -144,5 +161,15 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi |
144 | public void setJavaFileInfo(JavaFileInfo javaInfo) { | 161 | public void setJavaFileInfo(JavaFileInfo javaInfo) { |
145 | javaFileInfo = javaInfo; | 162 | javaFileInfo = javaInfo; |
146 | } | 163 | } |
164 | + | ||
165 | + @Override | ||
166 | + public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() { | ||
167 | + return tempJavaCodeFragmentFiles; | ||
168 | + } | ||
169 | + | ||
170 | + @Override | ||
171 | + public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) { | ||
172 | + tempJavaCodeFragmentFiles = fileHandle; | ||
173 | + } | ||
147 | } | 174 | } |
148 | 175 | ... | ... |
... | @@ -16,12 +16,12 @@ | ... | @@ -16,12 +16,12 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangBelongsTo; | 20 | import org.onosproject.yangutils.datamodel.YangBelongsTo; |
20 | import org.onosproject.yangutils.datamodel.YangSubModule; | 21 | import org.onosproject.yangutils.datamodel.YangSubModule; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils; | 26 | import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils; |
27 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 27 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
... | @@ -32,7 +32,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSy | ... | @@ -32,7 +32,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSy |
32 | /** | 32 | /** |
33 | * Represents sub module information extended to support java code generation. | 33 | * Represents sub module information extended to support java code generation. |
34 | */ | 34 | */ |
35 | -public class YangJavaSubModule extends YangSubModule implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 35 | +public class YangJavaSubModule |
36 | + extends YangSubModule | ||
37 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
36 | 38 | ||
37 | /** | 39 | /** |
38 | * Contains the information of the java file being generated. | 40 | * Contains the information of the java file being generated. |
... | @@ -40,12 +42,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato | ... | @@ -40,12 +42,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato |
40 | private JavaFileInfo javaFileInfo; | 42 | private JavaFileInfo javaFileInfo; |
41 | 43 | ||
42 | /** | 44 | /** |
43 | - * Contains information of the imports to be inserted in the java file | ||
44 | - * generated. | ||
45 | - */ | ||
46 | - private JavaImportData javaImportData; | ||
47 | - | ||
48 | - /** | ||
49 | * File handle to maintain temporary java code fragments as per the code | 45 | * File handle to maintain temporary java code fragments as per the code |
50 | * snippet types. | 46 | * snippet types. |
51 | */ | 47 | */ |
... | @@ -57,7 +53,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato | ... | @@ -57,7 +53,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato |
57 | public YangJavaSubModule() { | 53 | public YangJavaSubModule() { |
58 | super(); | 54 | super(); |
59 | setJavaFileInfo(new JavaFileInfo()); | 55 | setJavaFileInfo(new JavaFileInfo()); |
60 | - setJavaImportData(new JavaImportData()); | ||
61 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_MANAGER_WITH_RPC); | 56 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_MANAGER_WITH_RPC); |
62 | } | 57 | } |
63 | 58 | ||
... | @@ -85,27 +80,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato | ... | @@ -85,27 +80,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato |
85 | } | 80 | } |
86 | 81 | ||
87 | /** | 82 | /** |
88 | - * Returns the data of java imports to be included in generated file. | ||
89 | - * | ||
90 | - * @return data of java imports to be included in generated file | ||
91 | - */ | ||
92 | - @Override | ||
93 | - public JavaImportData getJavaImportData() { | ||
94 | - return javaImportData; | ||
95 | - } | ||
96 | - | ||
97 | - /** | ||
98 | - * Sets the data of java imports to be included in generated file. | ||
99 | - * | ||
100 | - * @param javaImportData data of java imports to be included in generated | ||
101 | - * file | ||
102 | - */ | ||
103 | - @Override | ||
104 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
105 | - this.javaImportData = javaImportData; | ||
106 | - } | ||
107 | - | ||
108 | - /** | ||
109 | * Returns the temporary file handle. | 83 | * Returns the temporary file handle. |
110 | * | 84 | * |
111 | * @return temporary file handle | 85 | * @return temporary file handle |
... | @@ -145,7 +119,8 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato | ... | @@ -145,7 +119,8 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato |
145 | * @throws IOException IO operation fail | 119 | * @throws IOException IO operation fail |
146 | */ | 120 | */ |
147 | @Override | 121 | @Override |
148 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 122 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
123 | + throws IOException { | ||
149 | String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()), | 124 | String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()), |
150 | getRevision().getRevDate()); | 125 | getRevision().getRevDate()); |
151 | YangJavaModelUtils.generateCodeOfRootNode(this, yangPlugin, subModulePkg); | 126 | YangJavaModelUtils.generateCodeOfRootNode(this, yangPlugin, subModulePkg); | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.translator.tojava.javamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.YangType; | ||
19 | +import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
20 | +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | ||
21 | +import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType; | ||
22 | + | ||
23 | +/** | ||
24 | + * Represents java information corresponding to the YANG type. | ||
25 | + */ | ||
26 | +public class YangJavaType<T> | ||
27 | + extends YangType<T> | ||
28 | + implements JavaQualifiedTypeResolver { | ||
29 | + | ||
30 | + private JavaQualifiedTypeInfo javaQualifiedAccess; | ||
31 | + | ||
32 | + /** | ||
33 | + * Create a YANG leaf object with java qualified access details. | ||
34 | + */ | ||
35 | + public YangJavaType() { | ||
36 | + super(); | ||
37 | + setJavaQualifiedInfo(new JavaQualifiedTypeInfo()); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public void updateJavaQualifiedInfo() { | ||
42 | + JavaQualifiedTypeInfo importInfo = getJavaQualifiedInfo(); | ||
43 | + | ||
44 | + /* | ||
45 | + * Type is added as an attribute in the class. | ||
46 | + */ | ||
47 | + String className = AttributesJavaDataType.getJavaImportClass(this, false); | ||
48 | + if (className != null) { | ||
49 | + /* | ||
50 | + * Corresponding to the attribute type a class needs to be imported, | ||
51 | + * since it can be a derived type or a usage of wrapper classes. | ||
52 | + */ | ||
53 | + importInfo.setClassInfo(className); | ||
54 | + String classPkg = AttributesJavaDataType.getJavaImportPackage(this, | ||
55 | + false, className); | ||
56 | + if (classPkg == null) { | ||
57 | + throw new TranslatorException("import package cannot be null when the class is used"); | ||
58 | + } | ||
59 | + importInfo.setPkgInfo(classPkg); | ||
60 | + } else { | ||
61 | + /* | ||
62 | + * The attribute does not need a class to be imported, for example | ||
63 | + * built in java types. | ||
64 | + */ | ||
65 | + String dataTypeName = AttributesJavaDataType.getJavaDataType(this); | ||
66 | + if (dataTypeName == null) { | ||
67 | + throw new TranslatorException("not supported data type"); | ||
68 | + } | ||
69 | + importInfo.setClassInfo(dataTypeName); | ||
70 | + } | ||
71 | + } | ||
72 | + | ||
73 | + @Override | ||
74 | + public JavaQualifiedTypeInfo getJavaQualifiedInfo() { | ||
75 | + return javaQualifiedAccess; | ||
76 | + } | ||
77 | + | ||
78 | + @Override | ||
79 | + public void setJavaQualifiedInfo(JavaQualifiedTypeInfo typeInfo) { | ||
80 | + javaQualifiedAccess = typeInfo; | ||
81 | + } | ||
82 | +} |
... | @@ -16,11 +16,11 @@ | ... | @@ -16,11 +16,11 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 20 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
20 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
22 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
23 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
26 | 26 | ||
... | @@ -30,7 +30,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti | ... | @@ -30,7 +30,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti |
30 | /** | 30 | /** |
31 | * Represents type define information extended to support java code generation. | 31 | * Represents type define information extended to support java code generation. |
32 | */ | 32 | */ |
33 | -public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 33 | +public class YangJavaTypeDef |
34 | + extends YangTypeDef | ||
35 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
34 | 36 | ||
35 | /** | 37 | /** |
36 | * Contains the information of the java file being generated. | 38 | * Contains the information of the java file being generated. |
... | @@ -38,12 +40,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf | ... | @@ -38,12 +40,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf |
38 | private JavaFileInfo javaFileInfo; | 40 | private JavaFileInfo javaFileInfo; |
39 | 41 | ||
40 | /** | 42 | /** |
41 | - * Contains information of the imports to be inserted in the java file | ||
42 | - * generated. | ||
43 | - */ | ||
44 | - private JavaImportData javaImportData; | ||
45 | - | ||
46 | - /** | ||
47 | * File handle to maintain temporary java code fragments as per the code | 43 | * File handle to maintain temporary java code fragments as per the code |
48 | * snippet types. | 44 | * snippet types. |
49 | */ | 45 | */ |
... | @@ -55,7 +51,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf | ... | @@ -55,7 +51,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf |
55 | public YangJavaTypeDef() { | 51 | public YangJavaTypeDef() { |
56 | super(); | 52 | super(); |
57 | setJavaFileInfo(new JavaFileInfo()); | 53 | setJavaFileInfo(new JavaFileInfo()); |
58 | - setJavaImportData(new JavaImportData()); | ||
59 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_TYPEDEF_CLASS); | 54 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_TYPEDEF_CLASS); |
60 | } | 55 | } |
61 | 56 | ||
... | @@ -84,27 +79,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf | ... | @@ -84,27 +79,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf |
84 | } | 79 | } |
85 | 80 | ||
86 | /** | 81 | /** |
87 | - * Returns the data of java imports to be included in generated file. | ||
88 | - * | ||
89 | - * @return data of java imports to be included in generated file | ||
90 | - */ | ||
91 | - @Override | ||
92 | - public JavaImportData getJavaImportData() { | ||
93 | - return javaImportData; | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * Sets the data of java imports to be included in generated file. | ||
98 | - * | ||
99 | - * @param javaImportData data of java imports to be included in generated | ||
100 | - * file | ||
101 | - */ | ||
102 | - @Override | ||
103 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
104 | - this.javaImportData = javaImportData; | ||
105 | - } | ||
106 | - | ||
107 | - /** | ||
108 | * Returns the temporary file handle. | 82 | * Returns the temporary file handle. |
109 | * | 83 | * |
110 | * @return temporary file handle | 84 | * @return temporary file handle |
... | @@ -132,8 +106,9 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf | ... | @@ -132,8 +106,9 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf |
132 | * @throws IOException IO operations fails | 106 | * @throws IOException IO operations fails |
133 | */ | 107 | */ |
134 | @Override | 108 | @Override |
135 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 109 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
136 | - generateCodeOfNode(this, yangPlugin, false); | 110 | + throws IOException { |
111 | + generateCodeOfNode(this, yangPlugin); | ||
137 | } | 112 | } |
138 | 113 | ||
139 | /** | 114 | /** |
... | @@ -142,7 +117,8 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf | ... | @@ -142,7 +117,8 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf |
142 | * @throws IOException IO operations fails | 117 | * @throws IOException IO operations fails |
143 | */ | 118 | */ |
144 | @Override | 119 | @Override |
145 | - public void generateCodeExit() throws IOException { | 120 | + public void generateCodeExit() |
121 | + throws IOException { | ||
146 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_TYPEDEF_CLASS, this); | 122 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_TYPEDEF_CLASS, this); |
147 | } | 123 | } |
148 | 124 | ... | ... |
... | @@ -16,10 +16,10 @@ | ... | @@ -16,10 +16,10 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | + | ||
19 | import org.onosproject.yangutils.datamodel.YangUnion; | 20 | import org.onosproject.yangutils.datamodel.YangUnion; |
20 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
21 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 22 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
22 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
23 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 23 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
24 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 24 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
25 | 25 | ||
... | @@ -29,7 +29,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti | ... | @@ -29,7 +29,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti |
29 | /** | 29 | /** |
30 | * Represents union information extended to support java code generation. | 30 | * Represents union information extended to support java code generation. |
31 | */ | 31 | */ |
32 | -public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, JavaCodeGenerator { | 32 | +public class YangJavaUnion |
33 | + extends YangUnion | ||
34 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
33 | 35 | ||
34 | /** | 36 | /** |
35 | * Contains the information of the java file being generated. | 37 | * Contains the information of the java file being generated. |
... | @@ -37,12 +39,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J | ... | @@ -37,12 +39,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J |
37 | private JavaFileInfo javaFileInfo; | 39 | private JavaFileInfo javaFileInfo; |
38 | 40 | ||
39 | /** | 41 | /** |
40 | - * Contains information of the imports to be inserted in the java file | ||
41 | - * generated. | ||
42 | - */ | ||
43 | - private JavaImportData javaImportData; | ||
44 | - | ||
45 | - /** | ||
46 | * File handle to maintain temporary java code fragments as per the code | 42 | * File handle to maintain temporary java code fragments as per the code |
47 | * snippet types. | 43 | * snippet types. |
48 | */ | 44 | */ |
... | @@ -54,7 +50,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J | ... | @@ -54,7 +50,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J |
54 | public YangJavaUnion() { | 50 | public YangJavaUnion() { |
55 | super(); | 51 | super(); |
56 | setJavaFileInfo(new JavaFileInfo()); | 52 | setJavaFileInfo(new JavaFileInfo()); |
57 | - setJavaImportData(new JavaImportData()); | ||
58 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_UNION_CLASS); | 53 | getJavaFileInfo().setGeneratedFileTypes(GENERATE_UNION_CLASS); |
59 | } | 54 | } |
60 | 55 | ||
... | @@ -82,27 +77,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J | ... | @@ -82,27 +77,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J |
82 | } | 77 | } |
83 | 78 | ||
84 | /** | 79 | /** |
85 | - * Returns the data of java imports to be included in generated file. | ||
86 | - * | ||
87 | - * @return data of java imports to be included in generated file | ||
88 | - */ | ||
89 | - @Override | ||
90 | - public JavaImportData getJavaImportData() { | ||
91 | - return javaImportData; | ||
92 | - } | ||
93 | - | ||
94 | - /** | ||
95 | - * Sets the data of java imports to be included in generated file. | ||
96 | - * | ||
97 | - * @param javaImportData data of java imports to be included in generated | ||
98 | - * file | ||
99 | - */ | ||
100 | - @Override | ||
101 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
102 | - this.javaImportData = javaImportData; | ||
103 | - } | ||
104 | - | ||
105 | - /** | ||
106 | * Returns the temporary file handle. | 80 | * Returns the temporary file handle. |
107 | * | 81 | * |
108 | * @return temporary file handle | 82 | * @return temporary file handle |
... | @@ -134,7 +108,8 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J | ... | @@ -134,7 +108,8 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J |
134 | * @throws IOException IO operations fails | 108 | * @throws IOException IO operations fails |
135 | */ | 109 | */ |
136 | @Override | 110 | @Override |
137 | - public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException { | 111 | + public void generateCodeEntry(YangPluginConfig yangPlugin) |
112 | + throws IOException { | ||
138 | generateCodeOfNode(this, yangPlugin); | 113 | generateCodeOfNode(this, yangPlugin); |
139 | } | 114 | } |
140 | 115 | ||
... | @@ -144,7 +119,8 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J | ... | @@ -144,7 +119,8 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J |
144 | * @throws IOException IO operations fails | 119 | * @throws IOException IO operations fails |
145 | */ | 120 | */ |
146 | @Override | 121 | @Override |
147 | - public void generateCodeExit() throws IOException { | 122 | + public void generateCodeExit() |
123 | + throws IOException { | ||
148 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_UNION_CLASS, this); | 124 | getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_UNION_CLASS, this); |
149 | } | 125 | } |
150 | } | 126 | } | ... | ... |
... | @@ -16,89 +16,21 @@ | ... | @@ -16,89 +16,21 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.YangUses; | 18 | import org.onosproject.yangutils.datamodel.YangUses; |
19 | -import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
20 | -import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo; | ||
21 | -import org.onosproject.yangutils.translator.tojava.HasJavaImportData; | ||
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 19 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ||
24 | -import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
25 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 20 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
26 | 21 | ||
27 | -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | ||
28 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | ||
29 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase; | ||
30 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage; | ||
31 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | ||
32 | - | ||
33 | /** | 22 | /** |
34 | * Represents uses information extended to support java code generation. | 23 | * Represents uses information extended to support java code generation. |
35 | */ | 24 | */ |
36 | -public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJavaFileInfo, HasJavaImportData { | 25 | +public class YangJavaUses |
37 | - | 26 | + extends YangUses |
38 | - /** | 27 | + implements JavaCodeGenerator { |
39 | - * Contains the information of the java file being generated. | ||
40 | - */ | ||
41 | - private JavaFileInfo javaFileInfo; | ||
42 | - | ||
43 | - /** | ||
44 | - * Contains information of the imports to be inserted in the java file | ||
45 | - * generated. | ||
46 | - */ | ||
47 | - private JavaImportData javaImportData; | ||
48 | 28 | ||
49 | /** | 29 | /** |
50 | * Creates YANG java uses object. | 30 | * Creates YANG java uses object. |
51 | */ | 31 | */ |
52 | public YangJavaUses() { | 32 | public YangJavaUses() { |
53 | super(); | 33 | super(); |
54 | - setJavaFileInfo(new JavaFileInfo()); | ||
55 | - setJavaImportData(new JavaImportData()); | ||
56 | - getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | ||
57 | - } | ||
58 | - | ||
59 | - /** | ||
60 | - * Returns the generated java file information. | ||
61 | - * | ||
62 | - * @return generated java file information | ||
63 | - */ | ||
64 | - @Override | ||
65 | - public JavaFileInfo getJavaFileInfo() { | ||
66 | - | ||
67 | - if (javaFileInfo == null) { | ||
68 | - throw new TranslatorException("Missing java info in java datamodel node"); | ||
69 | - } | ||
70 | - return javaFileInfo; | ||
71 | - } | ||
72 | - | ||
73 | - /** | ||
74 | - * Sets the java file info object. | ||
75 | - * | ||
76 | - * @param javaInfo java file info object | ||
77 | - */ | ||
78 | - @Override | ||
79 | - public void setJavaFileInfo(JavaFileInfo javaInfo) { | ||
80 | - javaFileInfo = javaInfo; | ||
81 | - } | ||
82 | - | ||
83 | - /** | ||
84 | - * Returns the data of java imports to be included in generated file. | ||
85 | - * | ||
86 | - * @return data of java imports to be included in generated file | ||
87 | - */ | ||
88 | - @Override | ||
89 | - public JavaImportData getJavaImportData() { | ||
90 | - return javaImportData; | ||
91 | - } | ||
92 | - | ||
93 | - /** | ||
94 | - * Sets the data of java imports to be included in generated file. | ||
95 | - * | ||
96 | - * @param javaImportData data of java imports to be included in generated | ||
97 | - * file | ||
98 | - */ | ||
99 | - @Override | ||
100 | - public void setJavaImportData(JavaImportData javaImportData) { | ||
101 | - this.javaImportData = javaImportData; | ||
102 | } | 34 | } |
103 | 35 | ||
104 | /** | 36 | /** |
... | @@ -109,14 +41,7 @@ public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJava | ... | @@ -109,14 +41,7 @@ public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJava |
109 | */ | 41 | */ |
110 | @Override | 42 | @Override |
111 | public void generateCodeEntry(YangPluginConfig yangPlugin) { | 43 | public void generateCodeEntry(YangPluginConfig yangPlugin) { |
112 | - | 44 | + /*Do nothing, the uses will copy the contents to the used location*/ |
113 | - getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName(), yangPlugin.getConflictResolver()))); | ||
114 | - getJavaFileInfo().setPackage(getCurNodePackage(this)); | ||
115 | - getJavaFileInfo().setPackageFilePath( | ||
116 | - getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage())); | ||
117 | - getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getCodeGenDir()); | ||
118 | - //TODO:addCurNodeLeavesInfoToTempFiles(this); | ||
119 | - //TODO:addCurNodeInfoInParentTempFile(this, false); | ||
120 | } | 45 | } |
121 | 46 | ||
122 | /** | 47 | /** |
... | @@ -124,7 +49,6 @@ public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJava | ... | @@ -124,7 +49,6 @@ public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJava |
124 | */ | 49 | */ |
125 | @Override | 50 | @Override |
126 | public void generateCodeExit() { | 51 | public void generateCodeExit() { |
127 | - // TODO Auto-generated method stub | 52 | + /*Do nothing, the uses will copy the contents to the used location*/ |
128 | - | ||
129 | } | 53 | } |
130 | } | 54 | } | ... | ... |
... | @@ -24,7 +24,7 @@ import org.onosproject.yangutils.datamodel.YangType; | ... | @@ -24,7 +24,7 @@ import org.onosproject.yangutils.datamodel.YangType; |
24 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 24 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
25 | import org.onosproject.yangutils.datamodel.YangUnion; | 25 | import org.onosproject.yangutils.datamodel.YangUnion; |
26 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 26 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
27 | -import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo; | 27 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
29 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; | 29 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; |
30 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; | 30 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; |
... | @@ -183,6 +183,7 @@ public final class AttributesJavaDataType { | ... | @@ -183,6 +183,7 @@ public final class AttributesJavaDataType { |
183 | return BIG_INTEGER; | 183 | return BIG_INTEGER; |
184 | case DECIMAL64: | 184 | case DECIMAL64: |
185 | //TODO: DECIMAL64. | 185 | //TODO: DECIMAL64. |
186 | + break; | ||
186 | case STRING: | 187 | case STRING: |
187 | return STRING_DATA_TYPE; | 188 | return STRING_DATA_TYPE; |
188 | case BOOLEAN: | 189 | case BOOLEAN: |
... | @@ -192,12 +193,16 @@ public final class AttributesJavaDataType { | ... | @@ -192,12 +193,16 @@ public final class AttributesJavaDataType { |
192 | getCamelCase(((YangJavaEnumeration) yangType.getDataTypeExtendedInfo()).getName(), null)); | 193 | getCamelCase(((YangJavaEnumeration) yangType.getDataTypeExtendedInfo()).getName(), null)); |
193 | case BITS: | 194 | case BITS: |
194 | //TODO:BITS | 195 | //TODO:BITS |
196 | + break; | ||
195 | case BINARY: | 197 | case BINARY: |
196 | //TODO:BINARY | 198 | //TODO:BINARY |
199 | + break; | ||
197 | case LEAFREF: | 200 | case LEAFREF: |
198 | //TODO:LEAFREF | 201 | //TODO:LEAFREF |
202 | + break; | ||
199 | case IDENTITYREF: | 203 | case IDENTITYREF: |
200 | //TODO:IDENTITYREF | 204 | //TODO:IDENTITYREF |
205 | + break; | ||
201 | case EMPTY: | 206 | case EMPTY: |
202 | return BOOLEAN_WRAPPER; | 207 | return BOOLEAN_WRAPPER; |
203 | case UNION: | 208 | case UNION: |
... | @@ -216,6 +221,7 @@ public final class AttributesJavaDataType { | ... | @@ -216,6 +221,7 @@ public final class AttributesJavaDataType { |
216 | return BIG_INTEGER; | 221 | return BIG_INTEGER; |
217 | case DECIMAL64: | 222 | case DECIMAL64: |
218 | //TODO: DECIMAL64. | 223 | //TODO: DECIMAL64. |
224 | + break; | ||
219 | case STRING: | 225 | case STRING: |
220 | return STRING_DATA_TYPE; | 226 | return STRING_DATA_TYPE; |
221 | case ENUMERATION: | 227 | case ENUMERATION: |
... | @@ -223,25 +229,32 @@ public final class AttributesJavaDataType { | ... | @@ -223,25 +229,32 @@ public final class AttributesJavaDataType { |
223 | getCamelCase(((YangJavaEnumeration) yangType.getDataTypeExtendedInfo()).getName(), null)); | 229 | getCamelCase(((YangJavaEnumeration) yangType.getDataTypeExtendedInfo()).getName(), null)); |
224 | case BITS: | 230 | case BITS: |
225 | //TODO:BITS | 231 | //TODO:BITS |
232 | + break; | ||
226 | case BINARY: | 233 | case BINARY: |
227 | //TODO:BINARY | 234 | //TODO:BINARY |
235 | + break; | ||
228 | case LEAFREF: | 236 | case LEAFREF: |
229 | //TODO:LEAFREF | 237 | //TODO:LEAFREF |
238 | + break; | ||
230 | case IDENTITYREF: | 239 | case IDENTITYREF: |
231 | //TODO:IDENTITYREF | 240 | //TODO:IDENTITYREF |
241 | + break; | ||
232 | case EMPTY: | 242 | case EMPTY: |
233 | //TODO:EMPTY | 243 | //TODO:EMPTY |
244 | + break; | ||
234 | case UNION: | 245 | case UNION: |
235 | return getCaptialCase(getCamelCase(((YangJavaUnion) yangType.getDataTypeExtendedInfo()).getName(), | 246 | return getCaptialCase(getCamelCase(((YangJavaUnion) yangType.getDataTypeExtendedInfo()).getName(), |
236 | null)); | 247 | null)); |
237 | case INSTANCE_IDENTIFIER: | 248 | case INSTANCE_IDENTIFIER: |
238 | //TODO:INSTANCE_IDENTIFIER | 249 | //TODO:INSTANCE_IDENTIFIER |
250 | + break; | ||
239 | case DERIVED: | 251 | case DERIVED: |
240 | return getCaptialCase(getCamelCase(yangType.getDataTypeName(), null)); | 252 | return getCaptialCase(getCamelCase(yangType.getDataTypeName(), null)); |
241 | default: | 253 | default: |
242 | return null; | 254 | return null; |
243 | } | 255 | } |
244 | } | 256 | } |
257 | + return null; | ||
245 | } | 258 | } |
246 | 259 | ||
247 | /** | 260 | /** |
... | @@ -272,22 +285,29 @@ public final class AttributesJavaDataType { | ... | @@ -272,22 +285,29 @@ public final class AttributesJavaDataType { |
272 | return JAVA_MATH; | 285 | return JAVA_MATH; |
273 | case DECIMAL64: | 286 | case DECIMAL64: |
274 | //TODO: DECIMAL64. | 287 | //TODO: DECIMAL64. |
288 | + break; | ||
275 | case ENUMERATION: | 289 | case ENUMERATION: |
276 | return getEnumsPackage(yangType); | 290 | return getEnumsPackage(yangType); |
277 | case BITS: | 291 | case BITS: |
278 | //TODO:BITS | 292 | //TODO:BITS |
293 | + break; | ||
279 | case BINARY: | 294 | case BINARY: |
280 | //TODO:BINARY | 295 | //TODO:BINARY |
296 | + break; | ||
281 | case LEAFREF: | 297 | case LEAFREF: |
282 | //TODO:LEAFREF | 298 | //TODO:LEAFREF |
299 | + break; | ||
283 | case IDENTITYREF: | 300 | case IDENTITYREF: |
284 | //TODO:IDENTITYREF | 301 | //TODO:IDENTITYREF |
302 | + break; | ||
285 | case EMPTY: | 303 | case EMPTY: |
286 | //TODO:EMPTY | 304 | //TODO:EMPTY |
305 | + break; | ||
287 | case UNION: | 306 | case UNION: |
288 | return getUnionPackage(yangType); | 307 | return getUnionPackage(yangType); |
289 | case INSTANCE_IDENTIFIER: | 308 | case INSTANCE_IDENTIFIER: |
290 | //TODO:INSTANCE_IDENTIFIER | 309 | //TODO:INSTANCE_IDENTIFIER |
310 | + break; | ||
291 | case DERIVED: | 311 | case DERIVED: |
292 | return getTypDefsPackage(yangType); | 312 | return getTypDefsPackage(yangType); |
293 | default: | 313 | default: |
... | @@ -297,32 +317,41 @@ public final class AttributesJavaDataType { | ... | @@ -297,32 +317,41 @@ public final class AttributesJavaDataType { |
297 | switch (type) { | 317 | switch (type) { |
298 | case UINT64: | 318 | case UINT64: |
299 | //TODO: BIGINTEGER. | 319 | //TODO: BIGINTEGER. |
320 | + break; | ||
300 | case DECIMAL64: | 321 | case DECIMAL64: |
301 | //TODO: DECIMAL64 | 322 | //TODO: DECIMAL64 |
323 | + break; | ||
302 | case STRING: | 324 | case STRING: |
303 | return JAVA_LANG; | 325 | return JAVA_LANG; |
304 | case ENUMERATION: | 326 | case ENUMERATION: |
305 | return getEnumsPackage(yangType); | 327 | return getEnumsPackage(yangType); |
306 | case BITS: | 328 | case BITS: |
307 | //TODO:BITS | 329 | //TODO:BITS |
330 | + break; | ||
308 | case BINARY: | 331 | case BINARY: |
309 | //TODO:BINARY | 332 | //TODO:BINARY |
333 | + break; | ||
310 | case LEAFREF: | 334 | case LEAFREF: |
311 | //TODO:LEAFREF | 335 | //TODO:LEAFREF |
336 | + break; | ||
312 | case IDENTITYREF: | 337 | case IDENTITYREF: |
313 | //TODO:IDENTITYREF | 338 | //TODO:IDENTITYREF |
339 | + break; | ||
314 | case EMPTY: | 340 | case EMPTY: |
315 | //TODO:EMPTY | 341 | //TODO:EMPTY |
342 | + break; | ||
316 | case UNION: | 343 | case UNION: |
317 | return getUnionPackage(yangType); | 344 | return getUnionPackage(yangType); |
318 | case INSTANCE_IDENTIFIER: | 345 | case INSTANCE_IDENTIFIER: |
319 | //TODO:INSTANCE_IDENTIFIER | 346 | //TODO:INSTANCE_IDENTIFIER |
347 | + break; | ||
320 | case DERIVED: | 348 | case DERIVED: |
321 | return getTypDefsPackage(yangType); | 349 | return getTypDefsPackage(yangType); |
322 | default: | 350 | default: |
323 | return null; | 351 | return null; |
324 | } | 352 | } |
325 | } | 353 | } |
354 | + return null; | ||
326 | } | 355 | } |
327 | 356 | ||
328 | /** | 357 | /** |
... | @@ -392,10 +421,10 @@ public final class AttributesJavaDataType { | ... | @@ -392,10 +421,10 @@ public final class AttributesJavaDataType { |
392 | * @return java package from parent node | 421 | * @return java package from parent node |
393 | */ | 422 | */ |
394 | private static String getPackageFromParent(YangNode parent) { | 423 | private static String getPackageFromParent(YangNode parent) { |
395 | - if (!(parent instanceof HasJavaFileInfo)) { | 424 | + if (!(parent instanceof JavaFileInfoContainer)) { |
396 | throw new TranslatorException("invalid child node is being processed."); | 425 | throw new TranslatorException("invalid child node is being processed."); |
397 | } | 426 | } |
398 | - JavaFileInfo parentInfo = ((HasJavaFileInfo) parent).getJavaFileInfo(); | 427 | + JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo(); |
399 | return parentInfo.getPackage() + PERIOD + parentInfo.getJavaName().toLowerCase(); | 428 | return parentInfo.getPackage() + PERIOD + parentInfo.getJavaName().toLowerCase(); |
400 | } | 429 | } |
401 | } | 430 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -19,10 +19,9 @@ package org.onosproject.yangutils.translator.tojava.utils; | ... | @@ -19,10 +19,9 @@ package org.onosproject.yangutils.translator.tojava.utils; |
19 | import java.io.File; | 19 | import java.io.File; |
20 | import java.io.IOException; | 20 | import java.io.IOException; |
21 | import java.util.List; | 21 | import java.util.List; |
22 | -import org.onosproject.yangutils.datamodel.YangNode; | 22 | + |
23 | -import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles; | ||
24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
25 | -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | +import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; |
26 | import org.onosproject.yangutils.utils.io.impl.CopyrightHeader; | 25 | import org.onosproject.yangutils.utils.io.impl.CopyrightHeader; |
27 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType; | 26 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType; |
28 | 27 | ||
... | @@ -39,6 +38,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. | ... | @@ -39,6 +38,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. |
39 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; | 38 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; |
40 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; | 39 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; |
41 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; | 40 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; |
41 | +import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; | ||
42 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; | 42 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; |
43 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK; | 43 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK; |
44 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK; | 44 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK; |
... | @@ -47,7 +47,6 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. | ... | @@ -47,7 +47,6 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. |
47 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; | 47 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; |
48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; | 48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; |
49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; | 49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; |
50 | -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; | ||
51 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefStart; | 50 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefStart; |
52 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath; | 51 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath; |
53 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; | 52 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; |
... | @@ -98,58 +97,59 @@ public final class JavaFileGeneratorUtils { | ... | @@ -98,58 +97,59 @@ public final class JavaFileGeneratorUtils { |
98 | * Returns data stored in temporary files. | 97 | * Returns data stored in temporary files. |
99 | * | 98 | * |
100 | * @param generatedTempFiles temporary file types | 99 | * @param generatedTempFiles temporary file types |
101 | - * @param curNode current YANG node | 100 | + * @param generatedTempFiles temporary file types |
101 | + * @param tempJavaFragmentFiles temp java fragment files | ||
102 | * @return data stored in temporary files | 102 | * @return data stored in temporary files |
103 | * @throws IOException when failed to get the data from temporary file handle | 103 | * @throws IOException when failed to get the data from temporary file handle |
104 | */ | 104 | */ |
105 | - public static String getDataFromTempFileHandle(int generatedTempFiles, YangNode curNode) throws IOException { | 105 | + public static String getDataFromTempFileHandle(int generatedTempFiles, |
106 | + TempJavaFragmentFiles tempJavaFragmentFiles) | ||
107 | + throws IOException { | ||
106 | 108 | ||
107 | - TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = ((HasTempJavaCodeFragmentFiles) curNode) | ||
108 | - .getTempJavaCodeFragmentFiles(); | ||
109 | 109 | ||
110 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { | 110 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { |
111 | - return tempJavaCodeFragmentFiles | 111 | + return tempJavaFragmentFiles |
112 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getAttributesTempFileHandle()); | 112 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAttributesTempFileHandle()); |
113 | } else if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) { | 113 | } else if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) { |
114 | - return tempJavaCodeFragmentFiles | 114 | + return tempJavaFragmentFiles |
115 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getGetterInterfaceTempFileHandle()); | 115 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getGetterInterfaceTempFileHandle()); |
116 | } else if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) { | 116 | } else if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) { |
117 | - return tempJavaCodeFragmentFiles | 117 | + return tempJavaFragmentFiles |
118 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getSetterInterfaceTempFileHandle()); | 118 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSetterInterfaceTempFileHandle()); |
119 | } else if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) { | 119 | } else if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) { |
120 | - return tempJavaCodeFragmentFiles | 120 | + return tempJavaFragmentFiles |
121 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getGetterImplTempFileHandle()); | 121 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getGetterImplTempFileHandle()); |
122 | } else if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) { | 122 | } else if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) { |
123 | - return tempJavaCodeFragmentFiles | 123 | + return tempJavaFragmentFiles |
124 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getSetterImplTempFileHandle()); | 124 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getSetterImplTempFileHandle()); |
125 | } else if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) { | 125 | } else if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) { |
126 | - return tempJavaCodeFragmentFiles | 126 | + return tempJavaFragmentFiles |
127 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getConstructorImplTempFileHandle()); | 127 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getConstructorImplTempFileHandle()); |
128 | } else if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) { | 128 | } else if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) { |
129 | - return tempJavaCodeFragmentFiles | 129 | + return tempJavaFragmentFiles |
130 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getHashCodeImplTempFileHandle()); | 130 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getHashCodeImplTempFileHandle()); |
131 | } else if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) { | 131 | } else if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) { |
132 | - return tempJavaCodeFragmentFiles | 132 | + return tempJavaFragmentFiles |
133 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getEqualsImplTempFileHandle()); | 133 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getEqualsImplTempFileHandle()); |
134 | } else if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) { | 134 | } else if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) { |
135 | - return tempJavaCodeFragmentFiles | 135 | + return tempJavaFragmentFiles |
136 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getToStringImplTempFileHandle()); | 136 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getToStringImplTempFileHandle()); |
137 | } else if ((generatedTempFiles & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { | 137 | } else if ((generatedTempFiles & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
138 | - return tempJavaCodeFragmentFiles | 138 | + return tempJavaFragmentFiles |
139 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles | 139 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles |
140 | .getConstructorForTypeTempFileHandle()); | 140 | .getConstructorForTypeTempFileHandle()); |
141 | } else if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) { | 141 | } else if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) { |
142 | - return tempJavaCodeFragmentFiles | 142 | + return tempJavaFragmentFiles |
143 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getOfStringImplTempFileHandle()); | 143 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getOfStringImplTempFileHandle()); |
144 | } else if ((generatedTempFiles & FROM_STRING_IMPL_MASK) != 0) { | 144 | } else if ((generatedTempFiles & FROM_STRING_IMPL_MASK) != 0) { |
145 | - return tempJavaCodeFragmentFiles | 145 | + return tempJavaFragmentFiles |
146 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getFromStringImplTempFileHandle()); | 146 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getFromStringImplTempFileHandle()); |
147 | } else if ((generatedTempFiles & ENUM_IMPL_MASK) != 0) { | 147 | } else if ((generatedTempFiles & ENUM_IMPL_MASK) != 0) { |
148 | - return tempJavaCodeFragmentFiles | 148 | + return tempJavaFragmentFiles |
149 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getEnumClassTempFileHandle()); | 149 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getEnumClassTempFileHandle()); |
150 | } else if ((generatedTempFiles & RPC_IMPL_MASK) != 0) { | 150 | } else if ((generatedTempFiles & RPC_IMPL_MASK) != 0) { |
151 | - return tempJavaCodeFragmentFiles | 151 | + return tempJavaFragmentFiles |
152 | - .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getRpcInterfaceImplTempFileHandle()); | 152 | + .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getRpcInterfaceImplTempFileHandle()); |
153 | } | 153 | } |
154 | return null; | 154 | return null; |
155 | } | 155 | } |
... | @@ -165,7 +165,8 @@ public final class JavaFileGeneratorUtils { | ... | @@ -165,7 +165,8 @@ public final class JavaFileGeneratorUtils { |
165 | * @throws IOException when fails to generate a file | 165 | * @throws IOException when fails to generate a file |
166 | */ | 166 | */ |
167 | public static void initiateJavaFileGeneration(File file, String className, int type, List<String> imports, | 167 | public static void initiateJavaFileGeneration(File file, String className, int type, List<String> imports, |
168 | - String pkg) throws IOException { | 168 | + String pkg) |
169 | + throws IOException { | ||
169 | 170 | ||
170 | try { | 171 | try { |
171 | file.createNewFile(); | 172 | file.createNewFile(); |
... | @@ -186,7 +187,8 @@ public final class JavaFileGeneratorUtils { | ... | @@ -186,7 +187,8 @@ public final class JavaFileGeneratorUtils { |
186 | * @throws IOException when fails to append contents | 187 | * @throws IOException when fails to append contents |
187 | */ | 188 | */ |
188 | private static void appendContents(File file, String fileName, int type, List<String> importsList, | 189 | private static void appendContents(File file, String fileName, int type, List<String> importsList, |
189 | - String pkg) throws IOException { | 190 | + String pkg) |
191 | + throws IOException { | ||
190 | 192 | ||
191 | String pkgString = parsePackageString(pkg, importsList); | 193 | String pkgString = parsePackageString(pkg, importsList); |
192 | 194 | ||
... | @@ -248,7 +250,8 @@ public final class JavaFileGeneratorUtils { | ... | @@ -248,7 +250,8 @@ public final class JavaFileGeneratorUtils { |
248 | * @param importsList list of imports | 250 | * @param importsList list of imports |
249 | * @throws IOException when fails to append contents | 251 | * @throws IOException when fails to append contents |
250 | */ | 252 | */ |
251 | - private static void appendHeaderContents(File file, String pkg, List<String> importsList) throws IOException { | 253 | + private static void appendHeaderContents(File file, String pkg, List<String> importsList) |
254 | + throws IOException { | ||
252 | 255 | ||
253 | insertDataIntoJavaFile(file, CopyrightHeader.getCopyrightHeader()); | 256 | insertDataIntoJavaFile(file, CopyrightHeader.getCopyrightHeader()); |
254 | insertDataIntoJavaFile(file, pkg); | 257 | insertDataIntoJavaFile(file, pkg); | ... | ... |
... | @@ -21,7 +21,7 @@ import java.util.List; | ... | @@ -21,7 +21,7 @@ import java.util.List; |
21 | 21 | ||
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
24 | -import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo; | 24 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
26 | 26 | ||
27 | import static org.onosproject.yangutils.utils.UtilConstants.COLAN; | 27 | import static org.onosproject.yangutils.utils.UtilConstants.COLAN; |
... | @@ -111,16 +111,16 @@ public final class JavaIdentifierSyntax { | ... | @@ -111,16 +111,16 @@ public final class JavaIdentifierSyntax { |
111 | public static String getCurNodePackage(YangNode curNode) { | 111 | public static String getCurNodePackage(YangNode curNode) { |
112 | 112 | ||
113 | String pkg; | 113 | String pkg; |
114 | - if (!(curNode instanceof HasJavaFileInfo) | 114 | + if (!(curNode instanceof JavaFileInfoContainer) |
115 | || curNode.getParent() == null) { | 115 | || curNode.getParent() == null) { |
116 | throw new TranslatorException("missing parent node to get current node's package"); | 116 | throw new TranslatorException("missing parent node to get current node's package"); |
117 | } | 117 | } |
118 | 118 | ||
119 | YangNode parentNode = getParentNodeInGenCode(curNode); | 119 | YangNode parentNode = getParentNodeInGenCode(curNode); |
120 | - if (!(parentNode instanceof HasJavaFileInfo)) { | 120 | + if (!(parentNode instanceof JavaFileInfoContainer)) { |
121 | throw new TranslatorException("missing parent java node to get current node's package"); | 121 | throw new TranslatorException("missing parent java node to get current node's package"); |
122 | } | 122 | } |
123 | - JavaFileInfo parentJavaFileHandle = ((HasJavaFileInfo) parentNode).getJavaFileInfo(); | 123 | + JavaFileInfo parentJavaFileHandle = ((JavaFileInfoContainer) parentNode).getJavaFileInfo(); |
124 | pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName(); | 124 | pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName(); |
125 | return pkg.toLowerCase(); | 125 | return pkg.toLowerCase(); |
126 | } | 126 | } | ... | ... |
... | @@ -21,7 +21,7 @@ import java.io.IOException; | ... | @@ -21,7 +21,7 @@ import java.io.IOException; |
21 | import java.util.List; | 21 | import java.util.List; |
22 | 22 | ||
23 | import org.onosproject.yangutils.datamodel.YangNode; | 23 | import org.onosproject.yangutils.datamodel.YangNode; |
24 | -import org.onosproject.yangutils.translator.tojava.HasJavaImportData; | 24 | +import org.onosproject.yangutils.translator.tojava.JavaImportDataContainer; |
25 | 25 | ||
26 | import static org.onosproject.yangutils.translator.tojava.JavaImportData.getAugmentedInfoImport; | 26 | import static org.onosproject.yangutils.translator.tojava.JavaImportData.getAugmentedInfoImport; |
27 | import static org.onosproject.yangutils.translator.tojava.JavaImportData.getHasAugmentationImport; | 27 | import static org.onosproject.yangutils.translator.tojava.JavaImportData.getHasAugmentationImport; |
... | @@ -52,9 +52,9 @@ public final class TempJavaCodeFragmentFilesUtils { | ... | @@ -52,9 +52,9 @@ public final class TempJavaCodeFragmentFilesUtils { |
52 | * @return import list | 52 | * @return import list |
53 | */ | 53 | */ |
54 | public static List<String> addImportsToStringAndHasCodeMethods(YangNode curNode, List<String> imports) { | 54 | public static List<String> addImportsToStringAndHasCodeMethods(YangNode curNode, List<String> imports) { |
55 | - if (curNode instanceof HasJavaImportData) { | 55 | + if (curNode instanceof JavaImportDataContainer) { |
56 | - imports.add(((HasJavaImportData) curNode).getJavaImportData().getImportForHashAndEquals()); | 56 | + imports.add(((JavaImportDataContainer) curNode).getJavaImportData().getImportForHashAndEquals()); |
57 | - imports.add(((HasJavaImportData) curNode).getJavaImportData().getImportForToString()); | 57 | + imports.add(((JavaImportDataContainer) curNode).getJavaImportData().getImportForToString()); |
58 | } | 58 | } |
59 | return imports; | 59 | return imports; |
60 | } | 60 | } |
... | @@ -68,7 +68,7 @@ public final class TempJavaCodeFragmentFilesUtils { | ... | @@ -68,7 +68,7 @@ public final class TempJavaCodeFragmentFilesUtils { |
68 | * @return import for HasAugmentation class | 68 | * @return import for HasAugmentation class |
69 | */ | 69 | */ |
70 | public static List<String> addHasAugmentationImport(YangNode curNode, List<String> imports, boolean operation) { | 70 | public static List<String> addHasAugmentationImport(YangNode curNode, List<String> imports, boolean operation) { |
71 | - if (curNode instanceof HasJavaImportData) { | 71 | + if (curNode instanceof JavaImportDataContainer) { |
72 | String thisImport = getHasAugmentationImport(); | 72 | String thisImport = getHasAugmentationImport(); |
73 | performOperationOnImports(imports, thisImport, operation); | 73 | performOperationOnImports(imports, thisImport, operation); |
74 | } | 74 | } |
... | @@ -84,7 +84,7 @@ public final class TempJavaCodeFragmentFilesUtils { | ... | @@ -84,7 +84,7 @@ public final class TempJavaCodeFragmentFilesUtils { |
84 | * @return import for AugmentedInfo class | 84 | * @return import for AugmentedInfo class |
85 | */ | 85 | */ |
86 | public static List<String> addAugmentedInfoImport(YangNode curNode, List<String> imports, boolean operation) { | 86 | public static List<String> addAugmentedInfoImport(YangNode curNode, List<String> imports, boolean operation) { |
87 | - if (curNode instanceof HasJavaImportData) { | 87 | + if (curNode instanceof JavaImportDataContainer) { |
88 | String thisImport = getAugmentedInfoImport(); | 88 | String thisImport = getAugmentedInfoImport(); |
89 | performOperationOnImports(imports, thisImport, operation); | 89 | performOperationOnImports(imports, thisImport, operation); |
90 | } | 90 | } |
... | @@ -100,7 +100,7 @@ public final class TempJavaCodeFragmentFilesUtils { | ... | @@ -100,7 +100,7 @@ public final class TempJavaCodeFragmentFilesUtils { |
100 | * @return import for HasAugmentation class | 100 | * @return import for HasAugmentation class |
101 | */ | 101 | */ |
102 | public static List<String> addArrayListImport(YangNode curNode, List<String> imports, boolean operation) { | 102 | public static List<String> addArrayListImport(YangNode curNode, List<String> imports, boolean operation) { |
103 | - if (curNode instanceof HasJavaImportData) { | 103 | + if (curNode instanceof JavaImportDataContainer) { |
104 | String arrayListImport = getImportForArrayList(); | 104 | String arrayListImport = getImportForArrayList(); |
105 | String listImport = getImportForList(); | 105 | String listImport = getImportForList(); |
106 | performOperationOnImports(imports, arrayListImport, operation); | 106 | performOperationOnImports(imports, arrayListImport, operation); | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -65,7 +65,7 @@ public class IntraFileTypeLinkingTest { | ... | @@ -65,7 +65,7 @@ public class IntraFileTypeLinkingTest { |
65 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); | 65 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); |
66 | YangLeaf leafInfo = leafIterator.next(); | 66 | YangLeaf leafInfo = leafIterator.next(); |
67 | 67 | ||
68 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 68 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
69 | assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); | 69 | assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); |
70 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 70 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
71 | 71 | ||
... | @@ -104,7 +104,7 @@ public class IntraFileTypeLinkingTest { | ... | @@ -104,7 +104,7 @@ public class IntraFileTypeLinkingTest { |
104 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 104 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
105 | YangLeaf leafInfo = leafIterator.next(); | 105 | YangLeaf leafInfo = leafIterator.next(); |
106 | 106 | ||
107 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 107 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
108 | assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); | 108 | assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); |
109 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 109 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
110 | 110 | ||
... | @@ -144,7 +144,7 @@ public class IntraFileTypeLinkingTest { | ... | @@ -144,7 +144,7 @@ public class IntraFileTypeLinkingTest { |
144 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 144 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
145 | YangLeaf leafInfo = leafIterator.next(); | 145 | YangLeaf leafInfo = leafIterator.next(); |
146 | 146 | ||
147 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 147 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
148 | assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); | 148 | assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); |
149 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 149 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
150 | 150 | ||
... | @@ -184,7 +184,7 @@ public class IntraFileTypeLinkingTest { | ... | @@ -184,7 +184,7 @@ public class IntraFileTypeLinkingTest { |
184 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 184 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
185 | YangLeaf leafInfo = leafIterator.next(); | 185 | YangLeaf leafInfo = leafIterator.next(); |
186 | 186 | ||
187 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 187 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
188 | assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); | 188 | assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); |
189 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 189 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
190 | 190 | ||
... | @@ -222,7 +222,7 @@ public class IntraFileTypeLinkingTest { | ... | @@ -222,7 +222,7 @@ public class IntraFileTypeLinkingTest { |
222 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 222 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
223 | YangLeaf leafInfo = leafIterator.next(); | 223 | YangLeaf leafInfo = leafIterator.next(); |
224 | 224 | ||
225 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 225 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
226 | assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); | 226 | assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); |
227 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 227 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
228 | 228 | ||
... | @@ -274,7 +274,7 @@ public class IntraFileTypeLinkingTest { | ... | @@ -274,7 +274,7 @@ public class IntraFileTypeLinkingTest { |
274 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 274 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
275 | YangLeaf leafInfo = leafIterator.next(); | 275 | YangLeaf leafInfo = leafIterator.next(); |
276 | 276 | ||
277 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 277 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
278 | assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); | 278 | assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); |
279 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 279 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
280 | 280 | ||
... | @@ -325,7 +325,7 @@ public class IntraFileTypeLinkingTest { | ... | @@ -325,7 +325,7 @@ public class IntraFileTypeLinkingTest { |
325 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 325 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
326 | YangLeaf leafInfo = leafIterator.next(); | 326 | YangLeaf leafInfo = leafIterator.next(); |
327 | 327 | ||
328 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 328 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
329 | assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); | 329 | assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); |
330 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 330 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
331 | 331 | ||
... | @@ -377,7 +377,7 @@ public class IntraFileTypeLinkingTest { | ... | @@ -377,7 +377,7 @@ public class IntraFileTypeLinkingTest { |
377 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 377 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
378 | YangLeaf leafInfo = leafIterator.next(); | 378 | YangLeaf leafInfo = leafIterator.next(); |
379 | 379 | ||
380 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 380 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
381 | assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); | 381 | assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); |
382 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 382 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
383 | 383 | ... | ... |
... | @@ -80,7 +80,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -80,7 +80,7 @@ public class IntraFileUsesLinkingTest { |
80 | leafInfo = leafIterator.next(); | 80 | leafInfo = leafIterator.next(); |
81 | 81 | ||
82 | // Check whether the information in the leaf is correct under grouping. | 82 | // Check whether the information in the leaf is correct under grouping. |
83 | - assertThat(leafInfo.getLeafName(), is("hello")); | 83 | + assertThat(leafInfo.getName(), is("hello")); |
84 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); | 84 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); |
85 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 85 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
86 | 86 | ||
... | @@ -96,7 +96,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -96,7 +96,7 @@ public class IntraFileUsesLinkingTest { |
96 | leafInfo = leafIterator.next(); | 96 | leafInfo = leafIterator.next(); |
97 | 97 | ||
98 | // Check whether the information in the leaf is correct under module. | 98 | // Check whether the information in the leaf is correct under module. |
99 | - assertThat(leafInfo.getLeafName(), is("hello")); | 99 | + assertThat(leafInfo.getName(), is("hello")); |
100 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); | 100 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); |
101 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 101 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
102 | 102 | ||
... | @@ -134,7 +134,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -134,7 +134,7 @@ public class IntraFileUsesLinkingTest { |
134 | leafInfo = leafIterator.next(); | 134 | leafInfo = leafIterator.next(); |
135 | 135 | ||
136 | // Check whether the information in the leaf is correct under grouping. | 136 | // Check whether the information in the leaf is correct under grouping. |
137 | - assertThat(leafInfo.getLeafName(), is("treat")); | 137 | + assertThat(leafInfo.getName(), is("treat")); |
138 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); | 138 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); |
139 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 139 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
140 | 140 | ||
... | @@ -149,7 +149,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -149,7 +149,7 @@ public class IntraFileUsesLinkingTest { |
149 | leafInfo = leafIterator.next(); | 149 | leafInfo = leafIterator.next(); |
150 | 150 | ||
151 | // Check whether the information in the leaf is correct under container which is under grouping. | 151 | // Check whether the information in the leaf is correct under container which is under grouping. |
152 | - assertThat(leafInfo.getLeafName(), is("leaf2")); | 152 | + assertThat(leafInfo.getName(), is("leaf2")); |
153 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); | 153 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); |
154 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 154 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
155 | 155 | ||
... | @@ -165,7 +165,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -165,7 +165,7 @@ public class IntraFileUsesLinkingTest { |
165 | leafInfo = leafIterator.next(); | 165 | leafInfo = leafIterator.next(); |
166 | 166 | ||
167 | // Check whether the information in the leaf is correct under module. | 167 | // Check whether the information in the leaf is correct under module. |
168 | - assertThat(leafInfo.getLeafName(), is("treat")); | 168 | + assertThat(leafInfo.getName(), is("treat")); |
169 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); | 169 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); |
170 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 170 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
171 | 171 | ||
... | @@ -180,7 +180,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -180,7 +180,7 @@ public class IntraFileUsesLinkingTest { |
180 | leafInfo = leafIterator.next(); | 180 | leafInfo = leafIterator.next(); |
181 | 181 | ||
182 | // Check whether the information in the leaf is correct under container which is under module. | 182 | // Check whether the information in the leaf is correct under container which is under module. |
183 | - assertThat(leafInfo.getLeafName(), is("leaf2")); | 183 | + assertThat(leafInfo.getName(), is("leaf2")); |
184 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); | 184 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); |
185 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 185 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
186 | } | 186 | } |
... | @@ -227,7 +227,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -227,7 +227,7 @@ public class IntraFileUsesLinkingTest { |
227 | leafInfo = leafIterator.next(); | 227 | leafInfo = leafIterator.next(); |
228 | 228 | ||
229 | // Check whether the information in the leaf is correct under list which is under grouping. | 229 | // Check whether the information in the leaf is correct under list which is under grouping. |
230 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 230 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
231 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 231 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
232 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 232 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
233 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 233 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -253,7 +253,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -253,7 +253,7 @@ public class IntraFileUsesLinkingTest { |
253 | leafInfo = leafIterator.next(); | 253 | leafInfo = leafIterator.next(); |
254 | 254 | ||
255 | // Check whether the information in the leaf is correct under list which is deep copied. | 255 | // Check whether the information in the leaf is correct under list which is deep copied. |
256 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 256 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
257 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 257 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
258 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 258 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
259 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 259 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -282,7 +282,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -282,7 +282,7 @@ public class IntraFileUsesLinkingTest { |
282 | leafInfo = leafIterator.next(); | 282 | leafInfo = leafIterator.next(); |
283 | 283 | ||
284 | // Check whether the information in the leaf is correct under list which is deep copied. | 284 | // Check whether the information in the leaf is correct under list which is deep copied. |
285 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 285 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
286 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 286 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
287 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 287 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
288 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 288 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -353,7 +353,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -353,7 +353,7 @@ public class IntraFileUsesLinkingTest { |
353 | leafInfo = leafIterator.next(); | 353 | leafInfo = leafIterator.next(); |
354 | 354 | ||
355 | // Check whether the information in the leaf is correct under design-container. | 355 | // Check whether the information in the leaf is correct under design-container. |
356 | - assertThat(leafInfo.getLeafName(), is("ink")); | 356 | + assertThat(leafInfo.getName(), is("ink")); |
357 | assertThat(leafInfo.getDataType().getDataTypeName(), is("int32")); | 357 | assertThat(leafInfo.getDataType().getDataTypeName(), is("int32")); |
358 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32)); | 358 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32)); |
359 | 359 | ||
... | @@ -374,7 +374,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -374,7 +374,7 @@ public class IntraFileUsesLinkingTest { |
374 | leafInfo = leafIterator.next(); | 374 | leafInfo = leafIterator.next(); |
375 | 375 | ||
376 | // Check whether the information in the leaf is correct under correct-container. | 376 | // Check whether the information in the leaf is correct under correct-container. |
377 | - assertThat(leafInfo.getLeafName(), is("newone")); | 377 | + assertThat(leafInfo.getName(), is("newone")); |
378 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 378 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); |
379 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 379 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
380 | 380 | ||
... | @@ -397,7 +397,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -397,7 +397,7 @@ public class IntraFileUsesLinkingTest { |
397 | 397 | ||
398 | // Check whether the information in the leaf is correct under container | 398 | // Check whether the information in the leaf is correct under container |
399 | // which has been deep copied from grouping. | 399 | // which has been deep copied from grouping. |
400 | - assertThat(leafInfo.getLeafName(), is("zip-code")); | 400 | + assertThat(leafInfo.getName(), is("zip-code")); |
401 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 401 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); |
402 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 402 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
403 | 403 | ||
... | @@ -426,7 +426,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -426,7 +426,7 @@ public class IntraFileUsesLinkingTest { |
426 | leafInfo = leafIterator.next(); | 426 | leafInfo = leafIterator.next(); |
427 | 427 | ||
428 | // Check whether the information in the leaf is correct under list which has been deep copied from grouping. | 428 | // Check whether the information in the leaf is correct under list which has been deep copied from grouping. |
429 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 429 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
430 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 430 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
431 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 431 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
432 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 432 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -441,7 +441,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -441,7 +441,7 @@ public class IntraFileUsesLinkingTest { |
441 | leafInfo = leafIterator.next(); | 441 | leafInfo = leafIterator.next(); |
442 | 442 | ||
443 | // Check whether the information in the leaf is correct under grouping. | 443 | // Check whether the information in the leaf is correct under grouping. |
444 | - assertThat(leafInfo.getLeafName(), is("zip-code")); | 444 | + assertThat(leafInfo.getName(), is("zip-code")); |
445 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 445 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); |
446 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 446 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
447 | 447 | ||
... | @@ -517,7 +517,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -517,7 +517,7 @@ public class IntraFileUsesLinkingTest { |
517 | leafInfo = leafIterator.next(); | 517 | leafInfo = leafIterator.next(); |
518 | 518 | ||
519 | // Check whether the information in the leaf is correct under grouping. | 519 | // Check whether the information in the leaf is correct under grouping. |
520 | - assertThat(leafInfo.getLeafName(), is("carry")); | 520 | + assertThat(leafInfo.getName(), is("carry")); |
521 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 521 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); |
522 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 522 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
523 | 523 | ||
... | @@ -550,7 +550,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -550,7 +550,7 @@ public class IntraFileUsesLinkingTest { |
550 | leafInfo = leafIterator.next(); | 550 | leafInfo = leafIterator.next(); |
551 | 551 | ||
552 | // Check whether the information in the leaf is correct under list. | 552 | // Check whether the information in the leaf is correct under list. |
553 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 553 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
554 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 554 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
555 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 555 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
556 | } | 556 | } |
... | @@ -687,7 +687,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -687,7 +687,7 @@ public class IntraFileUsesLinkingTest { |
687 | leafInfo = leafIterator.next(); | 687 | leafInfo = leafIterator.next(); |
688 | 688 | ||
689 | // Check whether the information in the leaf is correct under grouping. | 689 | // Check whether the information in the leaf is correct under grouping. |
690 | - assertThat(leafInfo.getLeafName(), is("hello")); | 690 | + assertThat(leafInfo.getName(), is("hello")); |
691 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); | 691 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); |
692 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 692 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
693 | 693 | ||
... | @@ -761,7 +761,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -761,7 +761,7 @@ public class IntraFileUsesLinkingTest { |
761 | leafInfo = leafIterator.next(); | 761 | leafInfo = leafIterator.next(); |
762 | 762 | ||
763 | // Check whether the information in the leaf is correct under grouping. | 763 | // Check whether the information in the leaf is correct under grouping. |
764 | - assertThat(leafInfo.getLeafName(), is("hello")); | 764 | + assertThat(leafInfo.getName(), is("hello")); |
765 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); | 765 | assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); |
766 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 766 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
767 | } | 767 | } | ... | ... |
... | @@ -62,7 +62,7 @@ public class AugmentListenerTest { | ... | @@ -62,7 +62,7 @@ public class AugmentListenerTest { |
62 | ListIterator<YangLeaf> leafIterator = yangAugment.getListOfLeaf().listIterator(); | 62 | ListIterator<YangLeaf> leafIterator = yangAugment.getListOfLeaf().listIterator(); |
63 | YangLeaf leafInfo = leafIterator.next(); | 63 | YangLeaf leafInfo = leafIterator.next(); |
64 | 64 | ||
65 | - assertThat(leafInfo.getLeafName(), is("ds0ChannelNumber")); | 65 | + assertThat(leafInfo.getName(), is("ds0ChannelNumber")); |
66 | assertThat(leafInfo.getDataType().getDataTypeName(), is("ChannelNumber")); | 66 | assertThat(leafInfo.getDataType().getDataTypeName(), is("ChannelNumber")); |
67 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 67 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
68 | } | 68 | } | ... | ... |
... | @@ -61,7 +61,7 @@ public class BitListenerTest { | ... | @@ -61,7 +61,7 @@ public class BitListenerTest { |
61 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); | 61 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); |
62 | YangLeaf leafInfo = leafIterator.next(); | 62 | YangLeaf leafInfo = leafIterator.next(); |
63 | 63 | ||
64 | - assertThat(leafInfo.getLeafName(), is("mybits")); | 64 | + assertThat(leafInfo.getName(), is("mybits")); |
65 | assertThat(leafInfo.getDataType().getDataTypeName(), is("bits")); | 65 | assertThat(leafInfo.getDataType().getDataTypeName(), is("bits")); |
66 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.BITS)); | 66 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.BITS)); |
67 | assertThat(((YangBits) leafInfo.getDataType().getDataTypeExtendedInfo()).getBitsName(), | 67 | assertThat(((YangBits) leafInfo.getDataType().getDataTypeExtendedInfo()).getBitsName(), | ... | ... |
... | @@ -70,7 +70,7 @@ public class CaseListenerTest { | ... | @@ -70,7 +70,7 @@ public class CaseListenerTest { |
70 | ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator(); | 70 | ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator(); |
71 | YangLeaf leafInfo1 = leafIterator1.next(); | 71 | YangLeaf leafInfo1 = leafIterator1.next(); |
72 | 72 | ||
73 | - assertThat(leafInfo1.getLeafName(), is("pretzel")); | 73 | + assertThat(leafInfo1.getName(), is("pretzel")); |
74 | 74 | ||
75 | YangCase yangCase2 = (YangCase) yangCase1.getNextSibling(); | 75 | YangCase yangCase2 = (YangCase) yangCase1.getNextSibling(); |
76 | assertThat(yangCase2.getName(), is("late-night")); | 76 | assertThat(yangCase2.getName(), is("late-night")); |
... | @@ -79,7 +79,7 @@ public class CaseListenerTest { | ... | @@ -79,7 +79,7 @@ public class CaseListenerTest { |
79 | ListIterator<YangLeaf> leafIterator2 = yangCase2.getListOfLeaf().listIterator(); | 79 | ListIterator<YangLeaf> leafIterator2 = yangCase2.getListOfLeaf().listIterator(); |
80 | YangLeaf leafInfo2 = leafIterator2.next(); | 80 | YangLeaf leafInfo2 = leafIterator2.next(); |
81 | 81 | ||
82 | - assertThat(leafInfo2.getLeafName(), is("chocolate")); | 82 | + assertThat(leafInfo2.getName(), is("chocolate")); |
83 | } | 83 | } |
84 | 84 | ||
85 | /** | 85 | /** |
... | @@ -140,7 +140,7 @@ public class CaseListenerTest { | ... | @@ -140,7 +140,7 @@ public class CaseListenerTest { |
140 | ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator(); | 140 | ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator(); |
141 | YangLeaf leafInfo1 = leafIterator1.next(); | 141 | YangLeaf leafInfo1 = leafIterator1.next(); |
142 | 142 | ||
143 | - assertThat(leafInfo1.getLeafName(), is("pretzel")); | 143 | + assertThat(leafInfo1.getName(), is("pretzel")); |
144 | 144 | ||
145 | YangChoice yangChoice2 = (YangChoice) yangChoice.getNextSibling(); | 145 | YangChoice yangChoice2 = (YangChoice) yangChoice.getNextSibling(); |
146 | assertThat(yangChoice2.getName(), is("lunch")); | 146 | assertThat(yangChoice2.getName(), is("lunch")); |
... | @@ -152,7 +152,7 @@ public class CaseListenerTest { | ... | @@ -152,7 +152,7 @@ public class CaseListenerTest { |
152 | ListIterator<YangLeaf> leafIterator2 = yangCase2.getListOfLeaf().listIterator(); | 152 | ListIterator<YangLeaf> leafIterator2 = yangCase2.getListOfLeaf().listIterator(); |
153 | YangLeaf leafInfo2 = leafIterator2.next(); | 153 | YangLeaf leafInfo2 = leafIterator2.next(); |
154 | 154 | ||
155 | - assertThat(leafInfo2.getLeafName(), is("chocolate")); | 155 | + assertThat(leafInfo2.getName(), is("chocolate")); |
156 | } | 156 | } |
157 | 157 | ||
158 | /** | 158 | /** |
... | @@ -186,7 +186,7 @@ public class CaseListenerTest { | ... | @@ -186,7 +186,7 @@ public class CaseListenerTest { |
186 | ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator(); | 186 | ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator(); |
187 | YangLeaf leafInfo1 = leafIterator1.next(); | 187 | YangLeaf leafInfo1 = leafIterator1.next(); |
188 | 188 | ||
189 | - assertThat(leafInfo1.getLeafName(), is("pretzel")); | 189 | + assertThat(leafInfo1.getName(), is("pretzel")); |
190 | 190 | ||
191 | YangCase yangCase2 = (YangCase) yangCase1.getNextSibling(); | 191 | YangCase yangCase2 = (YangCase) yangCase1.getNextSibling(); |
192 | assertThat(yangCase2.getName(), is("late-night")); | 192 | assertThat(yangCase2.getName(), is("late-night")); |
... | @@ -200,6 +200,6 @@ public class CaseListenerTest { | ... | @@ -200,6 +200,6 @@ public class CaseListenerTest { |
200 | // Check whether leaf properties as set correctly. | 200 | // Check whether leaf properties as set correctly. |
201 | ListIterator<YangLeaf> leafIterator2 = yangCase3.getListOfLeaf().listIterator(); | 201 | ListIterator<YangLeaf> leafIterator2 = yangCase3.getListOfLeaf().listIterator(); |
202 | YangLeaf leafInfo2 = leafIterator2.next(); | 202 | YangLeaf leafInfo2 = leafIterator2.next(); |
203 | - assertThat(leafInfo2.getLeafName(), is("beer")); | 203 | + assertThat(leafInfo2.getName(), is("beer")); |
204 | } | 204 | } |
205 | } | 205 | } | ... | ... |
... | @@ -68,7 +68,7 @@ public class ConfigListenerTest { | ... | @@ -68,7 +68,7 @@ public class ConfigListenerTest { |
68 | YangLeaf leafInfo = leafIterator.next(); | 68 | YangLeaf leafInfo = leafIterator.next(); |
69 | 69 | ||
70 | // Check whether the Config value is set correctly. | 70 | // Check whether the Config value is set correctly. |
71 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 71 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
72 | assertThat(leafInfo.isConfig(), is(true)); | 72 | assertThat(leafInfo.isConfig(), is(true)); |
73 | } | 73 | } |
74 | 74 | ||
... | @@ -94,7 +94,7 @@ public class ConfigListenerTest { | ... | @@ -94,7 +94,7 @@ public class ConfigListenerTest { |
94 | YangLeaf leafInfo = leafIterator.next(); | 94 | YangLeaf leafInfo = leafIterator.next(); |
95 | 95 | ||
96 | // Check whether the Config value is set correctly. | 96 | // Check whether the Config value is set correctly. |
97 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 97 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
98 | assertThat(leafInfo.isConfig(), is(false)); | 98 | assertThat(leafInfo.isConfig(), is(false)); |
99 | } | 99 | } |
100 | 100 | ||
... | @@ -168,7 +168,7 @@ public class ConfigListenerTest { | ... | @@ -168,7 +168,7 @@ public class ConfigListenerTest { |
168 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); | 168 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); |
169 | YangLeaf leafInfo = leafIterator.next(); | 169 | YangLeaf leafInfo = leafIterator.next(); |
170 | 170 | ||
171 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 171 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
172 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 172 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
173 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 173 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
174 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 174 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -204,7 +204,7 @@ public class ConfigListenerTest { | ... | @@ -204,7 +204,7 @@ public class ConfigListenerTest { |
204 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 204 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
205 | YangLeaf leafInfo = leafIterator.next(); | 205 | YangLeaf leafInfo = leafIterator.next(); |
206 | 206 | ||
207 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 207 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
208 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 208 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
209 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 209 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
210 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 210 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -236,7 +236,7 @@ public class ConfigListenerTest { | ... | @@ -236,7 +236,7 @@ public class ConfigListenerTest { |
236 | YangLeafList leafListInfo = leafListIterator.next(); | 236 | YangLeafList leafListInfo = leafListIterator.next(); |
237 | 237 | ||
238 | // Check whether config value is set correctly. | 238 | // Check whether config value is set correctly. |
239 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 239 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
240 | assertThat(leafListInfo.isConfig(), is(true)); | 240 | assertThat(leafListInfo.isConfig(), is(true)); |
241 | } | 241 | } |
242 | 242 | ||
... | @@ -262,7 +262,7 @@ public class ConfigListenerTest { | ... | @@ -262,7 +262,7 @@ public class ConfigListenerTest { |
262 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); | 262 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); |
263 | YangLeaf leafInfo = leafIterator.next(); | 263 | YangLeaf leafInfo = leafIterator.next(); |
264 | 264 | ||
265 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 265 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
266 | assertThat(leafInfo.isConfig(), is(true)); | 266 | assertThat(leafInfo.isConfig(), is(true)); |
267 | } | 267 | } |
268 | 268 | ||
... | @@ -367,7 +367,7 @@ public class ConfigListenerTest { | ... | @@ -367,7 +367,7 @@ public class ConfigListenerTest { |
367 | YangLeafList leafListInfo = leafListIterator.next(); | 367 | YangLeafList leafListInfo = leafListIterator.next(); |
368 | 368 | ||
369 | // Check whether config value is set correctly. | 369 | // Check whether config value is set correctly. |
370 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 370 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
371 | assertThat(leafListInfo.isConfig(), is(true)); | 371 | assertThat(leafListInfo.isConfig(), is(true)); |
372 | 372 | ||
373 | } | 373 | } |
... | @@ -395,7 +395,7 @@ public class ConfigListenerTest { | ... | @@ -395,7 +395,7 @@ public class ConfigListenerTest { |
395 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); | 395 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); |
396 | YangLeaf leafInfo = leafIterator.next(); | 396 | YangLeaf leafInfo = leafIterator.next(); |
397 | 397 | ||
398 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 398 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
399 | assertThat(leafInfo.isConfig(), is(true)); | 399 | assertThat(leafInfo.isConfig(), is(true)); |
400 | } | 400 | } |
401 | 401 | ||
... | @@ -475,7 +475,7 @@ public class ConfigListenerTest { | ... | @@ -475,7 +475,7 @@ public class ConfigListenerTest { |
475 | YangLeafList leafListInfo = leafListIterator.next(); | 475 | YangLeafList leafListInfo = leafListIterator.next(); |
476 | 476 | ||
477 | // Check whether config value is set correctly. | 477 | // Check whether config value is set correctly. |
478 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 478 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
479 | assertThat(leafListInfo.isConfig(), is(true)); | 479 | assertThat(leafListInfo.isConfig(), is(true)); |
480 | } | 480 | } |
481 | 481 | ||
... | @@ -502,7 +502,7 @@ public class ConfigListenerTest { | ... | @@ -502,7 +502,7 @@ public class ConfigListenerTest { |
502 | ListIterator<YangLeaf> leafIterator = list1.getListOfLeaf().listIterator(); | 502 | ListIterator<YangLeaf> leafIterator = list1.getListOfLeaf().listIterator(); |
503 | YangLeaf leafInfo = leafIterator.next(); | 503 | YangLeaf leafInfo = leafIterator.next(); |
504 | 504 | ||
505 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 505 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
506 | assertThat(leafInfo.isConfig(), is(true)); | 506 | assertThat(leafInfo.isConfig(), is(true)); |
507 | } | 507 | } |
508 | 508 | ... | ... |
... | @@ -192,7 +192,7 @@ public class ContainerListenerTest { | ... | @@ -192,7 +192,7 @@ public class ContainerListenerTest { |
192 | ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator(); | 192 | ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator(); |
193 | YangLeaf leafInfo = leafIterator.next(); | 193 | YangLeaf leafInfo = leafIterator.next(); |
194 | 194 | ||
195 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 195 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
196 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 196 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
197 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 197 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
198 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 198 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | ... | ... |
... | @@ -68,7 +68,7 @@ public class DescriptionListenerTest { | ... | @@ -68,7 +68,7 @@ public class DescriptionListenerTest { |
68 | YangLeaf leafInfo = leafIterator.next(); | 68 | YangLeaf leafInfo = leafIterator.next(); |
69 | 69 | ||
70 | // Check whether the description is set correctly. | 70 | // Check whether the description is set correctly. |
71 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 71 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
72 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 72 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
73 | } | 73 | } |
74 | 74 | ||
... | @@ -176,7 +176,7 @@ public class DescriptionListenerTest { | ... | @@ -176,7 +176,7 @@ public class DescriptionListenerTest { |
176 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); | 176 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); |
177 | YangLeaf leafInfo = leafIterator.next(); | 177 | YangLeaf leafInfo = leafIterator.next(); |
178 | 178 | ||
179 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 179 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
180 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 180 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
181 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 181 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
182 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 182 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -213,7 +213,7 @@ public class DescriptionListenerTest { | ... | @@ -213,7 +213,7 @@ public class DescriptionListenerTest { |
213 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 213 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
214 | YangLeaf leafInfo = leafIterator.next(); | 214 | YangLeaf leafInfo = leafIterator.next(); |
215 | 215 | ||
216 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 216 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
217 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 217 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
218 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 218 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
219 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 219 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -245,7 +245,7 @@ public class DescriptionListenerTest { | ... | @@ -245,7 +245,7 @@ public class DescriptionListenerTest { |
245 | YangLeafList leafListInfo = leafListIterator.next(); | 245 | YangLeafList leafListInfo = leafListIterator.next(); |
246 | 246 | ||
247 | // Check whether description value is set correctly. | 247 | // Check whether description value is set correctly. |
248 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 248 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
249 | assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 249 | assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
250 | } | 250 | } |
251 | } | 251 | } | ... | ... |
... | @@ -61,7 +61,7 @@ public class EnumListenerTest { | ... | @@ -61,7 +61,7 @@ public class EnumListenerTest { |
61 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); | 61 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); |
62 | YangLeaf leafInfo = leafIterator.next(); | 62 | YangLeaf leafInfo = leafIterator.next(); |
63 | 63 | ||
64 | - assertThat(leafInfo.getLeafName(), is("speed")); | 64 | + assertThat(leafInfo.getName(), is("speed")); |
65 | assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration")); | 65 | assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration")); |
66 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION)); | 66 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION)); |
67 | assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(), | 67 | assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(), | ... | ... |
... | @@ -64,7 +64,7 @@ public class GroupingListenerTest { | ... | @@ -64,7 +64,7 @@ public class GroupingListenerTest { |
64 | ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator(); | 64 | ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator(); |
65 | YangLeaf leafInfo = leafIterator.next(); | 65 | YangLeaf leafInfo = leafIterator.next(); |
66 | 66 | ||
67 | - assertThat(leafInfo.getLeafName(), is("address")); | 67 | + assertThat(leafInfo.getName(), is("address")); |
68 | } | 68 | } |
69 | 69 | ||
70 | /** | 70 | /** |
... | @@ -94,7 +94,7 @@ public class GroupingListenerTest { | ... | @@ -94,7 +94,7 @@ public class GroupingListenerTest { |
94 | ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator(); | 94 | ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator(); |
95 | YangLeaf leafInfo = leafIterator.next(); | 95 | YangLeaf leafInfo = leafIterator.next(); |
96 | 96 | ||
97 | - assertThat(leafInfo.getLeafName(), is("address")); | 97 | + assertThat(leafInfo.getName(), is("address")); |
98 | } | 98 | } |
99 | 99 | ||
100 | /** | 100 | /** |
... | @@ -124,7 +124,7 @@ public class GroupingListenerTest { | ... | @@ -124,7 +124,7 @@ public class GroupingListenerTest { |
124 | ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator(); | 124 | ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator(); |
125 | YangLeaf leafInfo = leafIterator.next(); | 125 | YangLeaf leafInfo = leafIterator.next(); |
126 | 126 | ||
127 | - assertThat(leafInfo.getLeafName(), is("address")); | 127 | + assertThat(leafInfo.getName(), is("address")); |
128 | } | 128 | } |
129 | 129 | ||
130 | /** | 130 | /** |
... | @@ -157,7 +157,7 @@ public class GroupingListenerTest { | ... | @@ -157,7 +157,7 @@ public class GroupingListenerTest { |
157 | ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator(); | 157 | ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator(); |
158 | YangLeaf leafInfo = leafIterator.next(); | 158 | YangLeaf leafInfo = leafIterator.next(); |
159 | 159 | ||
160 | - assertThat(leafInfo.getLeafName(), is("address")); | 160 | + assertThat(leafInfo.getName(), is("address")); |
161 | } | 161 | } |
162 | 162 | ||
163 | /** | 163 | /** | ... | ... |
utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
... | @@ -65,7 +65,7 @@ public class InputListenerTest { | ... | @@ -65,7 +65,7 @@ public class InputListenerTest { |
65 | ListIterator<YangLeaf> leafIterator = yangInput.getListOfLeaf().listIterator(); | 65 | ListIterator<YangLeaf> leafIterator = yangInput.getListOfLeaf().listIterator(); |
66 | YangLeaf leafInfo = leafIterator.next(); | 66 | YangLeaf leafInfo = leafIterator.next(); |
67 | 67 | ||
68 | - assertThat(leafInfo.getLeafName(), is("image-name")); | 68 | + assertThat(leafInfo.getName(), is("image-name")); |
69 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 69 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); |
70 | 70 | ||
71 | YangList yangList = (YangList) yangInput.getChild(); | 71 | YangList yangList = (YangList) yangInput.getChild(); |
... | @@ -76,7 +76,7 @@ public class InputListenerTest { | ... | @@ -76,7 +76,7 @@ public class InputListenerTest { |
76 | assertThat(yangList.getMinElements(), is(3)); | 76 | assertThat(yangList.getMinElements(), is(3)); |
77 | leafIterator = yangList.getListOfLeaf().listIterator(); | 77 | leafIterator = yangList.getListOfLeaf().listIterator(); |
78 | leafInfo = leafIterator.next(); | 78 | leafInfo = leafIterator.next(); |
79 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 79 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
80 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 80 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
81 | 81 | ||
82 | YangContainer yangContainer = (YangContainer) yangList.getNextSibling(); | 82 | YangContainer yangContainer = (YangContainer) yangList.getNextSibling(); |
... | @@ -84,7 +84,7 @@ public class InputListenerTest { | ... | @@ -84,7 +84,7 @@ public class InputListenerTest { |
84 | 84 | ||
85 | leafIterator = yangContainer.getListOfLeaf().listIterator(); | 85 | leafIterator = yangContainer.getListOfLeaf().listIterator(); |
86 | leafInfo = leafIterator.next(); | 86 | leafInfo = leafIterator.next(); |
87 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 87 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
88 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 88 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
89 | } | 89 | } |
90 | 90 | ... | ... |
... | @@ -66,7 +66,7 @@ public class LeafListListenerTest { | ... | @@ -66,7 +66,7 @@ public class LeafListListenerTest { |
66 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 66 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
67 | YangLeafList leafListInfo = leafListIterator.next(); | 67 | YangLeafList leafListInfo = leafListIterator.next(); |
68 | 68 | ||
69 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 69 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
70 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); | 70 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); |
71 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 71 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
72 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); | 72 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); |
... | @@ -161,7 +161,7 @@ public class LeafListListenerTest { | ... | @@ -161,7 +161,7 @@ public class LeafListListenerTest { |
161 | ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator(); | 161 | ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator(); |
162 | YangLeafList leafListInfo = leafListIterator.next(); | 162 | YangLeafList leafListInfo = leafListIterator.next(); |
163 | 163 | ||
164 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 164 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
165 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); | 165 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); |
166 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 166 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
167 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); | 167 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); |
... | @@ -198,7 +198,7 @@ public class LeafListListenerTest { | ... | @@ -198,7 +198,7 @@ public class LeafListListenerTest { |
198 | ListIterator<YangLeafList> leafListIterator = yangList.getListOfLeafList().listIterator(); | 198 | ListIterator<YangLeafList> leafListIterator = yangList.getListOfLeafList().listIterator(); |
199 | YangLeafList leafListInfo = leafListIterator.next(); | 199 | YangLeafList leafListInfo = leafListIterator.next(); |
200 | 200 | ||
201 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 201 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
202 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); | 202 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); |
203 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 203 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
204 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); | 204 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); | ... | ... |
... | @@ -67,7 +67,7 @@ public class LeafListenerTest { | ... | @@ -67,7 +67,7 @@ public class LeafListenerTest { |
67 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); | 67 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); |
68 | YangLeaf leafInfo = leafIterator.next(); | 68 | YangLeaf leafInfo = leafIterator.next(); |
69 | 69 | ||
70 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 70 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
71 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 71 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
72 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 72 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
73 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 73 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -161,7 +161,7 @@ public class LeafListenerTest { | ... | @@ -161,7 +161,7 @@ public class LeafListenerTest { |
161 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); | 161 | ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator(); |
162 | YangLeaf leafInfo = leafIterator.next(); | 162 | YangLeaf leafInfo = leafIterator.next(); |
163 | 163 | ||
164 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 164 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
165 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 165 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
166 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 166 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
167 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 167 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
... | @@ -224,7 +224,7 @@ public class LeafListenerTest { | ... | @@ -224,7 +224,7 @@ public class LeafListenerTest { |
224 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 224 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
225 | YangLeaf leafInfo = leafIterator.next(); | 225 | YangLeaf leafInfo = leafIterator.next(); |
226 | 226 | ||
227 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 227 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
228 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 228 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
229 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 229 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
230 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 230 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | ... | ... |
... | @@ -67,7 +67,7 @@ public class LengthRestrictionListenerTest { | ... | @@ -67,7 +67,7 @@ public class LengthRestrictionListenerTest { |
67 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); | 67 | ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); |
68 | YangLeaf leafInfo = leafIterator.next(); | 68 | YangLeaf leafInfo = leafIterator.next(); |
69 | 69 | ||
70 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 70 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
71 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 71 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); |
72 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 72 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
73 | YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo | 73 | YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo |
... | @@ -99,7 +99,7 @@ public class LengthRestrictionListenerTest { | ... | @@ -99,7 +99,7 @@ public class LengthRestrictionListenerTest { |
99 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 99 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
100 | YangLeafList leafListInfo = leafListIterator.next(); | 100 | YangLeafList leafListInfo = leafListIterator.next(); |
101 | 101 | ||
102 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 102 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
103 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("string")); | 103 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("string")); |
104 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 104 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
105 | YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo | 105 | YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo |
... | @@ -167,7 +167,7 @@ public class LengthRestrictionListenerTest { | ... | @@ -167,7 +167,7 @@ public class LengthRestrictionListenerTest { |
167 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 167 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
168 | YangLeafList leafListInfo = leafListIterator.next(); | 168 | YangLeafList leafListInfo = leafListIterator.next(); |
169 | 169 | ||
170 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 170 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
171 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("string")); | 171 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("string")); |
172 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 172 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
173 | YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo | 173 | YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo |
... | @@ -199,7 +199,7 @@ public class LengthRestrictionListenerTest { | ... | @@ -199,7 +199,7 @@ public class LengthRestrictionListenerTest { |
199 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 199 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
200 | YangLeafList leafListInfo = leafListIterator.next(); | 200 | YangLeafList leafListInfo = leafListIterator.next(); |
201 | 201 | ||
202 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 202 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
203 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("string")); | 203 | assertThat(leafListInfo.getDataType().getDataTypeName(), is("string")); |
204 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 204 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
205 | YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo | 205 | YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo | ... | ... |
... | @@ -161,7 +161,7 @@ public class ListListenerTest { | ... | @@ -161,7 +161,7 @@ public class ListListenerTest { |
161 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); | 161 | ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator(); |
162 | YangLeaf leafInfo = leafIterator.next(); | 162 | YangLeaf leafInfo = leafIterator.next(); |
163 | 163 | ||
164 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 164 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
165 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 165 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
166 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 166 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
167 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 167 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | ... | ... |
... | @@ -64,7 +64,7 @@ public class MandatoryListenerTest { | ... | @@ -64,7 +64,7 @@ public class MandatoryListenerTest { |
64 | YangLeaf leafInfo = leafIterator.next(); | 64 | YangLeaf leafInfo = leafIterator.next(); |
65 | 65 | ||
66 | // Check whether the mandatory value is set correctly. | 66 | // Check whether the mandatory value is set correctly. |
67 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 67 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
68 | assertThat(leafInfo.isMandatory(), is(true)); | 68 | assertThat(leafInfo.isMandatory(), is(true)); |
69 | } | 69 | } |
70 | 70 | ||
... | @@ -90,7 +90,7 @@ public class MandatoryListenerTest { | ... | @@ -90,7 +90,7 @@ public class MandatoryListenerTest { |
90 | YangLeaf leafInfo = leafIterator.next(); | 90 | YangLeaf leafInfo = leafIterator.next(); |
91 | 91 | ||
92 | // Check whether the mandatory value is set correctly. | 92 | // Check whether the mandatory value is set correctly. |
93 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 93 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
94 | assertThat(leafInfo.isMandatory(), is(false)); | 94 | assertThat(leafInfo.isMandatory(), is(false)); |
95 | } | 95 | } |
96 | 96 | ||
... | @@ -116,7 +116,7 @@ public class MandatoryListenerTest { | ... | @@ -116,7 +116,7 @@ public class MandatoryListenerTest { |
116 | YangLeaf leafInfo = leafIterator.next(); | 116 | YangLeaf leafInfo = leafIterator.next(); |
117 | 117 | ||
118 | // Check whether the mandatory value is set correctly. | 118 | // Check whether the mandatory value is set correctly. |
119 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 119 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
120 | assertThat(leafInfo.isMandatory(), is(false)); | 120 | assertThat(leafInfo.isMandatory(), is(false)); |
121 | } | 121 | } |
122 | 122 | ... | ... |
... | @@ -64,7 +64,7 @@ public class MaxElementsListenerTest { | ... | @@ -64,7 +64,7 @@ public class MaxElementsListenerTest { |
64 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 64 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
65 | YangLeafList leafListInfo = leafListIterator.next(); | 65 | YangLeafList leafListInfo = leafListIterator.next(); |
66 | 66 | ||
67 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 67 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
68 | assertThat(leafListInfo.getMaxElelements(), is(3)); | 68 | assertThat(leafListInfo.getMaxElelements(), is(3)); |
69 | } | 69 | } |
70 | 70 | ||
... | @@ -148,7 +148,7 @@ public class MaxElementsListenerTest { | ... | @@ -148,7 +148,7 @@ public class MaxElementsListenerTest { |
148 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 148 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
149 | YangLeafList leafListInfo = leafListIterator.next(); | 149 | YangLeafList leafListInfo = leafListIterator.next(); |
150 | 150 | ||
151 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 151 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
152 | assertThat(leafListInfo.getMaxElelements(), is(2147483647)); | 152 | assertThat(leafListInfo.getMaxElelements(), is(2147483647)); |
153 | } | 153 | } |
154 | 154 | ||
... | @@ -173,7 +173,7 @@ public class MaxElementsListenerTest { | ... | @@ -173,7 +173,7 @@ public class MaxElementsListenerTest { |
173 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 173 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
174 | YangLeafList leafListInfo = leafListIterator.next(); | 174 | YangLeafList leafListInfo = leafListIterator.next(); |
175 | 175 | ||
176 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 176 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
177 | assertThat(leafListInfo.getMaxElelements(), is(2147483647)); | 177 | assertThat(leafListInfo.getMaxElelements(), is(2147483647)); |
178 | } | 178 | } |
179 | } | 179 | } | ... | ... |
... | @@ -64,7 +64,7 @@ public class MinElementsListenerTest { | ... | @@ -64,7 +64,7 @@ public class MinElementsListenerTest { |
64 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 64 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
65 | YangLeafList leafListInfo = leafListIterator.next(); | 65 | YangLeafList leafListInfo = leafListIterator.next(); |
66 | 66 | ||
67 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 67 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
68 | assertThat(leafListInfo.getMinElements(), is(3)); | 68 | assertThat(leafListInfo.getMinElements(), is(3)); |
69 | } | 69 | } |
70 | 70 | ||
... | @@ -159,7 +159,7 @@ public class MinElementsListenerTest { | ... | @@ -159,7 +159,7 @@ public class MinElementsListenerTest { |
159 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); | 159 | ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator(); |
160 | YangLeafList leafListInfo = leafListIterator.next(); | 160 | YangLeafList leafListInfo = leafListIterator.next(); |
161 | 161 | ||
162 | - assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 162 | + assertThat(leafListInfo.getName(), is("invalid-interval")); |
163 | assertThat(leafListInfo.getMinElements(), is(0)); | 163 | assertThat(leafListInfo.getMinElements(), is(0)); |
164 | } | 164 | } |
165 | } | 165 | } | ... | ... |
... | @@ -65,7 +65,7 @@ public class NotificationListenerTest { | ... | @@ -65,7 +65,7 @@ public class NotificationListenerTest { |
65 | ListIterator<YangLeaf> leafIterator = yangNotification.getListOfLeaf().listIterator(); | 65 | ListIterator<YangLeaf> leafIterator = yangNotification.getListOfLeaf().listIterator(); |
66 | YangLeaf leafInfo = leafIterator.next(); | 66 | YangLeaf leafInfo = leafIterator.next(); |
67 | 67 | ||
68 | - assertThat(leafInfo.getLeafName(), is("if-name")); | 68 | + assertThat(leafInfo.getName(), is("if-name")); |
69 | assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref")); | 69 | assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref")); |
70 | } | 70 | } |
71 | } | 71 | } | ... | ... |
... | @@ -64,7 +64,7 @@ public class OutputListenerTest { | ... | @@ -64,7 +64,7 @@ public class OutputListenerTest { |
64 | ListIterator<YangLeaf> leafIterator = yangOutput.getListOfLeaf().listIterator(); | 64 | ListIterator<YangLeaf> leafIterator = yangOutput.getListOfLeaf().listIterator(); |
65 | YangLeaf leafInfo = leafIterator.next(); | 65 | YangLeaf leafInfo = leafIterator.next(); |
66 | 66 | ||
67 | - assertThat(leafInfo.getLeafName(), is("image-name")); | 67 | + assertThat(leafInfo.getName(), is("image-name")); |
68 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 68 | assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); |
69 | 69 | ||
70 | YangList yangList = (YangList) yangOutput.getChild(); | 70 | YangList yangList = (YangList) yangOutput.getChild(); |
... | @@ -75,7 +75,7 @@ public class OutputListenerTest { | ... | @@ -75,7 +75,7 @@ public class OutputListenerTest { |
75 | assertThat(yangList.getMinElements(), is(3)); | 75 | assertThat(yangList.getMinElements(), is(3)); |
76 | leafIterator = yangList.getListOfLeaf().listIterator(); | 76 | leafIterator = yangList.getListOfLeaf().listIterator(); |
77 | leafInfo = leafIterator.next(); | 77 | leafInfo = leafIterator.next(); |
78 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 78 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
79 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 79 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
80 | 80 | ||
81 | YangContainer yangContainer = (YangContainer) yangList.getNextSibling(); | 81 | YangContainer yangContainer = (YangContainer) yangList.getNextSibling(); |
... | @@ -83,7 +83,7 @@ public class OutputListenerTest { | ... | @@ -83,7 +83,7 @@ public class OutputListenerTest { |
83 | 83 | ||
84 | leafIterator = yangContainer.getListOfLeaf().listIterator(); | 84 | leafIterator = yangContainer.getListOfLeaf().listIterator(); |
85 | leafInfo = leafIterator.next(); | 85 | leafInfo = leafIterator.next(); |
86 | - assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 86 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
87 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 87 | assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
88 | } | 88 | } |
89 | 89 | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnionListenerTest.java
This diff is collapsed. Click to expand it.
utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
This diff is collapsed. Click to expand it.
utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ValueListenerTest.java
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment