blob: 1d7fb9a559ae6e3e0d3cab5ac5ecebbd4fbe5e15 [file] [log] [blame]
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +05303 *
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
17package org.onosproject.yangutils.datamodel;
18
19import java.util.Stack;
Bharat saraswald9822e92016-04-05 15:13:44 +053020
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053021import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053023import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED;
24import static org.onosproject.yangutils.datamodel.ResolvableStatus.LINKED;
25import static org.onosproject.yangutils.datamodel.ResolvableStatus.RESOLVED;
26import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED;
27
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053028/**
Bharat saraswald9822e92016-04-05 15:13:44 +053029 * Represents resolution object which will be resolved by linker.
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053030 *
31 * @param <T> type of resolution entity uses / type
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053032 */
33public class YangResolutionInfo<T> {
34
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053035 /**
36 * Information about the entity that needs to be resolved.
37 */
38 private YangEntityToResolveInfo<T> entityToResolveInfo;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053039
40 // Error Line number.
41 private int lineNumber;
42
43 // Error character position.
44 private int charPosition;
45
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053046 /*
Bharat saraswald9822e92016-04-05 15:13:44 +053047 * Stack for type/uses is maintained for hierarchical references, this is
48 * used during resolution.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053049 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053050 private Stack<YangEntityToResolveInfo<T>> partialResolvedStack;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053051
52 // Module/Sub-module prefix.
53 private String resolutionInfoRootNodePrefix;
54
55 /**
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053056 * It is private to ensure the overloaded method be invoked to create an
57 * object.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053058 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053059 @SuppressWarnings("unused")
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053060 private YangResolutionInfo() {
61
62 }
63
64 /**
65 * Creates a resolution information object with all the inputs.
66 *
67 * @param dataNode current parsable data node
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053068 * @param holderNode parent YANG node
69 * @param lineNumber error line number
70 * @param charPositionInLine error character position in line
71 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053072 public YangResolutionInfo(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) {
73 setEntityToResolveInfo(new YangEntityToResolveInfo<T>());
74 getEntityToResolveInfo().setEntityToResolve(dataNode);
75 getEntityToResolveInfo().setHolderOfEntityToResolve(holderNode);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053076 this.setLineNumber(lineNumber);
77 this.setCharPosition(charPositionInLine);
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053078 setPartialResolvedStack(new Stack<YangEntityToResolveInfo<T>>());
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053079 }
80
81 /**
82 * Resolve linking with all the ancestors node for a resolution info.
83 *
84 * @param resolutionInfoNodePrefix module/sub-module prefix
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053085 * @throws DataModelException DataModelException a violation of data model
86 * rules
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053087 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053088 public void resolveLinkingForResolutionInfo(String resolutionInfoNodePrefix)
89 throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053090
91 this.resolutionInfoRootNodePrefix = resolutionInfoNodePrefix;
92
93 // Current node to resolve, it can be a YANG type or YANG uses.
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053094 T entityToResolve = getEntityToResolveInfo().getEntityToResolve();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053095
96 // Check if linking is already done
97 if (entityToResolve instanceof Resolvable) {
98 Resolvable resolvable = (Resolvable) entityToResolve;
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053099 if (resolvable.getResolvableStatus() == RESOLVED) {
100 /**
101 * entity is already resolved, so nothing to do
102 */
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530103 return;
104 }
105 } else {
106 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
107 }
108
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530109 // Push the initial entity to resolve in stack.
110 addInPartialResolvedStack(getEntityToResolveInfo());
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530111
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530112 linkAndResolvePartialResolvedStack();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530113 }
114
115 /**
116 * Resolves linking with ancestors.
117 *
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530118 * @throws DataModelException a violation of data model rules
119 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530120 private void linkAndResolvePartialResolvedStack()
121 throws DataModelException {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530122
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530123 while (getPartialResolvedStack().size() != 0) {
124
125 // Current node to resolve, it can be a YANG type or YANG uses.
126 T entityToResolve = getCurrentEntityToResolveFromStack();
127 // Check if linking is already done
128 if (entityToResolve instanceof Resolvable) {
129
130 Resolvable resolvable = (Resolvable) entityToResolve;
131 switch (resolvable.getResolvableStatus()) {
132 case RESOLVED: {
133 /*
134 * If the entity is already resolved in the stack, then
135 * pop it and continue with the remaining stack elements
136 * to resolve
137 */
138 getPartialResolvedStack().pop();
139 break;
140 }
141
142 case LINKED: {
143 /*
144 * If the top of the stack is already linked then
145 * resolve the references and pop the entity and
146 * continue with remaining stack elements to resolve
147 */
148 resolveTopOfStack();
149 getPartialResolvedStack().pop();
150 break;
151 }
152
153 case INTRA_FILE_RESOLVED: {
154 /*
155 * TODO: this needs to be deleted, when inter-file
156 * resolution is implmeneted
157 */
158 getPartialResolvedStack().pop();
159 break;
160 }
161
162 case UNRESOLVED: {
163 linkTopOfStackReferenceUpdateStack();
164
165 if (resolvable.getResolvableStatus() == UNRESOLVED) {
166 // If current entity is still not resolved, then linking/resolution has failed.
167 DataModelException dataModelException =
168 new DataModelException("YANG file error: Unable to find base "
169 + "typedef/grouping for given type/uses");
170 dataModelException.setLine(getLineNumber());
171 dataModelException.setCharPosition(getCharPosition());
172 throw dataModelException;
173 }
174 break;
175 }
176 default: {
177 throw new DataModelException("Data Model Exception: Unsupported, linker state");
178 }
179
180 }
181
182 } else {
183 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530184 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530185
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530186 }
187
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530188 }
189
190 /**
191 * Resolve the current entity in the stack.
192 */
Vinod Kumar S427d2932016-04-20 13:02:58 +0530193 private void resolveTopOfStack()
194 throws DataModelException {
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530195 ((Resolvable) getCurrentEntityToResolveFromStack()).resolve();
196
197 if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus()
198 != INTRA_FILE_RESOLVED) {
199 // Sets the resolution status in inside the type/uses.
200 ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(RESOLVED);
201 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530202 }
203
204 /**
205 * Resolves linking for a node child and siblings.
206 *
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530207 * @throws DataModelException data model error
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530208 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530209 private void linkTopOfStackReferenceUpdateStack()
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530210 throws DataModelException {
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530211
212 if (!isSelfFileReference()) {
213 /*
214 * TODO: use mojo utilities to load the referred module/sub-module
215 * and get the reference to the corresponding referred entity
216 */
217
218 ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(INTRA_FILE_RESOLVED);
219 return;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530220 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530221
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530222 /**
223 * Try to resolve the top of the stack and update partial resolved stack
224 * if there is recursive references
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530225 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530226 YangNode potentialAncestorWithReferredNode = getPartialResolvedStack().peek()
227 .getHolderOfEntityToResolve();
228
229 /**
230 * Traverse up in the ancestor tree to check if the referred node is
231 * defined
232 */
233 while (potentialAncestorWithReferredNode != null) {
234
235 /**
236 * Check for the referred node defined in a ancestor scope
237 */
238 YangNode potentialReferredNode = potentialAncestorWithReferredNode.getChild();
239 if (isReferredNodeInSiblingListProcessed(potentialReferredNode)) {
240 return;
241 }
242
243 potentialAncestorWithReferredNode = potentialAncestorWithReferredNode.getParent();
244 }
245 }
246
247 /**
248 * Check if the reference in self file or in external file.
249 *
250 * @return true if self file reference, false otherwise
251 * @throws DataModelException a violation of data model rules
252 */
253 private boolean isSelfFileReference()
254 throws DataModelException {
255 String prefix;
256 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
257 prefix = ((YangType<?>) getCurrentEntityToResolveFromStack()).getPrefix();
258 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
259 prefix = ((YangUses) getCurrentEntityToResolveFromStack()).getPrefix();
260 } else {
261 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
262 }
263
264 if (prefix == null) {
265 return true;
266 }
267 return prefix.contentEquals(resolutionInfoRootNodePrefix);
268
269 }
270
271 /**
272 * Check for the referred node defined in a ancestor scope.
273 *
274 * @param potentialReferredNode potential referred node
275 * @return status of resolution and updating the partial resolved stack with
276 * the any recursive references
277 * @throws DataModelException data model errors
278 */
279 private boolean isReferredNodeInSiblingListProcessed(YangNode potentialReferredNode)
280 throws DataModelException {
281 while (potentialReferredNode != null) {
282
283 // Check if the potential referred node is the actual referred node
284 if (isReferredNode(potentialReferredNode)) {
285
286 // Adds reference link of entity to the node under resolution.
287 addReferredEntityLink(potentialReferredNode);
288
289 /**
290 * resolve the reference and update the partial resolution stack
291 * with any further recursive references
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530292 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530293 addUnresolvedRecursiveReferenceToStack(potentialReferredNode);
294
295 /*
296 * return true, since the reference is linked and any recursive
297 * unresolved references is added to the stack
298 */
299 return true;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530300 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530301
302 potentialReferredNode = potentialReferredNode.getNextSibling();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530303 }
304 return false;
305 }
306
307 /**
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530308 * Check if the potential referred node is the actual referred node.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530309 *
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530310 * @param potentialReferredNode typedef/grouping node
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530311 * @return true if node is of resolve type otherwise false
312 * @throws DataModelException a violation of data model rules
313 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530314 private boolean isReferredNode(YangNode potentialReferredNode)
315 throws DataModelException {
316 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
317 if (potentialReferredNode instanceof YangTypeDef) {
318 /*
319 * Check if name of node name matches with the entity being
320 * resolved
321 */
322 return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530323 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530324 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
325 if (potentialReferredNode instanceof YangGrouping) {
326 /*
327 * Check if name of node name matches with the entity being
328 * resolved
329 */
330 return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530331 }
332 } else {
333 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
334 }
335 return false;
336 }
337
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530338 /**
339 * Check if node name is same as name in resolution info, i.e. name of
340 * typedef/grouping is same as name of type/uses.
341 *
342 * @param node typedef/grouping node
343 * @return true if node name is same as name in resolution info, otherwise
344 * false
345 * @throws DataModelException a violation of data model rules
346 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530347
348 private boolean isNodeNameSameAsResolutionInfoName(YangNode node)
349 throws DataModelException {
350 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
351 if (node.getName().contentEquals(
352 ((YangType<?>) getCurrentEntityToResolveFromStack())
353 .getDataTypeName())) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530354 return true;
355 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530356 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
357 if (node.getName().contentEquals(
358 ((YangUses) getCurrentEntityToResolveFromStack()).getName())) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530359 return true;
360 }
361 } else {
362 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
363 }
364 return false;
365 }
366
367 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530368 * Adds reference of grouping/typedef in uses/type.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530369 *
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530370 * @param referredNode grouping/typedef node being referred
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530371 * @throws DataModelException a violation of data model rules
372 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530373 private void addReferredEntityLink(YangNode referredNode)
374 throws DataModelException {
375 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
376 YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>)
377 ((YangType<?>) getCurrentEntityToResolveFromStack()).getDataTypeExtendedInfo();
378 derivedInfo.setReferredTypeDef((YangTypeDef) referredNode);
379 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
380 ((YangUses) getCurrentEntityToResolveFromStack())
381 .setRefGroup((YangGrouping) referredNode);
382 } else {
383 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
384 }
385
386 // Sets the resolution status in inside the type/uses.
387 ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(LINKED);
388 }
389
390 /**
391 * Checks if type/grouping has further reference to typedef/ unresolved
392 * uses. Add it to the partial resolve stack and return the status of
393 * addition to stack.
394 *
395 * @param referredNode grouping/typedef node
396 * @throws DataModelException a violation of data model rules
397 */
398 private void addUnresolvedRecursiveReferenceToStack(YangNode referredNode)
399 throws DataModelException {
400 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
401 /*
402 * Checks if typedef type is derived
403 */
404 if (((YangTypeDef) referredNode).getTypeDefBaseType().getDataType()
405 == YangDataTypes.DERIVED) {
406
407 YangEntityToResolveInfo<YangType<?>> unResolvedEntityInfo = new YangEntityToResolveInfo<YangType<?>>();
408 unResolvedEntityInfo.setEntityToResolve(((YangTypeDef) referredNode)
409 .getTypeDefBaseType());
410 unResolvedEntityInfo.setHolderOfEntityToResolve(referredNode);
411 addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo);
412 }
413
414 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
415 /*
416 * Search if the grouping has any un resolved uses child, if so
417 * return true, else return false.
418 */
419 addUnResolvedUsesToStack(referredNode);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530420 } else {
421 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
422 }
423 }
424
425 /**
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530426 * Return if there is any unresolved uses in grouping.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530427 *
428 * @param node grouping/typedef node
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530429 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530430 private void addUnResolvedUsesToStack(YangNode node) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530431
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530432 /**
433 * Search the grouping node's children for presence of uses node.
434 */
435 YangNode curNode = node.getChild();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530436 while (curNode != null) {
437 if (curNode instanceof YangUses) {
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530438 ResolvableStatus curResolveStatus = ((Resolvable) curNode).getResolvableStatus();
439 if (curResolveStatus == UNRESOLVED) {
440 /**
441 * The current uses is not resolved, add it to partial
442 * resolved stack
443 */
444 YangEntityToResolveInfo<YangUses> unResolvedEntityInfo = new YangEntityToResolveInfo<YangUses>();
445 unResolvedEntityInfo.setEntityToResolve((YangUses) curNode);
446 unResolvedEntityInfo.setHolderOfEntityToResolve(node);
447 addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo);
448
449 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530450 }
451 curNode = curNode.getNextSibling();
452 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530453 }
454
455 /**
456 * Returns error position.
457 *
458 * @return error position
459 */
460 public int getCharPosition() {
461 return charPosition;
462 }
463
464 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530465 * Sets error position.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530466 *
467 * @param charPosition position of error
468 */
469 public void setCharPosition(int charPosition) {
470 this.charPosition = charPosition;
471 }
472
473 /**
474 * Returns error character position in line.
475 *
476 * @return error character position in line
477 */
478 public int getLineNumber() {
479 return lineNumber;
480 }
481
482 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530483 * Sets error character position in line.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530484 *
485 * @param lineNumber error character position in line
486 */
487 public void setLineNumber(int lineNumber) {
488 this.lineNumber = lineNumber;
489 }
490
491 /**
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530492 * Returns stack of YANG type with partially resolved YANG construct
493 * hierarchy.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530494 *
495 * @return partial resolved YANG construct stack
496 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530497 private Stack<YangEntityToResolveInfo<T>> getPartialResolvedStack() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530498 return partialResolvedStack;
499 }
500
501 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530502 * Sets stack of YANG type with partially resolved YANG construct hierarchy.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530503 *
504 * @param partialResolvedStack partial resolved YANG construct stack
505 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530506 private void setPartialResolvedStack(Stack<YangEntityToResolveInfo<T>> partialResolvedStack) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530507 this.partialResolvedStack = partialResolvedStack;
508 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530509
510 /**
511 * Sets stack of YANG type with partially resolved YANG construct hierarchy.
512 *
513 * @param partialResolvedInfo partial resolved YANG construct stack
514 */
515 private void addInPartialResolvedStack(YangEntityToResolveInfo<T> partialResolvedInfo) {
516 getPartialResolvedStack().push(partialResolvedInfo);
517 }
518
519 /**
520 * Retrieves the next entity in the stack that needs to be resolved. It is
521 * assumed that the caller ensures that the stack is not empty.
522 *
523 * @return next entity in the stack that needs to be resolved
524 */
525 private T getCurrentEntityToResolveFromStack() {
526 return getPartialResolvedStack().peek().getEntityToResolve();
527 }
528
529 /**
530 * Retrieves information about the entity that needs to be resolved.
531 *
532 * @return information about the entity that needs to be resolved
533 */
534 public YangEntityToResolveInfo<T> getEntityToResolveInfo() {
535 return entityToResolveInfo;
536 }
537
538 /**
539 * Sets information about the entity that needs to be resolved.
540 *
541 * @param entityToResolveInfo information about the entity that needs to be
542 * resolved
543 */
544 public void setEntityToResolveInfo(YangEntityToResolveInfo<T> entityToResolveInfo) {
545 this.entityToResolveInfo = entityToResolveInfo;
546 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530547}