Annotate AbstractRaftRPC with java.io.Serial
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / InstallSnapshotReply.java
1 /*
2  * Copyright (c) 2014 Cisco 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.raft.messages;
9
10 import java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14
15 public final class InstallSnapshotReply extends AbstractRaftRPC {
16     @java.io.Serial
17     private static final long serialVersionUID = 642227896390779503L;
18
19     // The followerId - this will be used to figure out which follower is
20     // responding
21     private final String followerId;
22     private final int chunkIndex;
23     private final boolean success;
24
25     public InstallSnapshotReply(final long term, final String followerId, final int chunkIndex, final boolean success) {
26         super(term);
27         this.followerId = followerId;
28         this.chunkIndex = chunkIndex;
29         this.success = success;
30     }
31
32     public String getFollowerId() {
33         return followerId;
34     }
35
36     public int getChunkIndex() {
37         return chunkIndex;
38     }
39
40     public boolean isSuccess() {
41         return success;
42     }
43
44     @Override
45     public String toString() {
46         return "InstallSnapshotReply [term=" + getTerm()
47                 + ", followerId=" + followerId
48                 + ", chunkIndex=" + chunkIndex
49                 + ", success=" + success + "]";
50     }
51
52     @Override
53     Object writeReplace() {
54         return new IR(this);
55     }
56
57     @Deprecated(since = "7.0.0", forRemoval = true)
58     private static class Proxy implements Externalizable {
59         @java.io.Serial
60         private static final long serialVersionUID = 1L;
61
62         private InstallSnapshotReply installSnapshotReply;
63
64         // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
65         // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
66         @SuppressWarnings("checkstyle:RedundantModifier")
67         public Proxy() {
68         }
69
70         @Override
71         public void writeExternal(final ObjectOutput out) {
72             throw new UnsupportedOperationException();
73         }
74
75         @Override
76         public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
77             long term = in.readLong();
78             String followerId = (String) in.readObject();
79             int chunkIndex = in.readInt();
80             boolean success = in.readBoolean();
81
82             installSnapshotReply = new InstallSnapshotReply(term, followerId, chunkIndex, success);
83         }
84
85         @java.io.Serial
86         private Object readResolve() {
87             return installSnapshotReply;
88         }
89     }
90 }