Define efficient serialization proxies
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / SS.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 /**
14  * Serialization proxy for {@link ShardSnapshotState}.
15  */
16 final class SS implements ShardSnapshotState.SerialForm {
17     private static final long serialVersionUID = 1L;
18
19     private ShardSnapshotState snapshotState;
20
21     @SuppressWarnings("checkstyle:RedundantModifier")
22     public SS() {
23         // For Externalizable
24     }
25
26     SS(final ShardSnapshotState snapshotState) {
27         this.snapshotState = requireNonNull(snapshotState);
28     }
29
30     @Override
31     public ShardSnapshotState snapshotState() {
32         return snapshotState;
33     }
34
35     @Override
36     public void resolveTo(final ShardSnapshotState newSnapshotState) {
37         snapshotState = requireNonNull(newSnapshotState);
38     }
39
40     @Override
41     public Object readResolve() {
42         return verifyNotNull(snapshotState);
43     }
44 }