2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.raft.messages;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.VisibleForTesting;
13 import com.google.common.base.MoreObjects;
14 import java.io.Serializable;
15 import java.util.Optional;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.eclipse.jdt.annotation.Nullable;
20 * Abstract base class for a server configuration change reply.
22 * @author Thomas Pantelis
24 public abstract class AbstractServerChangeReply implements Serializable {
25 private static final long serialVersionUID = 1L;
27 private final String leaderHint;
28 private final ServerChangeStatus status;
30 AbstractServerChangeReply(final @NonNull ServerChangeStatus status, final @Nullable String leaderHint) {
31 this.status = requireNonNull(status);
32 this.leaderHint = leaderHint;
36 public final @NonNull Optional<String> getLeaderHint() {
37 return Optional.ofNullable(leaderHint);
40 public final @NonNull ServerChangeStatus getStatus() {
45 public final String toString() {
46 return MoreObjects.toStringHelper(getClass()).omitNullValues()
47 .add("status", status).add("leaderHint", leaderHint).toString();