Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / JSONStreamWriterQNameContext.java
1 /*
2  * Copyright (c) 2014 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.data.codec.gson;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.net.URI;
13 import org.opendaylight.yangtools.yang.common.QName;
14
15 /**
16  * Abstract base class for {@link JSONNormalizedNodeStreamWriter} recursion
17  * levels which emit a QName-identified node.
18  */
19 abstract class JSONStreamWriterQNameContext extends JSONStreamWriterContext {
20     private final QName qname;
21
22     JSONStreamWriterQNameContext(final JSONStreamWriterContext parent, final QName qname, final boolean mandatory) {
23         super(parent, mandatory);
24         this.qname = requireNonNull(qname);
25     }
26
27     /**
28      * Returns the node's identifier as a QName.
29      *
30      * @return QName identifier
31      */
32     protected final QName getQName() {
33         return qname;
34     }
35
36     @Override
37     protected final URI getNamespace() {
38         return qname.getNamespace();
39     }
40 }