Sho SHIMIZU

Remove wildcard type parameter to simplify declarations

Change-Id: I628dc39704b357fcfc07a453fc54d55f1cc4d755
...@@ -135,7 +135,7 @@ public class ConsistentLinkResourceStore extends ...@@ -135,7 +135,7 @@ public class ConsistentLinkResourceStore extends
135 return storageService.transactionContextBuilder().build(); 135 return storageService.transactionContextBuilder().build();
136 } 136 }
137 137
138 - private Set<? extends ResourceAllocation> getResourceCapacity(ResourceType type, Link link) { 138 + private Set<ResourceAllocation> getResourceCapacity(ResourceType type, Link link) {
139 if (type == ResourceType.BANDWIDTH) { 139 if (type == ResourceType.BANDWIDTH) {
140 return ImmutableSet.of(getBandwidthResourceCapacity(link)); 140 return ImmutableSet.of(getBandwidthResourceCapacity(link));
141 } 141 }
...@@ -148,14 +148,14 @@ public class ConsistentLinkResourceStore extends ...@@ -148,14 +148,14 @@ public class ConsistentLinkResourceStore extends
148 return ImmutableSet.of(); 148 return ImmutableSet.of();
149 } 149 }
150 150
151 - private Set<LambdaResourceAllocation> getLambdaResourceCapacity(Link link) { 151 + private Set<ResourceAllocation> getLambdaResourceCapacity(Link link) {
152 Port port = deviceService.getPort(link.src().deviceId(), link.src().port()); 152 Port port = deviceService.getPort(link.src().deviceId(), link.src().port());
153 if (!(port instanceof OmsPort)) { 153 if (!(port instanceof OmsPort)) {
154 return Collections.emptySet(); 154 return Collections.emptySet();
155 } 155 }
156 156
157 OmsPort omsPort = (OmsPort) port; 157 OmsPort omsPort = (OmsPort) port;
158 - Set<LambdaResourceAllocation> allocations = new HashSet<>(); 158 + Set<ResourceAllocation> allocations = new HashSet<>();
159 // Assume fixed grid for now 159 // Assume fixed grid for now
160 for (int i = 0; i < omsPort.totalChannels(); i++) { 160 for (int i = 0; i < omsPort.totalChannels(); i++) {
161 allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i))); 161 allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
...@@ -182,8 +182,8 @@ public class ConsistentLinkResourceStore extends ...@@ -182,8 +182,8 @@ public class ConsistentLinkResourceStore extends
182 return new BandwidthResourceAllocation(bandwidth); 182 return new BandwidthResourceAllocation(bandwidth);
183 } 183 }
184 184
185 - private Set<MplsLabelResourceAllocation> getMplsResourceCapacity() { 185 + private Set<ResourceAllocation> getMplsResourceCapacity() {
186 - Set<MplsLabelResourceAllocation> allocations = new HashSet<>(); 186 + Set<ResourceAllocation> allocations = new HashSet<>();
187 //Ignoring reserved labels of 0 through 15 187 //Ignoring reserved labels of 0 through 15
188 for (int i = MIN_UNRESERVED_LABEL; i <= MAX_UNRESERVED_LABEL; i++) { 188 for (int i = MIN_UNRESERVED_LABEL; i <= MAX_UNRESERVED_LABEL; i++) {
189 allocations.add(new MplsLabelResourceAllocation(MplsLabel 189 allocations.add(new MplsLabelResourceAllocation(MplsLabel
...@@ -193,10 +193,10 @@ public class ConsistentLinkResourceStore extends ...@@ -193,10 +193,10 @@ public class ConsistentLinkResourceStore extends
193 return allocations; 193 return allocations;
194 } 194 }
195 195
196 - private Map<ResourceType, Set<? extends ResourceAllocation>> getResourceCapacity(Link link) { 196 + private Map<ResourceType, Set<ResourceAllocation>> getResourceCapacity(Link link) {
197 - Map<ResourceType, Set<? extends ResourceAllocation>> caps = new HashMap<>(); 197 + Map<ResourceType, Set<ResourceAllocation>> caps = new HashMap<>();
198 for (ResourceType type : ResourceType.values()) { 198 for (ResourceType type : ResourceType.values()) {
199 - Set<? extends ResourceAllocation> cap = getResourceCapacity(type, link); 199 + Set<ResourceAllocation> cap = getResourceCapacity(type, link);
200 caps.put(type, cap); 200 caps.put(type, cap);
201 } 201 }
202 return caps; 202 return caps;
...@@ -208,7 +208,7 @@ public class ConsistentLinkResourceStore extends ...@@ -208,7 +208,7 @@ public class ConsistentLinkResourceStore extends
208 208
209 tx.begin(); 209 tx.begin();
210 try { 210 try {
211 - Map<ResourceType, Set<? extends ResourceAllocation>> freeResources = getFreeResourcesEx(tx, link); 211 + Map<ResourceType, Set<ResourceAllocation>> freeResources = getFreeResourcesEx(tx, link);
212 Set<ResourceAllocation> allFree = new HashSet<>(); 212 Set<ResourceAllocation> allFree = new HashSet<>();
213 freeResources.values().forEach(allFree::addAll); 213 freeResources.values().forEach(allFree::addAll);
214 return allFree; 214 return allFree;
...@@ -217,12 +217,12 @@ public class ConsistentLinkResourceStore extends ...@@ -217,12 +217,12 @@ public class ConsistentLinkResourceStore extends
217 } 217 }
218 } 218 }
219 219
220 - private Map<ResourceType, Set<? extends ResourceAllocation>> getFreeResourcesEx(TransactionContext tx, Link link) { 220 + private Map<ResourceType, Set<ResourceAllocation>> getFreeResourcesEx(TransactionContext tx, Link link) {
221 checkNotNull(tx); 221 checkNotNull(tx);
222 checkNotNull(link); 222 checkNotNull(link);
223 223
224 - Map<ResourceType, Set<? extends ResourceAllocation>> free = new HashMap<>(); 224 + Map<ResourceType, Set<ResourceAllocation>> free = new HashMap<>();
225 - final Map<ResourceType, Set<? extends ResourceAllocation>> caps = getResourceCapacity(link); 225 + final Map<ResourceType, Set<ResourceAllocation>> caps = getResourceCapacity(link);
226 final Iterable<LinkResourceAllocations> allocations = getAllocations(tx, link); 226 final Iterable<LinkResourceAllocations> allocations = getAllocations(tx, link);
227 227
228 for (ResourceType type : ResourceType.values()) { 228 for (ResourceType type : ResourceType.values()) {
...@@ -230,7 +230,7 @@ public class ConsistentLinkResourceStore extends ...@@ -230,7 +230,7 @@ public class ConsistentLinkResourceStore extends
230 230
231 switch (type) { 231 switch (type) {
232 case BANDWIDTH: 232 case BANDWIDTH:
233 - Set<? extends ResourceAllocation> bw = caps.get(type); 233 + Set<ResourceAllocation> bw = caps.get(type);
234 if (bw == null || bw.isEmpty()) { 234 if (bw == null || bw.isEmpty()) {
235 bw = Sets.newHashSet(new BandwidthResourceAllocation(EMPTY_BW)); 235 bw = Sets.newHashSet(new BandwidthResourceAllocation(EMPTY_BW));
236 } 236 }
...@@ -251,42 +251,38 @@ public class ConsistentLinkResourceStore extends ...@@ -251,42 +251,38 @@ public class ConsistentLinkResourceStore extends
251 new BandwidthResourceAllocation(new BandwidthResource(Bandwidth.bps(freeBw))))); 251 new BandwidthResourceAllocation(new BandwidthResource(Bandwidth.bps(freeBw)))));
252 break; 252 break;
253 case LAMBDA: 253 case LAMBDA:
254 - Set<? extends ResourceAllocation> lmd = caps.get(type); 254 + Set<ResourceAllocation> lmd = caps.get(type);
255 if (lmd == null || lmd.isEmpty()) { 255 if (lmd == null || lmd.isEmpty()) {
256 // nothing left 256 // nothing left
257 break; 257 break;
258 } 258 }
259 - Set<LambdaResourceAllocation> freeL = lmd.stream() 259 + Set<ResourceAllocation> freeL = lmd.stream()
260 .filter(x -> x instanceof LambdaResourceAllocation) 260 .filter(x -> x instanceof LambdaResourceAllocation)
261 - .map(x -> (LambdaResourceAllocation) x)
262 .collect(Collectors.toSet()); 261 .collect(Collectors.toSet());
263 262
264 // enumerate current allocations, removing resources 263 // enumerate current allocations, removing resources
265 - List<LambdaResourceAllocation> allocatedLambda = ImmutableList.copyOf(allocations).stream() 264 + List<ResourceAllocation> allocatedLambda = ImmutableList.copyOf(allocations).stream()
266 .flatMap(x -> x.getResourceAllocation(link).stream()) 265 .flatMap(x -> x.getResourceAllocation(link).stream())
267 .filter(x -> x instanceof LambdaResourceAllocation) 266 .filter(x -> x instanceof LambdaResourceAllocation)
268 - .map(x -> (LambdaResourceAllocation) x)
269 .collect(Collectors.toList()); 267 .collect(Collectors.toList());
270 freeL.removeAll(allocatedLambda); 268 freeL.removeAll(allocatedLambda);
271 269
272 free.put(type, freeL); 270 free.put(type, freeL);
273 break; 271 break;
274 case MPLS_LABEL: 272 case MPLS_LABEL:
275 - Set<? extends ResourceAllocation> mpls = caps.get(type); 273 + Set<ResourceAllocation> mpls = caps.get(type);
276 if (mpls == null || mpls.isEmpty()) { 274 if (mpls == null || mpls.isEmpty()) {
277 // nothing left 275 // nothing left
278 break; 276 break;
279 } 277 }
280 - Set<MplsLabelResourceAllocation> freeLabel = mpls.stream() 278 + Set<ResourceAllocation> freeLabel = mpls.stream()
281 .filter(x -> x instanceof MplsLabelResourceAllocation) 279 .filter(x -> x instanceof MplsLabelResourceAllocation)
282 - .map(x -> (MplsLabelResourceAllocation) x)
283 .collect(Collectors.toSet()); 280 .collect(Collectors.toSet());
284 281
285 // enumerate current allocations, removing resources 282 // enumerate current allocations, removing resources
286 - List<MplsLabelResourceAllocation> allocatedLabel = ImmutableList.copyOf(allocations).stream() 283 + List<ResourceAllocation> allocatedLabel = ImmutableList.copyOf(allocations).stream()
287 .flatMap(x -> x.getResourceAllocation(link).stream()) 284 .flatMap(x -> x.getResourceAllocation(link).stream())
288 .filter(x -> x instanceof MplsLabelResourceAllocation) 285 .filter(x -> x instanceof MplsLabelResourceAllocation)
289 - .map(x -> (MplsLabelResourceAllocation) x)
290 .collect(Collectors.toList()); 286 .collect(Collectors.toList());
291 freeLabel.removeAll(allocatedLabel); 287 freeLabel.removeAll(allocatedLabel);
292 288
...@@ -322,9 +318,9 @@ public class ConsistentLinkResourceStore extends ...@@ -322,9 +318,9 @@ public class ConsistentLinkResourceStore extends
322 LinkResourceAllocations allocations) { 318 LinkResourceAllocations allocations) {
323 // requested resources 319 // requested resources
324 Set<ResourceAllocation> reqs = allocations.getResourceAllocation(link); 320 Set<ResourceAllocation> reqs = allocations.getResourceAllocation(link);
325 - Map<ResourceType, Set<? extends ResourceAllocation>> available = getFreeResourcesEx(tx, link); 321 + Map<ResourceType, Set<ResourceAllocation>> available = getFreeResourcesEx(tx, link);
326 for (ResourceAllocation req : reqs) { 322 for (ResourceAllocation req : reqs) {
327 - Set<? extends ResourceAllocation> avail = available.get(req.type()); 323 + Set<ResourceAllocation> avail = available.get(req.type());
328 if (req instanceof BandwidthResourceAllocation) { 324 if (req instanceof BandwidthResourceAllocation) {
329 // check if allocation should be accepted 325 // check if allocation should be accepted
330 if (avail.isEmpty()) { 326 if (avail.isEmpty()) {
......