Enable checkstyle on yang-data-codec-gson
[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 com.google.common.base.Preconditions;
11
12 import java.net.URI;
13
14 import javax.annotation.Nonnull;
15 import org.opendaylight.yangtools.yang.common.QName;
16
17 /**
18  * Abstract base class for {@link JSONNormalizedNodeStreamWriter} recursion
19  * levels which emit a QName-identified node.
20  */
21 abstract class JSONStreamWriterQNameContext extends JSONStreamWriterContext {
22     private final QName qname;
23
24     protected JSONStreamWriterQNameContext(final JSONStreamWriterContext parent, final QName qname,
25             final boolean mandatory) {
26         super(parent, mandatory);
27         this.qname = Preconditions.checkNotNull(qname);
28     }
29
30     /**
31      * Returns the node's identifier as a QName.
32      *
33      * @return QName identifier
34      */
35     protected final QName getQName() {
36         return qname;
37     }
38
39     @Nonnull
40     @Override
41     protected final URI getNamespace() {
42         return qname.getNamespace();
43     }
44 }