Sho SHIMIZU

Refactor: Reduce depth of indent

Change-Id: I9a1beb803619cc0ec8b4b23761bbfb03ffc49fa4
...@@ -149,15 +149,16 @@ public class ConsistentLinkResourceStore extends ...@@ -149,15 +149,16 @@ 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 - // Assume fixed grid for now 157 + OmsPort omsPort = (OmsPort) port;
158 - for (int i = 0; i < omsPort.totalChannels(); i++) { 158 + Set<LambdaResourceAllocation> allocations = new HashSet<>();
159 - allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i))); 159 + // Assume fixed grid for now
160 - } 160 + for (int i = 0; i < omsPort.totalChannels(); i++) {
161 + allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
161 } 162 }
162 return allocations; 163 return allocations;
163 } 164 }
...@@ -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) {
172 - try { 173 + return new BandwidthResourceAllocation(bandwidth);
173 - bandwidth = new BandwidthResource(Bandwidth.mbps(Double.parseDouble(strBw)));
174 - } catch (NumberFormatException e) {
175 - // do nothings, use default bandwidth
176 - bandwidth = DEFAULT_BANDWIDTH;
177 - }
178 } 174 }
179 175
176 + try {
177 + bandwidth = new BandwidthResource(Bandwidth.mbps(Double.parseDouble(strBw)));
178 + } catch (NumberFormatException e) {
179 + // do nothings, use default bandwidth
180 + bandwidth = DEFAULT_BANDWIDTH;
181 + }
180 return new BandwidthResourceAllocation(bandwidth); 182 return new BandwidthResourceAllocation(bandwidth);
181 } 183 }
182 184
......