Make ResourceService API more flexible in parameter
Change-Id: Ic8b803cc6ae3b2798de525bfd6545ac5c57e8fdd
diff --git a/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalPathProvisionerTest.java b/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalPathProvisionerTest.java
index 669124d..3968a99 100644
--- a/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalPathProvisionerTest.java
+++ b/apps/newoptical/src/test/java/org/onosproject/newoptical/OpticalPathProvisionerTest.java
@@ -808,7 +808,7 @@
private static class TestResourceService implements ResourceService {
@Override
- public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
+ public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
List<ResourceAllocation> allocations = new ArrayList<>();
resources.forEach(r -> allocations.add(new ResourceAllocation(r, consumer.consumerId())));
@@ -955,4 +955,4 @@
return 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
index 9e68702..c49fb27 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
@@ -300,7 +300,7 @@
}
@Override
- public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
+ public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
for (Resource resource: resources) {
if (resource instanceof ContinuousResource) {
List<ResourceAllocation> allocs = new LinkedList<>();
@@ -1197,4 +1197,4 @@
UNKNOWN, UNKNOWN, UNKNOWN,
UNKNOWN, new ChassisId(), builder.build()));
}
-}
\ No newline at end of file
+}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/ResourceServiceAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/ResourceServiceAdapter.java
index 791ca6e..be21282 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/ResourceServiceAdapter.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/ResourceServiceAdapter.java
@@ -43,7 +43,7 @@
}
@Override
- public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
+ public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
// TODO Auto-generated method stub
return null;
}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/ResourceAdminService.java b/core/api/src/main/java/org/onosproject/net/resource/ResourceAdminService.java
index edc3755..a46848a 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/ResourceAdminService.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/ResourceAdminService.java
@@ -43,7 +43,7 @@
* @return true if registration is successfully done, false otherwise. Registration
* succeeds when each resource is not registered or unallocated.
*/
- boolean register(List<Resource> resources);
+ boolean register(List<? extends Resource> resources);
/**
* Unregisters the specified resources.
@@ -63,5 +63,5 @@
* @return true if unregistration is successfully done, false otherwise. Unregistration
* succeeds when each resource is not registered or unallocated.
*/
- boolean unregister(List<ResourceId> ids);
+ boolean unregister(List<? extends ResourceId> ids);
}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/ResourceService.java b/core/api/src/main/java/org/onosproject/net/resource/ResourceService.java
index b52b6b9..7a75296 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/ResourceService.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/ResourceService.java
@@ -64,7 +64,7 @@
* @param resources resources to be allocated
* @return non-empty list of allocation information if succeeded, otherwise empty list
*/
- List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources);
+ List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources);
/**
* Transactionally allocates the specified resources to the specified user.
diff --git a/core/api/src/main/java/org/onosproject/net/resource/ResourceStore.java b/core/api/src/main/java/org/onosproject/net/resource/ResourceStore.java
index 8456106..051b9ca 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/ResourceStore.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/ResourceStore.java
@@ -37,7 +37,7 @@
* @param resources resources to be registered
* @return true if the registration succeeds, false otherwise
*/
- boolean register(List<Resource> resources);
+ boolean register(List<? extends Resource> resources);
/**
* Unregisters the resources in transactional way.
@@ -48,7 +48,7 @@
* @param ids resources to be unregistered
* @return true if the registration succeeds, false otherwise
*/
- boolean unregister(List<ResourceId> ids);
+ boolean unregister(List<? extends ResourceId> ids);
/**
* Allocates the specified resources to the specified consumer in transactional way.
@@ -60,7 +60,7 @@
* @param consumer resource consumer which the resources are allocated to
* @return true if the allocation succeeds, false otherwise.
*/
- boolean allocate(List<Resource> resources, ResourceConsumer consumer);
+ boolean allocate(List<? extends Resource> resources, ResourceConsumer consumer);
/**
* Releases the specified allocated resources in transactional way.
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index 6511cfa..471546e 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -192,7 +192,7 @@
}
@Override
- public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
+ public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
return null;
}
diff --git a/core/api/src/test/java/org/onosproject/net/resource/MockResourceService.java b/core/api/src/test/java/org/onosproject/net/resource/MockResourceService.java
index f5f884b..52236b3 100644
--- a/core/api/src/test/java/org/onosproject/net/resource/MockResourceService.java
+++ b/core/api/src/test/java/org/onosproject/net/resource/MockResourceService.java
@@ -38,7 +38,7 @@
private final Map<Resource, ResourceConsumer> assignment = new HashMap<>();
@Override
- public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
+ public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
assignment.putAll(
resources.stream().collect(Collectors.toMap(Function.identity(), x -> consumer))
);
diff --git a/core/net/src/main/java/org/onosproject/net/resource/impl/ResourceManager.java b/core/net/src/main/java/org/onosproject/net/resource/impl/ResourceManager.java
index 52ea71d..606c80d 100644
--- a/core/net/src/main/java/org/onosproject/net/resource/impl/ResourceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/resource/impl/ResourceManager.java
@@ -84,7 +84,7 @@
@Override
public List<ResourceAllocation> allocate(ResourceConsumer consumer,
- List<Resource> resources) {
+ List<? extends Resource> resources) {
checkPermission(RESOURCE_WRITE);
checkNotNull(consumer);
checkNotNull(resources);
@@ -202,14 +202,14 @@
}
@Override
- public boolean register(List<Resource> resources) {
+ public boolean register(List<? extends Resource> resources) {
checkNotNull(resources);
return store.register(resources);
}
@Override
- public boolean unregister(List<ResourceId> ids) {
+ public boolean unregister(List<? extends ResourceId> ids) {
checkNotNull(ids);
return store.unregister(ids);
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentResourceStore.java
index c5a1d03..7572406 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentResourceStore.java
@@ -113,7 +113,7 @@
}
@Override
- public boolean register(List<Resource> resources) {
+ public boolean register(List<? extends Resource> resources) {
checkNotNull(resources);
if (log.isTraceEnabled()) {
resources.forEach(r -> log.trace("registering {}", r));
@@ -155,7 +155,7 @@
}
@Override
- public boolean unregister(List<ResourceId> ids) {
+ public boolean unregister(List<? extends ResourceId> ids) {
checkNotNull(ids);
TransactionContext tx = service.transactionContextBuilder().build();
@@ -204,7 +204,7 @@
}
@Override
- public boolean allocate(List<Resource> resources, ResourceConsumer consumer) {
+ public boolean allocate(List<? extends Resource> resources, ResourceConsumer consumer) {
checkNotNull(resources);
checkNotNull(consumer);
diff --git a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProviderTest.java b/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProviderTest.java
index dd8721b..30a3886 100644
--- a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProviderTest.java
+++ b/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProviderTest.java
@@ -274,7 +274,7 @@
Map<ResourceId, List<Resource>> registeredRes = new HashMap<>();
@Override
- public boolean register(List<Resource> resources) {
+ public boolean register(List<? extends Resource> resources) {
for (Resource res : resources) {
List<Resource> resource = new LinkedList<>();
resource.add(res);
@@ -287,7 +287,7 @@
}
@Override
- public boolean unregister(List<ResourceId> ids) {
+ public boolean unregister(List<? extends ResourceId> ids) {
for (ResourceId id : ids) {
if (registeredRes.containsKey(id)) {
registeredRes.remove(id);