Made ResourceManager to accept arbitrary ResourceConsumer implementation. (ONOS-4406)

Change-Id: If41564824770c2a8b78237a206c036df94141117
diff --git a/core/api/src/main/java/org/onosproject/net/resource/ResourceAllocation.java b/core/api/src/main/java/org/onosproject/net/resource/ResourceAllocation.java
index 63bee4e..3fa16af 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/ResourceAllocation.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/ResourceAllocation.java
@@ -29,7 +29,18 @@
 public class ResourceAllocation {
 
     private final Resource resource;
-    private final ResourceConsumer consumer;
+    private final ResourceConsumerId consumerId;
+
+    /**
+     * Creates an instance with the specified subject, resource and consumerId.
+     *
+     * @param resource resource of the subject
+     * @param consumerId consumer ID of this resource
+     */
+    public ResourceAllocation(Resource resource, ResourceConsumerId consumerId) {
+        this.resource = checkNotNull(resource);
+        this.consumerId = checkNotNull(consumerId);
+    }
 
     /**
      * Creates an instance with the specified subject, resource and consumer.
@@ -38,14 +49,13 @@
      * @param consumer consumer of this resource
      */
     public ResourceAllocation(Resource resource, ResourceConsumer consumer) {
-        this.resource = checkNotNull(resource);
-        this.consumer = consumer;
+        this(resource, checkNotNull(consumer).consumerId());
     }
 
     // for serialization
     private ResourceAllocation() {
         this.resource = null;
-        this.consumer = null;
+        this.consumerId = null;
     }
 
     /**
@@ -58,17 +68,17 @@
     }
 
     /**
-     * Returns the consumer of this resource.
+     * Returns ID of the consumer of this resource.
      *
-     * @return the consumer of this resource
+     * @return ID of the consumer of this resource
      */
-    public ResourceConsumer consumer() {
-        return consumer;
+    public ResourceConsumerId consumerId() {
+        return consumerId;
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(resource, consumer);
+        return Objects.hash(resource, consumerId);
     }
 
     @Override
@@ -81,14 +91,14 @@
         }
         final ResourceAllocation that = (ResourceAllocation) obj;
         return Objects.equals(this.resource, that.resource)
-                && Objects.equals(this.consumer, that.consumer);
+                && Objects.equals(this.consumerId, that.consumerId);
     }
 
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this)
                 .add("resource", resource)
-                .add("consumer", consumer)
+                .add("consumerId", consumerId)
                 .toString();
     }
 }