Refactor: Rename ResourcePath to Resource for a better name

Also the followings
- Rename variables from path to resource
- Update Javadoc

Change-Id: I07da7e7d13882f2134a3687c66ed91a9de5b0849
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 5549918..a9bf1b7 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
@@ -49,7 +49,7 @@
 import org.onosproject.net.intent.IntentCompiler;
 import org.onosproject.net.intent.IntentExtensionService;
 import org.onosproject.net.intent.MplsPathIntent;
-import org.onosproject.net.newresource.ResourcePath;
+import org.onosproject.net.newresource.Resource;
 import org.onosproject.net.newresource.ResourceService;
 import org.onosproject.net.resource.link.LinkResourceAllocations;
 import org.slf4j.Logger;
@@ -123,10 +123,10 @@
 
         // for short term solution: same label is used for both directions
         // TODO: introduce the concept of Tx and Rx resources of a port
-        Set<ResourcePath> resources = labels.entrySet().stream()
+        Set<Resource> resources = labels.entrySet().stream()
                 .flatMap(x -> Stream.of(
-                        ResourcePath.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()),
-                        ResourcePath.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue())
+                        Resource.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()),
+                        Resource.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue())
                 ))
                 .collect(Collectors.toSet());
         List<org.onosproject.net.newresource.ResourceAllocation> allocations =
@@ -154,7 +154,7 @@
     }
 
     private Set<MplsLabel> findMplsLabel(ConnectPoint cp) {
-        return resourceService.getAvailableResources(ResourcePath.discrete(cp.deviceId(), cp.port())).stream()
+        return resourceService.getAvailableResources(Resource.discrete(cp.deviceId(), cp.port())).stream()
                 .filter(x -> x.last() instanceof MplsLabel)
                 .map(x -> (MplsLabel) x.last())
                 .collect(Collectors.toSet());
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 2c547ea..9bcd7a9 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
@@ -50,7 +50,7 @@
 import org.onosproject.net.intent.OpticalConnectivityIntent;
 import org.onosproject.net.intent.impl.IntentCompilationException;
 import org.onosproject.net.newresource.ResourceAllocation;
-import org.onosproject.net.newresource.ResourcePath;
+import org.onosproject.net.newresource.Resource;
 import org.onosproject.net.newresource.ResourceService;
 import org.onosproject.net.resource.device.IntentSetMultimap;
 import org.onosproject.net.resource.link.LinkResourceAllocations;
@@ -160,9 +160,9 @@
         log.debug("Compiling optical circuit intent between {} and {}", src, dst);
 
         // Reserve OduClt ports
-        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);
+        Resource srcPortResource = Resource.discrete(src.deviceId(), src.port());
+        Resource dstPortResource = Resource.discrete(dst.deviceId(), dst.port());
+        List<ResourceAllocation> allocation = resourceService.allocate(intent.id(), srcPortResource, dstPortResource);
         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(ResourcePath.discrete(ochCP.deviceId(), ochCP.port()))
+                    resourceService.getResourceAllocation(Resource.discrete(ochCP.deviceId(), ochCP.port()))
                             .stream()
                             .map(ResourceAllocation::consumer)
                             .filter(x -> x instanceof IntentId)
@@ -333,7 +333,7 @@
             }
 
             Optional<IntentId> intentId =
-                    resourceService.getResourceAllocation(ResourcePath.discrete(oduPort.deviceId(), port.number()))
+                    resourceService.getResourceAllocation(Resource.discrete(oduPort.deviceId(), port.number()))
                             .stream()
                             .map(ResourceAllocation::consumer)
                             .filter(x -> x instanceof IntentId)
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 2d4545c..44d0894 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
@@ -44,7 +44,7 @@
 import org.onosproject.net.intent.OpticalPathIntent;
 import org.onosproject.net.intent.impl.IntentCompilationException;
 import org.onosproject.net.newresource.ResourceAllocation;
-import org.onosproject.net.newresource.ResourcePath;
+import org.onosproject.net.newresource.Resource;
 import org.onosproject.net.newresource.ResourceService;
 import org.onosproject.net.resource.link.LinkResourceAllocations;
 import org.onosproject.net.topology.LinkWeight;
