Deprecate simple DataTreeFactory.create()
[yangtools.git] / common / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / QNv1.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.common;
9
10 import static com.google.common.base.Verify.verifyNotNull;
11 import static java.util.Objects.requireNonNull;
12
13 import java.io.Externalizable;
14 import java.io.IOException;
15 import java.io.ObjectInput;
16 import java.io.ObjectOutput;
17 import java.io.Serial;
18
19 /**
20  * Externalizable proxy for {@link QName}.
21  */
22 final class QNv1 implements Externalizable {
23     @Serial
24     private static final long serialVersionUID = 1L;
25
26     private QName qname;
27
28     @SuppressWarnings("checkstyle:redundantModifier")
29     public QNv1() {
30         // For Externalizable
31     }
32
33     QNv1(final QName qname) {
34         this.qname = requireNonNull(qname);
35     }
36
37     @Override
38     public void writeExternal(final ObjectOutput out) throws IOException {
39         qname.writeTo(out);
40     }
41
42     @Override
43     public void readExternal(final ObjectInput in) throws IOException {
44         qname = QName.readFrom(in);
45     }
46
47     @Serial
48     Object readResolve() {
49         return verifyNotNull(qname);
50     }
51 }