blob: af8f122243ebad90cb494d670a766ba797fa5e1e [file] [log] [blame]
tomcfde0622014-09-09 11:02:42 -07001package org.onlab.onos.net.topology;
2
3import java.util.Objects;
4
5import static com.google.common.base.MoreObjects.toStringHelper;
6
7/**
8 * Representation of the topology cluster identity.
9 */
10public final class ClusterId {
11
12 private final int id;
13
14 // Public construction is prohibit
15 private ClusterId(int id) {
16 this.id = id;
17 }
18
19 /**
20 * Returns the cluster identifier, represented by the specified integer
21 * serial number.
22 *
23 * @param id integer serial number
24 * @return cluster identifier
25 */
26 public static ClusterId clusterId(int id) {
27 return new ClusterId(id);
28 }
29
30 @Override
31 public int hashCode() {
32 return Objects.hash(id);
33 }
34
35 @Override
36 public boolean equals(Object obj) {
37 if (obj instanceof ClusterId) {
38 final ClusterId other = (ClusterId) obj;
39 return Objects.equals(this.id, other.id);
40 }
41 return false;
42 }
43
44 @Override
45 public String toString() {
46 return toStringHelper(this).add("id", id).toString();
47 }
48
49}