@@ -109,10 +109,10 @@
         log.debug("Compiling optical connectivity intent between {} and {}", src, dst);
 
         // Reserve OCh ports
-        ResourcePath srcPortPath = ResourcePath.discrete(src.deviceId(), src.port());
-        ResourcePath dstPortPath = ResourcePath.discrete(dst.deviceId(), dst.port());
+        Resource srcPortResource = Resource.discrete(src.deviceId(), src.port());
+        Resource dstPortResource = Resource.discrete(dst.deviceId(), dst.port());
         List<org.onosproject.net.newresource.ResourceAllocation> allocation =
-                resourceService.allocate(intent.id(), srcPortPath, dstPortPath);
+                resourceService.allocate(intent.id(), srcPortResource, dstPortResource);
         if (allocation.isEmpty()) {
             throw new IntentCompilationException("Unable to reserve ports for intent " + intent);
         }
@@ -182,10 +182,10 @@
         }
 
         List<OchSignal> minLambda = findFirstLambda(lambdas, slotCount());
-        List<ResourcePath> lambdaResources = path.links().stream()
+        List<Resource> lambdaResources = path.links().stream()
                 .flatMap(x -> Stream.of(
-                        ResourcePath.discrete(x.src().deviceId(), x.src().port()),
-                        ResourcePath.discrete(x.dst().deviceId(), x.dst().port())
+                        Resource.discrete(x.src().deviceId(), x.src().port()),
+                        Resource.discrete(x.dst().deviceId(), x.dst().port())
                 ))
                 .flatMap(x -> minLambda.stream().map(l -> x.child(l)))
                 .collect(Collectors.toList());
@@ -214,8 +214,8 @@
     private Set<OchSignal> findCommonLambdasOverLinks(List<Link> links) {
         return links.stream()
                 .flatMap(x -> Stream.of(
-                        ResourcePath.discrete(x.src().deviceId(), x.src().port()),
-                        ResourcePath.discrete(x.dst().deviceId(), x.dst().port())
+                        Resource.discrete(x.src().deviceId(), x.src().port()),
+                        Resource.discrete(x.dst().deviceId(), x.dst().port())
                 ))
                 .map(resourceService::getAvailableResources)
                 .map(x -> Iterables.filter(x, r -> r.last() instanceof OchSignal))
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
index ffced6c..ec7cfd7 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
@@ -44,7 +44,7 @@
 import org.onosproject.net.intent.PathIntent;
 import org.onosproject.net.intent.constraint.EncapsulationConstraint;
 import org.onosproject.net.intent.impl.IntentCompilationException;
-import org.onosproject.net.newresource.ResourcePath;
+import org.onosproject.net.newresource.Resource;
 import org.onosproject.net.newresource.ResourceService;
 import org.onosproject.net.resource.link.LinkResourceAllocations;
 import org.slf4j.Logger;
@@ -250,10 +250,10 @@
         }
 
         //same VLANID is used for both directions
-        Set<ResourcePath> resources = vlanIds.entrySet().stream()
+        Set<Resource> resources = vlanIds.entrySet().stream()
                 .flatMap(x -> Stream.of(
-                        ResourcePath.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()),
-                        ResourcePath.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue())
+                        Resource.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue()),
+                        Resource.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue())
                 ))
                 .collect(Collectors.toSet());
         List<org.onosproject.net.newresource.ResourceAllocation> allocations =
