Remove old payload proxies
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / DSS.java
1 /*
2  * Copyright (c) 2022 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.controller.cluster.datastore.persisted;
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 org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
18 import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
19
20 /**
21  * Serialization proxy for {@link ShardDataTreeSnapshot}.
22  */
23 final class DSS implements Externalizable {
24     @java.io.Serial
25     private static final long serialVersionUID = 1L;
26
27     private ShardSnapshot shardSnapshot;
28
29     @SuppressWarnings("checkstyle:RedundantModifier")
30     public DSS() {
31         // For Externalizable
32     }
33
34     DSS(final ShardSnapshot shardSnapshot) {
35         this.shardSnapshot = requireNonNull(shardSnapshot);
36     }
37
38     @Override
39     public void writeExternal(final ObjectOutput out) throws IOException {
40         out.writeObject(shardSnapshot.getName());
41         out.writeObject(shardSnapshot.getSnapshot());
42     }
43
44     @Override
45     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
46         shardSnapshot = new ShardSnapshot((String) in.readObject(), (Snapshot) in.readObject());
47     }
48
49     @java.io.Serial
50     private Object readResolve() {
51         return verifyNotNull(shardSnapshot);
52     }
53 }