Fix for ONOS-3220 : Implement Comparable on intent Key.

Change-Id: Ibba4a972d2e3a82b5bf9256893a82501236021cb
diff --git a/core/api/src/main/java/org/onosproject/net/intent/Key.java b/core/api/src/main/java/org/onosproject/net/intent/Key.java
index 18baafc..0344acb 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/Key.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/Key.java
@@ -28,7 +28,7 @@
  */
 // TODO maybe pull this up to utils
 @Beta
-public abstract class Key {
+public abstract class Key implements Comparable<Key> {
 
     //TODO consider making this a HashCode object (worry about performance)
     private final long hash;
@@ -117,6 +117,12 @@
                     Objects.equals(this.appId, other.appId) &&
                     Objects.equals(this.key, other.key);
         }
+
+        @Override
+        public int compareTo(Key o) {
+            StringKey sk = (StringKey) o;
+            return this.key.compareTo(sk.key);
+        }
     }
 
     private static final class LongKey extends Key {
@@ -157,6 +163,13 @@
                     this.key == other.key &&
                     Objects.equals(this.appId, other.appId);
         }
+
+        @Override
+        public int compareTo(Key o) {
+            Long myKey = key;
+            Long otherKey = ((LongKey) o).key;
+            return myKey.compareTo(otherKey);
+        }
     }
 }
 
diff --git a/core/store/dist/src/test/java/org/onosproject/store/intent/impl/PartitionManagerTest.java b/core/store/dist/src/test/java/org/onosproject/store/intent/impl/PartitionManagerTest.java
index 25e23d3..61d1937 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/intent/impl/PartitionManagerTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/intent/impl/PartitionManagerTest.java
@@ -325,5 +325,11 @@
 
             return Objects.equals(this.hash(), that.hash());
         }
+
+        @Override
+        public int compareTo(Key o) {
+            Long thisHash = hash();
+            return thisHash.compareTo(o.hash());
+        }
     }
 }