Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / web / root / src / main / java / org / opendaylight / controller / web / ClusterNodeBean.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 package org.opendaylight.controller.web;
9
10 import java.net.InetAddress;
11
12 /**
13  * Information about a clustered controller to send to the UI frontend
14  * @author andrekim
15  */
16 public class ClusterNodeBean {
17     private final byte[] address;
18     private final String name;
19     private final Boolean me;
20     private final Boolean coordinator;
21     private final Integer numConnectedNodes;
22
23     public static class Builder {
24         // required params
25         private final byte[] address;
26         private final String name;
27
28         // optional params
29         private Boolean me = null;
30         private Boolean coordinator = null;
31         private Integer numConnectedNodes = null;
32
33         public Builder(InetAddress address) {
34             this.address = address.getAddress();
35             this.name = address.getHostAddress();
36         }
37
38         public Builder highlightMe() {
39             this.me = true;
40             return this;
41         }
42
43         public Builder iAmCoordinator() {
44             this.coordinator = true;
45             return this;
46         }
47
48         public Builder nodesConnected(int numNodes) {
49             this.numConnectedNodes = numNodes;
50             return this;
51         }
52
53         public ClusterNodeBean build() {
54             return new ClusterNodeBean(this);
55         }
56     }
57
58     private ClusterNodeBean(Builder builder) {
59         this.address = builder.address;
60         this.name = builder.name;
61         this.me = builder.me;
62         this.coordinator = builder.coordinator;
63         this.numConnectedNodes = builder.numConnectedNodes;
64     }
65 }