BUG-865: deprecate pre-Beryllium parser elements
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / impl / SchemaPathStack.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.impl;
9
10 import com.google.common.base.Preconditions;
11 import java.util.Deque;
12 import java.util.LinkedList;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
15
16 /**
17  * @deprecated Pre-Beryllium implementation, scheduled for removal.
18  */
19 @Deprecated
20 final class SchemaPathStack {
21     private final Deque<SchemaPath> paths = new LinkedList<>();
22
23     SchemaPath addNodeToPath(final QName name) {
24         SchemaPath sp = paths.pop();
25         sp = sp.createChild(name);
26         paths.push(sp);
27         return sp;
28     }
29
30     QName removeNodeFromPath() {
31         SchemaPath sp = paths.pop();
32         QName ret = sp.getLastComponent();
33         paths.push(Preconditions.checkNotNull(sp.getParent(), "Attempted to remove too many nodes from schemapath at stack %s", paths));
34         return ret;
35     }
36
37     SchemaPath currentSchemaPath() {
38         return paths.peek();
39     }
40
41     void pop() {
42         paths.pop();
43     }
44
45     void push() {
46         paths.push(SchemaPath.ROOT);
47     }
48 }