90cec9db6c1ca479be13730ef2f410c1500e0976
[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  * <p>
22  * This message is intended for testing purposes only.
23  */
24 @VisibleForTesting
25 public final class FindLeaderReply implements Serializable {
26     private static final long serialVersionUID = 1L;
27     private final String leaderActor;
28
29     public FindLeaderReply(@Nullable final String leaderActor) {
30         this.leaderActor = leaderActor;
31     }
32
33     public Optional<String> getLeaderActor() {
34         return Optional.ofNullable(leaderActor);
35     }
36 }