Refactor: Reduce depth of indent
Change-Id: I9a1beb803619cc0ec8b4b23761bbfb03ffc49fa4
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
index e11ead5..65179ae 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
@@ -149,15 +149,16 @@
}
private Set<LambdaResourceAllocation> getLambdaResourceCapacity(Link link) {
- Set<LambdaResourceAllocation> allocations = new HashSet<>();
Port port = deviceService.getPort(link.src().deviceId(), link.src().port());
- if (port instanceof OmsPort) {
- OmsPort omsPort = (OmsPort) port;
+ if (!(port instanceof OmsPort)) {
+ return Collections.emptySet();
+ }
- // Assume fixed grid for now
- for (int i = 0; i < omsPort.totalChannels(); i++) {
- allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
- }
+ OmsPort omsPort = (OmsPort) port;
+ Set<LambdaResourceAllocation> allocations = new HashSet<>();
+ // Assume fixed grid for now
+ for (int i = 0; i < omsPort.totalChannels(); i++) {
+ allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
}
return allocations;
}
@@ -168,15 +169,16 @@
// if all fails, use DEFAULT_BANDWIDTH
BandwidthResource bandwidth = DEFAULT_BANDWIDTH;
String strBw = link.annotations().value(BANDWIDTH);
- if (strBw != null) {
- try {
- bandwidth = new BandwidthResource(Bandwidth.mbps(Double.parseDouble(strBw)));
- } catch (NumberFormatException e) {
- // do nothings, use default bandwidth
- bandwidth = DEFAULT_BANDWIDTH;
- }
+ if (strBw == null) {
+ return new BandwidthResourceAllocation(bandwidth);
}
+ try {
+ bandwidth = new BandwidthResource(Bandwidth.mbps(Double.parseDouble(strBw)));
+ } catch (NumberFormatException e) {
+ // do nothings, use default bandwidth
+ bandwidth = DEFAULT_BANDWIDTH;
+ }
return new BandwidthResourceAllocation(bandwidth);
}