Add Cluster Menu
[controller.git] / opendaylight / web / root / src / main / java / org / opendaylight / controller / web / ClusterNodeBean.java
diff --git a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/ClusterNodeBean.java b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/ClusterNodeBean.java
new file mode 100644 (file)
index 0000000..5e4f22a
--- /dev/null
@@ -0,0 +1,50 @@
+package org.opendaylight.controller.web;
+
+import java.net.InetAddress;
+
+/**
+ * Information about a clustered controller to send to the UI frontend
+ * @author andrekim
+ */
+public class ClusterNodeBean {
+    private final byte[] address;
+    private final String name;
+    private final Boolean me;
+    private final Boolean coordinator;
+
+    public static class Builder {
+        // required params
+        private final byte[] address;
+        private final String name;
+
+        // optional params
+        private Boolean me = null;
+        private Boolean coordinator = null;
+
+        public Builder(InetAddress address) {
+            this.address = address.getAddress();
+            this.name = address.getHostAddress();
+        }
+
+        public Builder highlightMe() {
+            this.me = true;
+            return this;
+        }
+
+        public Builder iAmCoordinator() {
+            this.coordinator = true;
+            return this;
+        }
+
+        public ClusterNodeBean build() {
+            return new ClusterNodeBean(this);
+        }
+    }
+
+    private ClusterNodeBean(Builder builder) {
+        this.address = builder.address;
+        this.name = builder.name;
+        this.me = builder.me;
+        this.coordinator = builder.coordinator;
+    }
+}
\ No newline at end of file