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