Introduce binding.EntryObject
[yangtools.git] / common / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / ETv1.java
1 /*
2  * Copyright (c) 2021 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 java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import java.io.Serial;
15
16 /**
17  * Externalizable proxy for {@link ErrorTag}.
18  */
19 final class ETv1 implements Externalizable {
20     @Serial
21     private static final long serialVersionUID = 1L;
22
23     private String elementBody;
24
25     @SuppressWarnings("checkstyle:redundantModifier")
26     public ETv1() {
27         // visible for Externalizable
28     }
29
30     ETv1(final ErrorTag tag) {
31         elementBody = tag.elementBody();
32     }
33
34     @Override
35     public void writeExternal(final ObjectOutput out) throws IOException {
36         out.writeUTF(elementBody);
37     }
38
39     @Override
40     public void readExternal(final ObjectInput in) throws IOException {
41         elementBody = in.readUTF();
42     }
43
44     @Serial
45     Object readResolve() {
46         return new ErrorTag(elementBody);
47     }
48 }