Cleanup and document FindLeaderReply
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / client / messages / FindLeaderReply.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
9 package org.opendaylight.controller.cluster.raft.client.messages;
10
11 import com.google.common.annotations.VisibleForTesting;
12 import java.io.Serializable;
13 import java.util.Optional;
14 import javax.annotation.Nullable;
15
16 /**
17  * Reply to {@link FindLeader} message, containing the address of the leader actor, as known to the raft actor which
18  * sent the message. If the responding actor does not have knowledge of the leader, {@link #getLeaderActor()} will
19  * return {@link Optional#empty()}.
20  *
21  * This message is intended for testing purposes only.
22  */
23 @VisibleForTesting
24 public final class FindLeaderReply implements Serializable {
25     private static final long serialVersionUID = 1L;
26     private final String leaderActor;
27
28     public FindLeaderReply(@Nullable final String leaderActor) {
29         this.leaderActor = leaderActor;
30     }
31
32     public Optional<String> getLeaderActor() {
33         return Optional.ofNullable(leaderActor);
34     }
35 }