2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.impl;
10 import com.google.common.base.Preconditions;
12 import java.util.Deque;
13 import java.util.LinkedList;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 final class SchemaPathStack {
19 private final Deque<SchemaPath> paths = new LinkedList<>();
21 SchemaPath addNodeToPath(final QName name) {
22 SchemaPath sp = paths.pop();
23 sp = sp.createChild(name);
28 QName removeNodeFromPath() {
29 SchemaPath sp = paths.pop();
30 QName ret = sp.getLastComponent();
31 paths.push(Preconditions.checkNotNull(sp.getParent(), "Attempted to remove too many nodes from schemapath at stack %s", paths));
35 SchemaPath currentSchemaPath() {
44 paths.push(SchemaPath.ROOT);