@@ -280,7 +280,7 @@
     }
 
     private Set<VlanId> findVlanId(ConnectPoint cp) {
-        return resourceService.getAvailableResources(ResourcePath.discrete(cp.deviceId(), cp.port())).stream()
+        return resourceService.getAvailableResources(Resource.discrete(cp.deviceId(), cp.port())).stream()
                 .filter(x -> x.last() instanceof VlanId)
                 .map(x -> (VlanId) x.last())
                 .collect(Collectors.toSet());
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 b9b11dc..0b793a9 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
@@ -35,7 +35,7 @@
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.net.driver.DriverService;
 import org.onosproject.net.newresource.ResourceAdminService;
-import org.onosproject.net.newresource.ResourcePath;
+import org.onosproject.net.newresource.Resource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -108,15 +108,15 @@
     }
 
     private void registerDeviceResource(Device device) {
-        executor.submit(() -> adminService.registerResources(ResourcePath.discrete(device.id())));
+        executor.submit(() -> adminService.registerResources(Resource.discrete(device.id())));
     }
 
     private void unregisterDeviceResource(Device device) {
-        executor.submit(() -> adminService.unregisterResources(ResourcePath.discrete(device.id())));
+        executor.submit(() -> adminService.unregisterResources(Resource.discrete(device.id())));
     }
 
     private void registerPortResource(Device device, Port port) {
-        ResourcePath portPath = ResourcePath.discrete(device.id(), port.number());
+        Resource portPath = Resource.discrete(device.id(), port.number());
         executor.submit(() -> {
             adminService.registerResources(portPath);
 
@@ -155,7 +155,7 @@
     }
 
     private void unregisterPortResource(Device device, Port port) {
-        ResourcePath resource = ResourcePath.discrete(device.id(), port.number());
+        Resource resource = Resource.discrete(device.id(), port.number());
         executor.submit(() -> adminService.unregisterResources(resource));
     }
 
diff --git a/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java b/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
index eaf4b59..96466d5 100644
--- a/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
@@ -31,7 +31,7 @@
 import org.onosproject.net.newresource.ResourceEvent;
 import org.onosproject.net.newresource.ResourceListener;
 import org.onosproject.net.newresource.ResourceService;
-import org.onosproject.net.newresource.ResourcePath;
+import org.onosproject.net.newresource.Resource;
 import org.onosproject.net.newresource.ResourceStore;
 import org.onosproject.net.newresource.ResourceStoreDelegate;
 
@@ -69,7 +69,7 @@
 
     @Override
     public List<ResourceAllocation> allocate(ResourceConsumer consumer,
-                                             List<ResourcePath> resources) {
+                                             List<Resource> resources) {
         checkNotNull(consumer);
         checkNotNull(resources);
 
@@ -87,7 +87,7 @@
     public boolean release(List<ResourceAllocation> allocations) {
         checkNotNull(allocations);
 
-        List<ResourcePath> resources = allocations.stream()
+        List<Resource> resources = allocations.stream()
                 .map(ResourceAllocation::resource)
                 .collect(Collectors.toList());
         List<ResourceConsumer> consumers = allocations.stream()
@@ -106,7 +106,7 @@
     }
 
     @Override
-    public List<ResourceAllocation> getResourceAllocation(ResourcePath resource) {
+    public List<ResourceAllocation> getResourceAllocation(Resource resource) {
         checkNotNull(resource);
 
         List<ResourceConsumer> consumers = store.getConsumers(resource);
@@ -116,12 +116,12 @@
     }
 
     @Override
-    public <T> Collection<ResourceAllocation> getResourceAllocations(ResourcePath parent, Class<T> cls) {
+    public <T> Collection<ResourceAllocation> getResourceAllocations(Resource parent, Class<T> cls) {
         checkNotNull(parent);
         checkNotNull(cls);
 
         // We access store twice in this method, then the store may be updated by others
-        Collection<ResourcePath> resources = store.getAllocatedResources(parent, cls);
+        Collection<Resource> resources = store.getAllocatedResources(parent, cls);
         return resources.stream()
                 .flatMap(resource -> store.getConsumers(resource).stream()
                         .map(consumer -> new ResourceAllocation(resource, consumer)))
@@ -132,17 +132,17 @@
     public Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer) {
         checkNotNull(consumer);
 
-        Collection<ResourcePath> resources = store.getResources(consumer);
+        Collection<Resource> resources = store.getResources(consumer);
         return resources.stream()
                 .map(x -> new ResourceAllocation(x, consumer))
                 .collect(Collectors.toList());
     }
 
     @Override
-    public Collection<ResourcePath> getAvailableResources(ResourcePath parent) {
+    public Collection<Resource> getAvailableResources(Resource parent) {
         checkNotNull(parent);
 
-        Collection<ResourcePath> children = store.getChildResources(parent);
+        Collection<Resource> children = store.getChildResources(parent);
         return children.stream()
                 // We access store twice in this method, then the store may be updated by others
                 .filter(store::isAvailable)
@@ -150,21 +150,21 @@
     }
 
     @Override
-    public boolean isAvailable(ResourcePath resource) {
+    public boolean isAvailable(Resource resource) {
         checkNotNull(resource);
 
         return store.isAvailable(resource);
     }
 
     @Override
-    public boolean registerResources(List<ResourcePath> resources) {
+    public boolean registerResources(List<Resource> resources) {
         checkNotNull(resources);
 
         return store.register(resources);
     }
 
     @Override
-    public boolean unregisterResources(List<ResourcePath> resources) {
+    public boolean unregisterResources(List<Resource> resources) {
         checkNotNull(resources);
 
         return store.unregister(resources);
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java
index 7cee0d0..480e6e4 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java
@@ -41,7 +41,7 @@
 import org.onosproject.net.link.LinkEvent;
 import org.onosproject.net.newresource.ResourceEvent;
 import org.onosproject.net.newresource.ResourceListener;
-import org.onosproject.net.newresource.ResourcePath;
+import org.onosproject.net.newresource.Resource;
 import org.onosproject.net.topology.Topology;
 import org.onosproject.net.topology.TopologyEvent;
 import org.onosproject.net.topology.TopologyListener;
@@ -232,7 +232,7 @@
     @Test
     public void testResourceEvent() throws Exception {
         ResourceEvent event = new ResourceEvent(RESOURCE_ADDED,
-                ResourcePath.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)));
+                Resource.discrete(DeviceId.deviceId("a"), PortNumber.portNumber(1)));
         resourceListener.event(event);
 
         assertThat(
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MockResourceService.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MockResourceService.java
index 866c513..16c3c9b 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MockResourceService.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/MockResourceService.java
@@ -21,7 +21,7 @@
 import org.onosproject.net.newresource.ResourceAllocation;
 import org.onosproject.net.newresource.ResourceConsumer;
 import org.onosproject.net.newresource.ResourceListener;
-import org.onosproject.net.newresource.ResourcePath;
+import org.onosproject.net.newresource.Resource;
 import org.onosproject.net.newresource.ResourceService;
 
 import java.util.Collection;
@@ -34,10 +34,10 @@
 
 class MockResourceService implements ResourceService {
 
-    private final Map<ResourcePath, ResourceConsumer> assignment = new HashMap<>();
+    private final Map<Resource, ResourceConsumer> assignment = new HashMap<>();
 
     @Override
-    public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<ResourcePath> resources) {
+    public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
         assignment.putAll(
                 resources.stream().collect(Collectors.toMap(x -> x, x -> consumer))
         );
@@ -56,7 +56,7 @@
 
     @Override
     public boolean release(ResourceConsumer consumer) {
-        List<ResourcePath> resources = assignment.entrySet().stream()
+        List<Resource> resources = assignment.entrySet().stream()
                 .filter(x -> x.getValue().equals(consumer))
                 .map(Map.Entry::getKey)
                 .collect(Collectors.toList());
@@ -68,14 +68,14 @@
     }
 
     @Override
-    public List<ResourceAllocation> getResourceAllocation(ResourcePath resource) {
+    public List<ResourceAllocation> getResourceAllocation(Resource resource) {
         return Optional.ofNullable(assignment.get(resource))
                 .map(x -> ImmutableList.of(new ResourceAllocation(resource, x)))
                 .orElse(ImmutableList.of());
     }
 
     @Override
-    public <T> Collection<ResourceAllocation> getResourceAllocations(ResourcePath parent, Class<T> cls) {
+    public <T> Collection<ResourceAllocation> getResourceAllocations(Resource parent, Class<T> cls) {
         return assignment.entrySet().stream()
                 .filter(x -> x.getKey().parent().isPresent())
                 .filter(x -> x.getKey().parent().get().equals(parent))
@@ -92,16 +92,16 @@
     }
 
     @Override
-    public Collection<ResourcePath> getAvailableResources(ResourcePath parent) {
+    public Collection<Resource> getAvailableResources(Resource parent) {
 
-        Collection<ResourcePath> resources = new HashSet<ResourcePath>();
+        Collection<Resource> resources = new HashSet<Resource>();
         resources.add(parent.child(VlanId.vlanId((short) 10)));
         resources.add(parent.child(MplsLabel.mplsLabel(10)));
         return ImmutableList.copyOf(resources);
     }
 
     @Override
-    public boolean isAvailable(ResourcePath resource) {
+    public boolean isAvailable(Resource resource) {
         return true;
     }