Do not pretty-print body class
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / NIVv1.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.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.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
18
19 /**
20  * Externalizable proxy for {@link NodeWithValue}.
21  */
22 final class NIVv1 implements Externalizable {
23     private static final long serialVersionUID = 1L;
24
25     private NodeWithValue<?> niv;
26
27     @SuppressWarnings("checkstyle:redundantModifier")
28     public NIVv1() {
29         // For Externalizable
30     }
31
32     NIVv1(final NodeWithValue<?> niv) {
33         this.niv = requireNonNull(niv);
34     }
35
36     @Override
37     public void writeExternal(final ObjectOutput out) throws IOException {
38         niv.getNodeType().writeTo(out);
39         out.writeObject(niv.getValue());
40     }
41
42     @Override
43     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
44         niv = new NodeWithValue<>(QName.readFrom(in), in.readObject());
45     }
46
47     private Object readResolve() {
48         return niv;
49     }
50 }