b4b45465047420198b22ee0c1b0ab74fb9a18a7f
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / persisted / DeleteEntries.java
1 /*
2  * Copyright (c) 2016 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.raft.persisted;
9
10 import java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import java.io.Serializable;
15
16 /**
17  * Internal message that is stored in the akka's persistent journal to delete journal entries.
18  *
19  * @author Thomas Pantelis
20  */
21 public class DeleteEntries implements Serializable {
22     @Deprecated(since = "7.0.0", forRemoval = true)
23     private static final class Proxy implements Externalizable {
24         @java.io.Serial
25         private static final long serialVersionUID = 1L;
26
27         private DeleteEntries deleteEntries;
28
29         // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
30         // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
31         @SuppressWarnings("checkstyle:RedundantModifier")
32         public Proxy() {
33             // For Externalizable
34         }
35
36         Proxy(final DeleteEntries deleteEntries) {
37             this.deleteEntries = deleteEntries;
38         }
39
40         @Override
41         public void writeExternal(final ObjectOutput out) throws IOException {
42             out.writeLong(deleteEntries.fromIndex);
43         }
44
45         @Override
46         public void readExternal(final ObjectInput in) throws IOException {
47             deleteEntries = new DeleteEntries(in.readLong());
48         }
49
50         @java.io.Serial
51         private Object readResolve() {
52             return deleteEntries;
53         }
54     }
55
56     @java.io.Serial
57     private static final long serialVersionUID = 1L;
58
59     private final long fromIndex;
60
61     public DeleteEntries(final long fromIndex) {
62         this.fromIndex = fromIndex;
63     }
64
65     public long getFromIndex() {
66         return fromIndex;
67     }
68
69     private Object writeReplace() {
70         return new DE(this);
71     }
72
73     @Override
74     public String toString() {
75         return "DeleteEntries [fromIndex=" + fromIndex + "]";
76     }
77 }