Remove old payload proxies
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / ShardSnapshotState.java
1 /*
2  * Copyright (c) 2017 Brocade Communications Systems, Inc. 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 java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.VisibleForTesting;
13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
16
17 /**
18  * Encapsulates the snapshot State for a Shard.
19  *
20  * @author Thomas Pantelis
21  */
22 public final class ShardSnapshotState implements Snapshot.State {
23     @java.io.Serial
24     private static final long serialVersionUID = 1L;
25
26     @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
27             + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
28             + "aren't serialized. FindBugs does not recognize this.")
29     private final @NonNull ShardDataTreeSnapshot snapshot;
30     private final boolean migrated;
31
32     @VisibleForTesting
33     public ShardSnapshotState(final @NonNull ShardDataTreeSnapshot snapshot, final boolean migrated) {
34         this.snapshot = requireNonNull(snapshot);
35         this.migrated = migrated;
36     }
37
38     public ShardSnapshotState(final @NonNull ShardDataTreeSnapshot snapshot) {
39         this(snapshot, false);
40     }
41
42     public @NonNull ShardDataTreeSnapshot getSnapshot() {
43         return snapshot;
44     }
45
46     @Override
47     public boolean needsMigration() {
48         return migrated;
49     }
50
51     @java.io.Serial
52     private Object writeReplace() {
53         return new SS(this);
54     }
55 }