bdf7a3f9d2250cad8074566c487de955c1f625a9
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / FollowerIdentifier.java
1 /*
2  * Copyright (c) 2017 Inocybe Technologies 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.behaviors;
9
10 import java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.opendaylight.yangtools.util.AbstractStringIdentifier;
15
16 /**
17  * An Identifier for a follower.
18  *
19  * @author Thomas Pantelis
20  */
21 class FollowerIdentifier extends AbstractStringIdentifier<FollowerIdentifier> {
22     @java.io.Serial
23     private static final long serialVersionUID = 1L;
24
25     FollowerIdentifier(final String followerId) {
26         super(followerId);
27     }
28
29     @java.io.Serial
30     private Object writeReplace() {
31         return new FI(getValue());
32     }
33
34     @Deprecated(since = "7.0.0", forRemoval = true)
35     private static class Proxy implements Externalizable {
36         @java.io.Serial
37         private static final long serialVersionUID = 1L;
38
39         private FollowerIdentifier identifier;
40
41         // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
42         // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
43         @SuppressWarnings("checkstyle:RedundantModifier")
44         public Proxy() {
45         }
46
47         @Override
48         public void writeExternal(final ObjectOutput out) {
49             throw new UnsupportedOperationException();
50         }
51
52         @Override
53         public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
54             identifier = new FollowerIdentifier((String) in.readObject());
55         }
56
57         @java.io.Serial
58         private Object readResolve() {
59             return identifier;
60         }
61     }
62 }