5e4f22afe2edc823afa29a45fcfa4c8b44da90c0
[controller.git] / opendaylight / web / root / src / main / java / org / opendaylight / controller / web / ClusterNodeBean.java
1 package org.opendaylight.controller.web;
2
3 import java.net.InetAddress;
4
5 /**
6  * Information about a clustered controller to send to the UI frontend
7  * @author andrekim
8  */
9 public class ClusterNodeBean {
10     private final byte[] address;
11     private final String name;
12     private final Boolean me;
13     private final Boolean coordinator;
14
15     public static class Builder {
16         // required params
17         private final byte[] address;
18         private final String name;
19
20         // optional params
21         private Boolean me = null;
22         private Boolean coordinator = null;
23
24         public Builder(InetAddress address) {
25             this.address = address.getAddress();
26             this.name = address.getHostAddress();
27         }
28
29         public Builder highlightMe() {
30             this.me = true;
31             return this;
32         }
33
34         public Builder iAmCoordinator() {
35             this.coordinator = true;
36             return this;
37         }
38
39         public ClusterNodeBean build() {
40             return new ClusterNodeBean(this);
41         }
42     }
43
44     private ClusterNodeBean(Builder builder) {
45         this.address = builder.address;
46         this.name = builder.name;
47         this.me = builder.me;
48         this.coordinator = builder.coordinator;
49     }
50 }