blob: 5ff2fbc719962addde9db46d693985488c79b74d [file] [log] [blame]
tom73d6d1e2014-09-17 20:08:01 -07001package org.onlab.onos.cluster;
2
tomfc9a4ff2014-09-22 18:22:47 -07003import java.util.Objects;
4
tom73d6d1e2014-09-17 20:08:01 -07005/**
6 * Controller cluster identity.
7 */
tome4729872014-09-23 00:37:37 -07008public class NodeId {
tomfc9a4ff2014-09-22 18:22:47 -07009
10 private final String id;
11
tomfc9a4ff2014-09-22 18:22:47 -070012 /**
tome4729872014-09-23 00:37:37 -070013 * Creates a new cluster node identifier from the specified string.
tomfc9a4ff2014-09-22 18:22:47 -070014 *
15 * @param id string identifier
16 */
tome4729872014-09-23 00:37:37 -070017 public NodeId(String id) {
tomfc9a4ff2014-09-22 18:22:47 -070018 this.id = id;
19 }
20
21 @Override
22 public int hashCode() {
23 return Objects.hash(id);
24 }
25
26 @Override
27 public boolean equals(Object obj) {
28 if (this == obj) {
29 return true;
30 }
tome4729872014-09-23 00:37:37 -070031 if (obj instanceof NodeId) {
32 final NodeId other = (NodeId) obj;
tomfc9a4ff2014-09-22 18:22:47 -070033 return Objects.equals(this.id, other.id);
34 }
35 return false;
36 }
37
38 @Override
39 public String toString() {
tome4729872014-09-23 00:37:37 -070040 return id;
tomfc9a4ff2014-09-22 18:22:47 -070041 }
42
tom73d6d1e2014-09-17 20:08:01 -070043}