blob: 861dec6fcefcc3576aa181fc1b0304206bf74821 [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001package net.onrc.onos.of.ctl.util;
2
3import static com.google.common.base.Preconditions.checkNotNull;
4import static com.google.common.base.Preconditions.checkArgument;
5
6/**
7 * The class representing an ONOS Instance ID.
8 *
9 * This class is immutable.
10 */
11public final class InstanceId {
12 private final String id;
13
14 /**
15 * Constructor from a string value.
16 *
17 * @param id the value to use.
18 */
19 public InstanceId(String id) {
20 this.id = checkNotNull(id);
21 checkArgument(!id.isEmpty(), "Empty ONOS Instance ID");
22 }
23
24 @Override
25 public int hashCode() {
26 return id.hashCode();
27 }
28
29 @Override
30 public boolean equals(Object obj) {
31 if (obj == this) {
32 return true;
33 }
34
35 if (!(obj instanceof InstanceId)) {
36 return false;
37 }
38
39 InstanceId that = (InstanceId) obj;
40 return this.id.equals(that.id);
41 }
42
43 @Override
44 public String toString() {
45 return id;
46 }
47}