879d1ceaf8fe07eb0c68e5c1127c583969c723d2
[yangtools.git] / data / rfc8528-data-api / src / main / java / org / opendaylight / yangtools / rfc8528 / data / api / MPIv1.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.rfc8528.data.api;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.io.Externalizable;
13 import java.io.IOException;
14 import java.io.ObjectInput;
15 import java.io.ObjectOutput;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.yang.common.QName;
18
19 final class MPIv1 implements Externalizable {
20     @java.io.Serial
21     private static final long serialVersionUID = 1L;
22
23     private QName qname;
24
25     @SuppressWarnings("checkstyle:redundantModifier")
26     public MPIv1() {
27         // For Externalizable
28     }
29
30     MPIv1(final @NonNull QName qname) {
31         this.qname = requireNonNull(qname);
32     }
33
34     @Override
35     public void writeExternal(final ObjectOutput out) throws IOException {
36         qname.writeTo(out);
37     }
38
39     @Override
40     public void readExternal(final ObjectInput in) throws IOException {
41         qname = QName.readFrom(in);
42     }
43
44     @java.io.Serial
45     private Object readResolve() {
46         return MountPointIdentifier.create(qname);
47     }
48 }