blob: 14f1edaca87fdea364d7c983985ab1ec1c58610b [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
5import static com.google.common.base.MoreObjects.toStringHelper;
6
tom73d6d1e2014-09-17 20:08:01 -07007/**
8 * Controller cluster identity.
9 */
tomfc9a4ff2014-09-22 18:22:47 -070010public class InstanceId {
11
12 private final String id;
13
14 // Default constructor for serialization
15 protected InstanceId() {
16 id = null;
17 }
18
19 /**
20 * Creates a new cluster instance identifier from the specified string.
21 *
22 * @param id string identifier
23 */
24 public InstanceId(String id) {
25 this.id = id;
26 }
27
28 @Override
29 public int hashCode() {
30 return Objects.hash(id);
31 }
32
33 @Override
34 public boolean equals(Object obj) {
35 if (this == obj) {
36 return true;
37 }
38 if (obj instanceof InstanceId) {
39 final InstanceId other = (InstanceId) obj;
40 return Objects.equals(this.id, other.id);
41 }
42 return false;
43 }
44
45 @Override
46 public String toString() {
47 return toStringHelper(this).add("id", id).toString();
48 }
49
tom73d6d1e2014-09-17 20:08:01 -070050}