Fixed equals methods for better efficiency.
Cleaned up ClusterService API.
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/InstanceId.java b/core/api/src/main/java/org/onlab/onos/cluster/InstanceId.java
index 7292a85..14f1eda 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/InstanceId.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/InstanceId.java
@@ -1,7 +1,50 @@
package org.onlab.onos.cluster;
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
/**
* Controller cluster identity.
*/
-public interface InstanceId {
+public class InstanceId {
+
+ private final String id;
+
+ // Default constructor for serialization
+ protected InstanceId() {
+ id = null;
+ }
+
+ /**
+ * Creates a new cluster instance identifier from the specified string.
+ *
+ * @param id string identifier
+ */
+ public InstanceId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof InstanceId) {
+ final InstanceId other = (InstanceId) obj;
+ return Objects.equals(this.id, other.id);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).toString();
+ }
+
}