Sho SHIMIZU

Refactor: Reduce depth of indent

Change-Id: I9a1beb803619cc0ec8b4b23761bbfb03ffc49fa4
...@@ -149,16 +149,17 @@ public class ConsistentLinkResourceStore extends ...@@ -149,16 +149,17 @@ public class ConsistentLinkResourceStore extends
149 } 149 }
150 150
151 private Set<LambdaResourceAllocation> getLambdaResourceCapacity(Link link) { 151 private Set<LambdaResourceAllocation> getLambdaResourceCapacity(Link link) {
152 - Set<LambdaResourceAllocation> allocations = new HashSet<>();
153 Port port = deviceService.getPort(link.src().deviceId(), link.src().port()); 152 Port port = deviceService.getPort(link.src().deviceId(), link.src().port());
154 - if (port instanceof OmsPort) { 153 + if (!(port instanceof OmsPort)) {
155 - OmsPort omsPort = (OmsPort) port; 154 + return Collections.emptySet();
155 + }
156 156
157 + OmsPort omsPort = (OmsPort) port;
158 + Set<LambdaResourceAllocation> allocations = new HashSet<>();
157 // Assume fixed grid for now 159 // Assume fixed grid for now
158 for (int i = 0; i < omsPort.totalChannels(); i++) { 160 for (int i = 0; i < omsPort.totalChannels(); i++) {
159 allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i))); 161 allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
160 } 162 }
161 - }
162 return allocations; 163 return allocations;
163 } 164 }
164 165
...@@ -168,15 +169,16 @@ public class ConsistentLinkResourceStore extends ...@@ -168,15 +169,16 @@ public class ConsistentLinkResourceStore extends
168 // if all fails, use DEFAULT_BANDWIDTH 169 // if all fails, use DEFAULT_BANDWIDTH
169 BandwidthResource bandwidth = DEFAULT_BANDWIDTH; 170 BandwidthResource bandwidth = DEFAULT_BANDWIDTH;
170 String strBw = link.annotations().value(BANDWIDTH); 171 String strBw = link.annotations().value(BANDWIDTH);
171 - if (strBw != null) { 172 + if (strBw == null) {
173 + return new BandwidthResourceAllocation(bandwidth);
174 + }
175 +
172 try { 176 try {
173 bandwidth = new BandwidthResource(Bandwidth.mbps(Double.parseDouble(strBw))); 177 bandwidth = new BandwidthResource(Bandwidth.mbps(Double.parseDouble(strBw)));
174 } catch (NumberFormatException e) { 178 } catch (NumberFormatException e) {
175 // do nothings, use default bandwidth 179 // do nothings, use default bandwidth
176 bandwidth = DEFAULT_BANDWIDTH; 180 bandwidth = DEFAULT_BANDWIDTH;
177 } 181 }
178 - }
179 -
180 return new BandwidthResourceAllocation(bandwidth); 182 return new BandwidthResourceAllocation(bandwidth);
181 } 183 }
182 184
......