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

Change-Id: If41564824770c2a8b78237a206c036df94141117
diff --git a/cli/src/main/java/org/onosproject/cli/net/AllocationsCommand.java b/cli/src/main/java/org/onosproject/cli/net/AllocationsCommand.java
index 4c04f9a..0882429 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AllocationsCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AllocationsCommand.java
@@ -40,6 +40,7 @@
 import org.onosproject.net.TributarySlot;
 import org.onosproject.net.device.DeviceService;
 import org.onosproject.net.intent.IntentId;
+import org.onosproject.net.resource.ResourceConsumerId;
 import org.onosproject.net.resource.Resources;
 import org.onosproject.net.resource.DiscreteResourceId;
 import org.onosproject.net.resource.ResourceAllocation;
@@ -145,15 +146,15 @@
             resourceService.getResourceAllocations(resourceId, t).stream()
                     .filter(a -> isSubjectToPrint(a))
                     .forEach(a -> print("%s%s allocated by %s", Strings.repeat(" ", level + 1),
-                            a.resource().valueAs(Object.class).orElse(""), asVerboseString(a.consumer())));
+                            a.resource().valueAs(Object.class).orElse(""), asVerboseString(a.consumerId())));
 
         }
     }
 
     private boolean isSubjectToPrint(ResourceAllocation allocation) {
         if (!intentsToPrint.isEmpty()
-                && allocation.consumer() instanceof IntentId
-                && !intentsToPrint.contains(allocation.consumer().toString())) {
+                && allocation.consumerId().isClassOf(IntentId.class)
+                && !intentsToPrint.contains(allocation.consumerId().toString())) {
             return false;
         }
 
@@ -184,4 +185,8 @@
         }
     }
 
+    private static String asVerboseString(ResourceConsumerId consumerId) {
+        return String.format("%s:%s", consumerId.consumerClass(), consumerId.value());
+    }
+
 }