Reduce JSR305 proliferation
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / ChangeServersVotingStatus.java
1 /*
2  * Copyright (c) 2016 Brocade Communications 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 package org.opendaylight.controller.cluster.raft.messages;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.collect.ImmutableSet;
13 import java.io.Serializable;
14 import java.util.Collection;
15 import java.util.HashMap;
16 import java.util.Map;
17 import org.eclipse.jdt.annotation.NonNull;
18
19 /**
20  * Message sent to change the raft voting status for servers.
21  *
22  * @author Thomas Pantelis
23  */
24 public class ChangeServersVotingStatus implements Serializable {
25     private static final long serialVersionUID = 1L;
26
27     private final Map<String, Boolean> serverVotingStatusMap;
28     private final Collection<String> serversVisited;
29
30     public ChangeServersVotingStatus(@NonNull Map<String, Boolean> serverVotingStatusMap) {
31         this(serverVotingStatusMap, ImmutableSet.of());
32     }
33
34     public ChangeServersVotingStatus(@NonNull Map<String, Boolean> serverVotingStatusMap,
35             @NonNull Collection<String> serversVisited) {
36         this.serverVotingStatusMap = new HashMap<>(requireNonNull(serverVotingStatusMap));
37         this.serversVisited = ImmutableSet.copyOf(requireNonNull(serversVisited));
38     }
39
40     public @NonNull Map<String, Boolean> getServerVotingStatusMap() {
41         return serverVotingStatusMap;
42     }
43
44     public @NonNull Collection<String> getServersVisited() {
45         return serversVisited;
46     }
47
48     @Override
49     public String toString() {
50         return "ChangeServersVotingStatus [serverVotingStatusMap=" + serverVotingStatusMap
51                 + (serversVisited != null ? ", serversVisited=" + serversVisited : "") + "]";
52     }
53 }