Switch to use PayloadVersion.CHLORINE_SR2
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / SM.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.util.List;
14
15 /**
16  * Serialization proxy for {@link ShardManagerSnapshot}.
17  */
18 final class SM implements ShardManagerSnapshot.SerializedForm {
19     @java.io.Serial
20     private static final long serialVersionUID = 1L;
21
22     private ShardManagerSnapshot snapshot;
23
24     @SuppressWarnings("checkstyle:RedundantModifier")
25     public SM() {
26         // For Externalizable
27     }
28
29     SM(final ShardManagerSnapshot snapshot) {
30         this.snapshot = requireNonNull(snapshot);
31     }
32
33     @Override
34     public List<String> shardNames() {
35         return snapshot.getShardList();
36     }
37
38     @Override
39     public void resolveTo(final ShardManagerSnapshot newSnapshot) {
40         snapshot = requireNonNull(newSnapshot);
41     }
42
43     @Override
44     public Object readResolve() {
45         return verifyNotNull(snapshot);
46     }
47 }