added equality functions that do a deep content check

Change-Id: Ibc64373587622fa6911d18e21d1695577cc36301
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
index 008886d..e1eacfe 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadata.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.cluster;
 
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -26,6 +27,7 @@
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
 
 /**
  * Cluster metadata.
@@ -82,6 +84,33 @@
                 .toString();
     }
 
+    @Override
+    public int hashCode() {
+        return Arrays.deepHashCode(new Object[] {name, nodes, partitions});
+    }
+
+    /*
+     * Provide a deep quality check of the meta data (non-Javadoc)
+     *
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object object) {
+
+        if (!ClusterMetadata.class.isInstance(object)) {
+            return false;
+        }
+        ClusterMetadata that = (ClusterMetadata) object;
+
+        if (!this.name.equals(that.name) || this.nodes.size() != that.nodes.size()
+                || this.partitions.size() != that.partitions.size()) {
+            return false;
+        }
+
+        return Sets.symmetricDifference(this.nodes, that.nodes).isEmpty()
+                && Sets.symmetricDifference(this.partitions, that.partitions).isEmpty();
+    }
+
     /**
      * Builder for a {@link ClusterMetadata} instance.
      */
@@ -146,10 +175,10 @@
 
             // verify that partitions are constituted from valid cluster nodes.
             boolean validPartitions = Collections2.transform(metadata.getNodes(), ControllerNode::id)
-                                                  .containsAll(metadata.getPartitions()
-                                                                       .stream()
-                                                                       .flatMap(r -> r.getMembers().stream())
-                                                                       .collect(Collectors.toSet()));
+                    .containsAll(metadata.getPartitions()
+                            .stream()
+                            .flatMap(r -> r.getMembers().stream())
+                            .collect(Collectors.toSet()));
             verify(validPartitions, "Partition locations must be valid cluster nodes");
         }
     }
diff --git a/core/api/src/main/java/org/onosproject/cluster/NodeId.java b/core/api/src/main/java/org/onosproject/cluster/NodeId.java
index 68b490f..6cfb42c 100644
--- a/core/api/src/main/java/org/onosproject/cluster/NodeId.java
+++ b/core/api/src/main/java/org/onosproject/cluster/NodeId.java
@@ -20,7 +20,7 @@
 /**
  * Controller cluster identity.
  */
-public class NodeId {
+public class NodeId implements Comparable<NodeId> {
 
     private final String id;
 
@@ -55,4 +55,9 @@
         return id;
     }
 
+    @Override
+    public int compareTo(NodeId that) {
+        return this.id.compareTo(that.id);
+    }
+
 }
diff --git a/core/api/src/main/java/org/onosproject/cluster/Partition.java b/core/api/src/main/java/org/onosproject/cluster/Partition.java
index 7590275..1eca4ae 100644
--- a/core/api/src/main/java/org/onosproject/cluster/Partition.java
+++ b/core/api/src/main/java/org/onosproject/cluster/Partition.java
@@ -15,10 +15,12 @@
  */
 package org.onosproject.cluster;
 
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Set;
 
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -61,4 +63,29 @@
     public Collection<NodeId> getMembers() {
         return this.members;
     }
+
+    @Override
+    public int hashCode() {
+        return Arrays.deepHashCode(new Object[] {name, members});
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+
+        if (other == null || !Partition.class.isInstance(other)) {
+            return false;
+        }
+
+        Partition that = (Partition) other;
+
+        if (!this.name.equals(that.name) || (this.members == null && that.members != null)
+                || (this.members != null && that.members == null) || this.members.size() != that.members.size()) {
+            return false;
+        }
+
+        return Sets.symmetricDifference(this.members, that.members).isEmpty();
+    }
 }
\ No newline at end of file