Sho SHIMIZU
Committed by Gerrit Code Review

Use lower bound wildcard for API to be more flexible

Change-Id: Ia6bcec5afb2e872b55bae4bbd9139ad35ce01284
......@@ -43,7 +43,7 @@ public interface ResourceAdminService {
* @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 @@ public interface ResourceAdminService {
* @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);
}
......
......@@ -66,7 +66,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource
* @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.
......
......@@ -37,7 +37,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
* @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 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
* @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 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
* @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 resources allocated to the specified corresponding consumers
......
......@@ -80,7 +80,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent
@Override
public List<ResourceAllocation> allocate(ResourceConsumer consumer,
List<Resource> resources) {
List<? extends Resource> resources) {
checkNotNull(consumer);
checkNotNull(resources);
......@@ -171,14 +171,14 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent
}
@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);
......
......@@ -44,7 +44,7 @@ class MockResourceService implements ResourceService {
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(x -> x, x -> consumer))
);
......
......@@ -151,7 +151,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
}
@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));
......@@ -190,7 +190,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
}
@Override
public boolean unregister(List<ResourceId> ids) {
public boolean unregister(List<? extends ResourceId> ids) {
checkNotNull(ids);
TransactionContext tx = service.transactionContextBuilder().build();
......@@ -254,7 +254,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
}
@Override
public boolean allocate(List<Resource> resources, ResourceConsumer consumer) {
public boolean allocate(List<? extends Resource> resources, ResourceConsumer consumer) {
checkNotNull(resources);
checkNotNull(consumer);
......