tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cluster; |
| 2 | |
tom | fc9a4ff | 2014-09-22 18:22:47 -0700 | [diff] [blame^] | 3 | import java.util.Objects; |
| 4 | |
| 5 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 6 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 7 | /** |
| 8 | * Controller cluster identity. |
| 9 | */ |
tom | fc9a4ff | 2014-09-22 18:22:47 -0700 | [diff] [blame^] | 10 | public 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 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 50 | } |