Sho SHIMIZU

Return early when the value is null to reduce the depth of indents

Change-Id: I34b01d1888884ee752655d2b2bed1f6facb0b432
...@@ -51,6 +51,7 @@ import com.google.common.collect.ImmutableList; ...@@ -51,6 +51,7 @@ import com.google.common.collect.ImmutableList;
51 import com.google.common.collect.ImmutableSet; 51 import com.google.common.collect.ImmutableSet;
52 52
53 import java.io.IOException; 53 import java.io.IOException;
54 +import java.util.Collections;
54 import java.util.List; 55 import java.util.List;
55 import java.util.Map; 56 import java.util.Map;
56 import java.util.ArrayList; 57 import java.util.ArrayList;
...@@ -291,29 +292,31 @@ public class OFOpticalSwitchImplLINC13 ...@@ -291,29 +292,31 @@ public class OFOpticalSwitchImplLINC13
291 } 292 }
292 293
293 private List<OFAction> buildActions(List<OFInstruction> iList, CircuitSignalID sigid) { 294 private List<OFAction> buildActions(List<OFInstruction> iList, CircuitSignalID sigid) {
294 - List<OFAction> actions = new ArrayList<>();
295 Map<OFInstructionType, OFInstruction> instructions = iList.stream() 295 Map<OFInstructionType, OFInstruction> instructions = iList.stream()
296 .collect(Collectors.toMap(OFInstruction::getType, inst -> inst)); 296 .collect(Collectors.toMap(OFInstruction::getType, inst -> inst));
297 297
298 OFInstruction inst = instructions.get(OFInstructionType.APPLY_ACTIONS); 298 OFInstruction inst = instructions.get(OFInstructionType.APPLY_ACTIONS);
299 - if (inst != null) { 299 + if (inst == null) {
300 - OFInstructionApplyActions iaa = (OFInstructionApplyActions) inst; 300 + return Collections.emptyList();
301 - if (iaa.getActions() == null) { 301 + }
302 - return actions; 302 +
303 - } 303 + List<OFAction> actions = new ArrayList<>();
304 - iaa.getActions().forEach(action -> { 304 + OFInstructionApplyActions iaa = (OFInstructionApplyActions) inst;
305 - if (OFActionType.EXPERIMENTER == action.getType()) { 305 + if (iaa.getActions() == null) {
306 - OFActionCircuit.Builder cBuilder = factory.actions().buildCircuit() 306 + return actions;
307 - .setField(factory.oxms()
308 - .buildOchSigid()
309 - .setValue(sigid)
310 - .build());
311 - actions.add(cBuilder.build());
312 - } else {
313 - actions.add(action);
314 - }
315 - });
316 } 307 }
308 + iaa.getActions().forEach(action -> {
309 + if (OFActionType.EXPERIMENTER == action.getType()) {
310 + OFActionCircuit.Builder cBuilder = factory.actions().buildCircuit()
311 + .setField(factory.oxms()
312 + .buildOchSigid()
313 + .setValue(sigid)
314 + .build());
315 + actions.add(cBuilder.build());
316 + } else {
317 + actions.add(action);
318 + }
319 + });
317 return actions; 320 return actions;
318 } 321 }
319 322
......