Add sub-types to distinguish type of resources

Change-Id: Ia43cbf4a13937c9bd9dbc97221062ef5fa3e578f
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
index b75ca5d..718c7bb 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java
@@ -121,7 +121,7 @@
         }
 
         List<ResourcePath> resources = labels.entrySet().stream()
-                .map(x -> new ResourcePath(linkKey(x.getKey().src(), x.getKey().src()), x.getValue()))
+                .map(x -> ResourcePath.discrete(linkKey(x.getKey().src(), x.getKey().src()), x.getValue()))
                 .collect(Collectors.toList());
         List<org.onosproject.net.newresource.ResourceAllocation> allocations =
                 resourceService.allocate(intent.id(), resources);
@@ -145,7 +145,7 @@
     }
 
     private Optional<MplsLabel> findMplsLabel(LinkKey link) {
-        return resourceService.getAvailableResources(new ResourcePath(link)).stream()
+        return resourceService.getAvailableResources(ResourcePath.discrete(link)).stream()
                 .filter(x -> x.last() instanceof MplsLabel)
                 .map(x -> (MplsLabel) x.last())
                 .findFirst();
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
index fce8498..ee04aab 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
@@ -160,8 +160,8 @@
         log.debug("Compiling optical circuit intent between {} and {}", src, dst);
 
         // Reserve OduClt ports
-        ResourcePath srcPortPath = new ResourcePath(src.deviceId(), src.port());
-        ResourcePath dstPortPath = new ResourcePath(dst.deviceId(), dst.port());
+        ResourcePath srcPortPath = ResourcePath.discrete(src.deviceId(), src.port());
+        ResourcePath dstPortPath = ResourcePath.discrete(dst.deviceId(), dst.port());
         List<ResourceAllocation> allocation = resourceService.allocate(intent.id(), srcPortPath, dstPortPath);
         if (allocation.isEmpty()) {
             throw new IntentCompilationException("Unable to reserve ports for intent " + intent);
@@ -312,7 +312,7 @@
         if (ochCP != null) {
             OchPort ochPort = (OchPort) deviceService.getPort(ochCP.deviceId(), ochCP.port());
             Optional<IntentId> intentId =
-                    resourceService.getResourceAllocation(new ResourcePath(ochCP.deviceId(), ochCP.port()))
+                    resourceService.getResourceAllocation(ResourcePath.discrete(ochCP.deviceId(), ochCP.port()))
                             .map(ResourceAllocation::consumer)
                             .filter(x -> x instanceof IntentId)
                             .map(x -> (IntentId) x);
@@ -331,7 +331,7 @@
             }
 
             Optional<IntentId> intentId =
-                    resourceService.getResourceAllocation(new ResourcePath(oduPort.deviceId(), port.number()))
+                    resourceService.getResourceAllocation(ResourcePath.discrete(oduPort.deviceId(), port.number()))
                             .map(ResourceAllocation::consumer)
                             .filter(x -> x instanceof IntentId)
                             .map(x -> (IntentId) x);
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index 05caa66..a4ed551 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -107,8 +107,8 @@
         log.debug("Compiling optical connectivity intent between {} and {}", src, dst);
 
         // Reserve OCh ports
-        ResourcePath srcPortPath = new ResourcePath(src.deviceId(), src.port());
-        ResourcePath dstPortPath = new ResourcePath(dst.deviceId(), dst.port());
+        ResourcePath srcPortPath = ResourcePath.discrete(src.deviceId(), src.port());
+        ResourcePath dstPortPath = ResourcePath.discrete(dst.deviceId(), dst.port());
         List<org.onosproject.net.newresource.ResourceAllocation> allocation =
                 resourceService.allocate(intent.id(), srcPortPath, dstPortPath);
         if (allocation.isEmpty()) {
@@ -182,7 +182,7 @@
 
         IndexedLambda minLambda = findFirstLambda(lambdas);
         List<ResourcePath> lambdaResources = path.links().stream()
-                .map(x -> new ResourcePath(linkKey(x.src(), x.dst())))
+                .map(x -> ResourcePath.discrete(linkKey(x.src(), x.dst())))
                 .map(x -> x.child(minLambda))
                 .collect(Collectors.toList());
 
@@ -196,7 +196,7 @@
 
     private Set<IndexedLambda> findCommonLambdasOverLinks(List<Link> links) {
         return links.stream()
-                .map(x -> new ResourcePath(linkKey(x.src(), x.dst())))
+                .map(x -> ResourcePath.discrete(linkKey(x.src(), x.dst())))
                 .map(resourceService::getAvailableResources)
                 .map(x -> Iterables.filter(x, r -> r.last() instanceof IndexedLambda))
                 .map(x -> Iterables.transform(x, r -> (IndexedLambda) r.last()))
diff --git a/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java b/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java
index e6d9225..066dd33 100644
--- a/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java
+++ b/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceDeviceListener.java
@@ -75,12 +75,12 @@
     }
 
     private void registerPortResource(Device device, Port port) {
-        ResourcePath parent = new ResourcePath(device.id());
+        ResourcePath parent = ResourcePath.discrete(device.id());
         executor.submit(() -> adminService.registerResources(parent, port.number()));
     }
 
     private void unregisterPortResource(Device device, Port port) {
-        ResourcePath parent = new ResourcePath(device.id());
+        ResourcePath parent = ResourcePath.discrete(device.id());
         executor.submit(() -> adminService.unregisterResources(parent, port.number()));
     }
 }
diff --git a/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java b/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java
index f04c78b..68fd661 100644
--- a/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java
+++ b/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceLinkListener.java
@@ -87,7 +87,7 @@
             LinkKey linkKey = LinkKey.linkKey(link);
             adminService.registerResources(ResourcePath.ROOT, linkKey);
 
-            ResourcePath linkPath = new ResourcePath(linkKey);
+            ResourcePath linkPath = ResourcePath.discrete(linkKey);
             // register VLAN IDs against the link
             if (isEnabled(link, this::isVlanEnabled)) {
                 adminService.registerResources(linkPath, ENTIRE_VLAN_IDS);