Sho SHIMIZU
Committed by Gerrit Code Review

Narrow the scope of the variable

Change-Id: I14be43184e1ebd8d9ab16ab0728d6f84d64699d7
......@@ -99,14 +99,13 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> {
// TODO: implement recompile behavior
List<Link> links = intent.path().links();
List<FlowRule> rules = new LinkedList<>();
Optional<EncapsulationConstraint> encapConstraint = intent.constraints().stream()
.filter(constraint -> constraint instanceof EncapsulationConstraint)
.map(x -> (EncapsulationConstraint) x).findAny();
//if no encapsulation or is involved only a single switch use the default behaviour
if (!encapConstraint.isPresent() || links.size() == 1) {
List<FlowRule> rules = new LinkedList<>();
for (int i = 0; i < links.size() - 1; i++) {
ConnectPoint ingress = links.get(i).dst();
ConnectPoint egress = links.get(i + 1).src();
......@@ -119,6 +118,7 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> {
return ImmutableList.of(new FlowRuleIntent(appId, null, rules, intent.resources()));
}
List<FlowRule> rules = Collections.emptyList();
if (EncapsulationType.VLAN == encapConstraint.get().encapType()) {
rules = manageVlanEncap(intent);
} else if (EncapsulationType.MPLS == encapConstraint.get().encapType()) {
......