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 { ...@@ -43,7 +43,7 @@ public interface ResourceAdminService {
43 * @return true if registration is successfully done, false otherwise. Registration 43 * @return true if registration is successfully done, false otherwise. Registration
44 * succeeds when each resource is not registered or unallocated. 44 * succeeds when each resource is not registered or unallocated.
45 */ 45 */
46 - boolean register(List<Resource> resources); 46 + boolean register(List<? extends Resource> resources);
47 47
48 /** 48 /**
49 * Unregisters the specified resources. 49 * Unregisters the specified resources.
...@@ -63,5 +63,5 @@ public interface ResourceAdminService { ...@@ -63,5 +63,5 @@ public interface ResourceAdminService {
63 * @return true if unregistration is successfully done, false otherwise. Unregistration 63 * @return true if unregistration is successfully done, false otherwise. Unregistration
64 * succeeds when each resource is not registered or unallocated. 64 * succeeds when each resource is not registered or unallocated.
65 */ 65 */
66 - boolean unregister(List<ResourceId> ids); 66 + boolean unregister(List<? extends ResourceId> ids);
67 } 67 }
......
...@@ -66,7 +66,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource ...@@ -66,7 +66,7 @@ public interface ResourceService extends ListenerService<ResourceEvent, Resource
66 * @param resources resources to be allocated 66 * @param resources resources to be allocated
67 * @return non-empty list of allocation information if succeeded, otherwise empty list 67 * @return non-empty list of allocation information if succeeded, otherwise empty list
68 */ 68 */
69 - List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources); 69 + List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources);
70 70
71 /** 71 /**
72 * Transactionally allocates the specified resources to the specified user. 72 * Transactionally allocates the specified resources to the specified user.
......
...@@ -37,7 +37,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat ...@@ -37,7 +37,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
37 * @param resources resources to be registered 37 * @param resources resources to be registered
38 * @return true if the registration succeeds, false otherwise 38 * @return true if the registration succeeds, false otherwise
39 */ 39 */
40 - boolean register(List<Resource> resources); 40 + boolean register(List<? extends Resource> resources);
41 41
42 /** 42 /**
43 * Unregisters the resources in transactional way. 43 * Unregisters the resources in transactional way.
...@@ -48,7 +48,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat ...@@ -48,7 +48,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
48 * @param ids resources to be unregistered 48 * @param ids resources to be unregistered
49 * @return true if the registration succeeds, false otherwise 49 * @return true if the registration succeeds, false otherwise
50 */ 50 */
51 - boolean unregister(List<ResourceId> ids); 51 + boolean unregister(List<? extends ResourceId> ids);
52 52
53 /** 53 /**
54 * Allocates the specified resources to the specified consumer in transactional way. 54 * Allocates the specified resources to the specified consumer in transactional way.
...@@ -60,7 +60,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat ...@@ -60,7 +60,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
60 * @param consumer resource consumer which the resources are allocated to 60 * @param consumer resource consumer which the resources are allocated to
61 * @return true if the allocation succeeds, false otherwise. 61 * @return true if the allocation succeeds, false otherwise.
62 */ 62 */
63 - boolean allocate(List<Resource> resources, ResourceConsumer consumer); 63 + boolean allocate(List<? extends Resource> resources, ResourceConsumer consumer);
64 64
65 /** 65 /**
66 * Releases the specified resources allocated to the specified corresponding consumers 66 * Releases the specified resources allocated to the specified corresponding consumers
......
...@@ -80,7 +80,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent ...@@ -80,7 +80,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent
80 80
81 @Override 81 @Override
82 public List<ResourceAllocation> allocate(ResourceConsumer consumer, 82 public List<ResourceAllocation> allocate(ResourceConsumer consumer,
83 - List<Resource> resources) { 83 + List<? extends Resource> resources) {
84 checkNotNull(consumer); 84 checkNotNull(consumer);
85 checkNotNull(resources); 85 checkNotNull(resources);
86 86
...@@ -171,14 +171,14 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent ...@@ -171,14 +171,14 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent
171 } 171 }
172 172
173 @Override 173 @Override
174 - public boolean register(List<Resource> resources) { 174 + public boolean register(List<? extends Resource> resources) {
175 checkNotNull(resources); 175 checkNotNull(resources);
176 176
177 return store.register(resources); 177 return store.register(resources);
178 } 178 }
179 179
180 @Override 180 @Override
181 - public boolean unregister(List<ResourceId> ids) { 181 + public boolean unregister(List<? extends ResourceId> ids) {
182 checkNotNull(ids); 182 checkNotNull(ids);
183 183
184 return store.unregister(ids); 184 return store.unregister(ids);
......
...@@ -44,7 +44,7 @@ class MockResourceService implements ResourceService { ...@@ -44,7 +44,7 @@ class MockResourceService implements ResourceService {
44 private final Map<Resource, ResourceConsumer> assignment = new HashMap<>(); 44 private final Map<Resource, ResourceConsumer> assignment = new HashMap<>();
45 45
46 @Override 46 @Override
47 - public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { 47 + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
48 assignment.putAll( 48 assignment.putAll(
49 resources.stream().collect(Collectors.toMap(x -> x, x -> consumer)) 49 resources.stream().collect(Collectors.toMap(x -> x, x -> consumer))
50 ); 50 );
......
...@@ -151,7 +151,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour ...@@ -151,7 +151,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
151 } 151 }
152 152
153 @Override 153 @Override
154 - public boolean register(List<Resource> resources) { 154 + public boolean register(List<? extends Resource> resources) {
155 checkNotNull(resources); 155 checkNotNull(resources);
156 if (log.isTraceEnabled()) { 156 if (log.isTraceEnabled()) {
157 resources.forEach(r -> log.trace("registering {}", r)); 157 resources.forEach(r -> log.trace("registering {}", r));
...@@ -190,7 +190,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour ...@@ -190,7 +190,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
190 } 190 }
191 191
192 @Override 192 @Override
193 - public boolean unregister(List<ResourceId> ids) { 193 + public boolean unregister(List<? extends ResourceId> ids) {
194 checkNotNull(ids); 194 checkNotNull(ids);
195 195
196 TransactionContext tx = service.transactionContextBuilder().build(); 196 TransactionContext tx = service.transactionContextBuilder().build();
...@@ -254,7 +254,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour ...@@ -254,7 +254,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
254 } 254 }
255 255
256 @Override 256 @Override
257 - public boolean allocate(List<Resource> resources, ResourceConsumer consumer) { 257 + public boolean allocate(List<? extends Resource> resources, ResourceConsumer consumer) {
258 checkNotNull(resources); 258 checkNotNull(resources);
259 checkNotNull(consumer); 259 checkNotNull(consumer);
260 260
......