Return early when the value is null to reduce the depth of indents
Change-Id: I34b01d1888884ee752655d2b2bed1f6facb0b432
Showing
1 changed file
with
6 additions
and
3 deletions
... | @@ -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,12 +292,15 @@ public class OFOpticalSwitchImplLINC13 | ... | @@ -291,12 +292,15 @@ 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 | + return Collections.emptyList(); | ||
301 | + } | ||
302 | + | ||
303 | + List<OFAction> actions = new ArrayList<>(); | ||
300 | OFInstructionApplyActions iaa = (OFInstructionApplyActions) inst; | 304 | OFInstructionApplyActions iaa = (OFInstructionApplyActions) inst; |
301 | if (iaa.getActions() == null) { | 305 | if (iaa.getActions() == null) { |
302 | return actions; | 306 | return actions; |
... | @@ -313,7 +317,6 @@ public class OFOpticalSwitchImplLINC13 | ... | @@ -313,7 +317,6 @@ public class OFOpticalSwitchImplLINC13 |
313 | actions.add(action); | 317 | actions.add(action); |
314 | } | 318 | } |
315 | }); | 319 | }); |
316 | - } | ||
317 | return actions; | 320 | return actions; |
318 | } | 321 | } |
319 | 322 | ... | ... |
-
Please register or login to post a comment