blob: c9c0064eec3f37cdf365c243f07c7e1935bcec1a [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 */
193 private void resolveTopOfStack() {
194 ((Resolvable) getCurrentEntityToResolveFromStack()).resolve();
195
196 if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus()
197 != INTRA_FILE_RESOLVED) {
198 // Sets the resolution status in inside the type/uses.
199 ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(RESOLVED);
200 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530201 }
202
203 /**
204 * Resolves linking for a node child and siblings.
205 *
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530206 * @throws DataModelException data model error
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530207 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530208 private void linkTopOfStackReferenceUpdateStack()
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530209 throws DataModelException {
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530210
211 if (!isSelfFileReference()) {
212 /*
213 * TODO: use mojo utilities to load the referred module/sub-module
214 * and get the reference to the corresponding referred entity
215 */
216
217 ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(INTRA_FILE_RESOLVED);
218 return;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530219 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530220
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530221 /**
222 * Try to resolve the top of the stack and update partial resolved stack
223 * if there is recursive references
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530224 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530225 YangNode potentialAncestorWithReferredNode = getPartialResolvedStack().peek()
226 .getHolderOfEntityToResolve();
227
228 /**
229 * Traverse up in the ancestor tree to check if the referred node is
230 * defined
231 */
232 while (potentialAncestorWithReferredNode != null) {
233
234 /**
235 * Check for the referred node defined in a ancestor scope
236 */
237 YangNode potentialReferredNode = potentialAncestorWithReferredNode.getChild();
238 if (isReferredNodeInSiblingListProcessed(potentialReferredNode)) {
239 return;
240 }
241
242 potentialAncestorWithReferredNode = potentialAncestorWithReferredNode.getParent();
243 }
244 }
245
246 /**
247 * Check if the reference in self file or in external file.
248 *
249 * @return true if self file reference, false otherwise
250 * @throws DataModelException a violation of data model rules
251 */
252 private boolean isSelfFileReference()
253 throws DataModelException {
254 String prefix;
255 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
256 prefix = ((YangType<?>) getCurrentEntityToResolveFromStack()).getPrefix();
257 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
258 prefix = ((YangUses) getCurrentEntityToResolveFromStack()).getPrefix();
259 } else {
260 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
261 }
262
263 if (prefix == null) {
264 return true;
265 }
266 return prefix.contentEquals(resolutionInfoRootNodePrefix);
267
268 }
269
270 /**
271 * Check for the referred node defined in a ancestor scope.
272 *
273 * @param potentialReferredNode potential referred node
274 * @return status of resolution and updating the partial resolved stack with
275 * the any recursive references
276 * @throws DataModelException data model errors
277 */
278 private boolean isReferredNodeInSiblingListProcessed(YangNode potentialReferredNode)
279 throws DataModelException {
280 while (potentialReferredNode != null) {
281
282 // Check if the potential referred node is the actual referred node
283 if (isReferredNode(potentialReferredNode)) {
284
285 // Adds reference link of entity to the node under resolution.
286 addReferredEntityLink(potentialReferredNode);
287
288 /**
289 * resolve the reference and update the partial resolution stack
290 * with any further recursive references
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530291 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530292 addUnresolvedRecursiveReferenceToStack(potentialReferredNode);
293
294 /*
295 * return true, since the reference is linked and any recursive
296 * unresolved references is added to the stack
297 */
298 return true;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530299 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530300
301 potentialReferredNode = potentialReferredNode.getNextSibling();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530302 }
303 return false;
304 }
305
306 /**
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530307 * Check if the potential referred node is the actual referred node.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530308 *
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530309 * @param potentialReferredNode typedef/grouping node
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530310 * @return true if node is of resolve type otherwise false
311 * @throws DataModelException a violation of data model rules
312 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530313 private boolean isReferredNode(YangNode potentialReferredNode)
314 throws DataModelException {
315 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
316 if (potentialReferredNode instanceof YangTypeDef) {
317 /*
318 * Check if name of node name matches with the entity being
319 * resolved
320 */
321 return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530322 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530323 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
324 if (potentialReferredNode instanceof YangGrouping) {
325 /*
326 * Check if name of node name matches with the entity being
327 * resolved
328 */
329 return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530330 }
331 } else {
332 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
333 }
334 return false;
335 }
336
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530337 /**
338 * Check if node name is same as name in resolution info, i.e. name of
339 * typedef/grouping is same as name of type/uses.
340 *
341 * @param node typedef/grouping node
342 * @return true if node name is same as name in resolution info, otherwise
343 * false
344 * @throws DataModelException a violation of data model rules
345 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530346
347 private boolean isNodeNameSameAsResolutionInfoName(YangNode node)
348 throws DataModelException {
349 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
350 if (node.getName().contentEquals(
351 ((YangType<?>) getCurrentEntityToResolveFromStack())
352 .getDataTypeName())) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530353 return true;
354 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530355 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
356 if (node.getName().contentEquals(
357 ((YangUses) getCurrentEntityToResolveFromStack()).getName())) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530358 return true;
359 }
360 } else {
361 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
362 }
363 return false;
364 }
365
366 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530367 * Adds reference of grouping/typedef in uses/type.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530368 *
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530369 * @param referredNode grouping/typedef node being referred
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530370 * @throws DataModelException a violation of data model rules
371 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530372 private void addReferredEntityLink(YangNode referredNode)
373 throws DataModelException {
374 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
375 YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>)
376 ((YangType<?>) getCurrentEntityToResolveFromStack()).getDataTypeExtendedInfo();
377 derivedInfo.setReferredTypeDef((YangTypeDef) referredNode);
378 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
379 ((YangUses) getCurrentEntityToResolveFromStack())
380 .setRefGroup((YangGrouping) referredNode);
381 } else {
382 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
383 }
384
385 // Sets the resolution status in inside the type/uses.
386 ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(LINKED);
387 }
388
389 /**
390 * Checks if type/grouping has further reference to typedef/ unresolved
391 * uses. Add it to the partial resolve stack and return the status of
392 * addition to stack.
393 *
394 * @param referredNode grouping/typedef node
395 * @throws DataModelException a violation of data model rules
396 */
397 private void addUnresolvedRecursiveReferenceToStack(YangNode referredNode)
398 throws DataModelException {
399 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
400 /*
401 * Checks if typedef type is derived
402 */
403 if (((YangTypeDef) referredNode).getTypeDefBaseType().getDataType()
404 == YangDataTypes.DERIVED) {
405
406 YangEntityToResolveInfo<YangType<?>> unResolvedEntityInfo = new YangEntityToResolveInfo<YangType<?>>();
407 unResolvedEntityInfo.setEntityToResolve(((YangTypeDef) referredNode)
408 .getTypeDefBaseType());
409 unResolvedEntityInfo.setHolderOfEntityToResolve(referredNode);
410 addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo);
411 }
412
413 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
414 /*
415 * Search if the grouping has any un resolved uses child, if so
416 * return true, else return false.
417 */
418 addUnResolvedUsesToStack(referredNode);
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530419 } else {
420 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
421 }
422 }
423
424 /**
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530425 * Return if there is any unresolved uses in grouping.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530426 *
427 * @param node grouping/typedef node
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530428 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530429 private void addUnResolvedUsesToStack(YangNode node) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530430
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530431 /**
432 * Search the grouping node's children for presence of uses node.
433 */
434 YangNode curNode = node.getChild();
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530435 while (curNode != null) {
436 if (curNode instanceof YangUses) {
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530437 ResolvableStatus curResolveStatus = ((Resolvable) curNode).getResolvableStatus();
438 if (curResolveStatus == UNRESOLVED) {
439 /**
440 * The current uses is not resolved, add it to partial
441 * resolved stack
442 */
443 YangEntityToResolveInfo<YangUses> unResolvedEntityInfo = new YangEntityToResolveInfo<YangUses>();
444 unResolvedEntityInfo.setEntityToResolve((YangUses) curNode);
445 unResolvedEntityInfo.setHolderOfEntityToResolve(node);
446 addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo);
447
448 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530449 }
450 curNode = curNode.getNextSibling();
451 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530452
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530453 return;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530454 }
455
456 /**
457 * Returns error position.
458 *
459 * @return error position
460 */
461 public int getCharPosition() {
462 return charPosition;
463 }
464
465 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530466 * Sets error position.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530467 *
468 * @param charPosition position of error
469 */
470 public void setCharPosition(int charPosition) {
471 this.charPosition = charPosition;
472 }
473
474 /**
475 * Returns error character position in line.
476 *
477 * @return error character position in line
478 */
479 public int getLineNumber() {
480 return lineNumber;
481 }
482
483 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530484 * Sets error character position in line.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530485 *
486 * @param lineNumber error character position in line
487 */
488 public void setLineNumber(int lineNumber) {
489 this.lineNumber = lineNumber;
490 }
491
492 /**
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530493 * Returns stack of YANG type with partially resolved YANG construct
494 * hierarchy.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530495 *
496 * @return partial resolved YANG construct stack
497 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530498 private Stack<YangEntityToResolveInfo<T>> getPartialResolvedStack() {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530499 return partialResolvedStack;
500 }
501
502 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530503 * Sets stack of YANG type with partially resolved YANG construct hierarchy.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530504 *
505 * @param partialResolvedStack partial resolved YANG construct stack
506 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530507 private void setPartialResolvedStack(Stack<YangEntityToResolveInfo<T>> partialResolvedStack) {
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530508 this.partialResolvedStack = partialResolvedStack;
509 }
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530510
511 /**
512 * Sets stack of YANG type with partially resolved YANG construct hierarchy.
513 *
514 * @param partialResolvedInfo partial resolved YANG construct stack
515 */
516 private void addInPartialResolvedStack(YangEntityToResolveInfo<T> partialResolvedInfo) {
517 getPartialResolvedStack().push(partialResolvedInfo);
518 }
519
520 /**
521 * Retrieves the next entity in the stack that needs to be resolved. It is
522 * assumed that the caller ensures that the stack is not empty.
523 *
524 * @return next entity in the stack that needs to be resolved
525 */
526 private T getCurrentEntityToResolveFromStack() {
527 return getPartialResolvedStack().peek().getEntityToResolve();
528 }
529
530 /**
531 * Retrieves information about the entity that needs to be resolved.
532 *
533 * @return information about the entity that needs to be resolved
534 */
535 public YangEntityToResolveInfo<T> getEntityToResolveInfo() {
536 return entityToResolveInfo;
537 }
538
539 /**
540 * Sets information about the entity that needs to be resolved.
541 *
542 * @param entityToResolveInfo information about the entity that needs to be
543 * resolved
544 */
545 public void setEntityToResolveInfo(YangEntityToResolveInfo<T> entityToResolveInfo) {
546 this.entityToResolveInfo = entityToResolveInfo;
547 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530548}