Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / FI.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.raft.behaviors;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.io.Externalizable;
13 import java.io.IOException;
14 import java.io.ObjectInput;
15 import java.io.ObjectOutput;
16
17 /**
18  * Serialization proxy for {@link FollowerIdentifier}.
19  */
20 final class FI implements Externalizable {
21     @java.io.Serial
22     private static final long serialVersionUID = 1L;
23
24     private String value;
25
26     @SuppressWarnings("checkstyle:RedundantModifier")
27     public FI() {
28         // For Externalizable
29     }
30
31     FI(final String value) {
32         this.value = requireNonNull(value);
33     }
34
35     @Override
36     public void writeExternal(final ObjectOutput out) throws IOException {
37         out.writeObject(value);
38     }
39
40     @Override
41     public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
42         value = (String) in.readObject();
43     }
44
45     @java.io.Serial
46     private Object readResolve() {
47         return new FollowerIdentifier(value);
48     }
49 }