Make use of Optional more idiomatic
Change-Id: Ibe8f07a5de6b2927217cff5aeb29c6c103cd96ef
Showing
1 changed file
with
11 additions
and
8 deletions
... | @@ -26,7 +26,6 @@ import org.onlab.packet.VlanId; | ... | @@ -26,7 +26,6 @@ import org.onlab.packet.VlanId; |
26 | import org.onosproject.core.ApplicationId; | 26 | import org.onosproject.core.ApplicationId; |
27 | import org.onosproject.core.CoreService; | 27 | import org.onosproject.core.CoreService; |
28 | import org.onosproject.net.ConnectPoint; | 28 | import org.onosproject.net.ConnectPoint; |
29 | -import org.onosproject.net.EncapsulationType; | ||
30 | import org.onosproject.net.Link; | 29 | import org.onosproject.net.Link; |
31 | import org.onosproject.net.LinkKey; | 30 | import org.onosproject.net.LinkKey; |
32 | import org.onosproject.net.flow.DefaultFlowRule; | 31 | import org.onosproject.net.flow.DefaultFlowRule; |
... | @@ -118,13 +117,17 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { | ... | @@ -118,13 +117,17 @@ public class PathIntentCompiler implements IntentCompiler<PathIntent> { |
118 | return ImmutableList.of(new FlowRuleIntent(appId, null, rules, intent.resources())); | 117 | return ImmutableList.of(new FlowRuleIntent(appId, null, rules, intent.resources())); |
119 | } | 118 | } |
120 | 119 | ||
121 | - List<FlowRule> rules = Collections.emptyList(); | 120 | + List<FlowRule> rules = encapConstraint.map(EncapsulationConstraint::encapType) |
122 | - if (EncapsulationType.VLAN == encapConstraint.get().encapType()) { | 121 | + .map(type -> { |
123 | - rules = manageVlanEncap(intent); | 122 | + switch (type) { |
124 | - } else if (EncapsulationType.MPLS == encapConstraint.get().encapType()) { | 123 | + case VLAN: |
125 | - //TODO: to be implemented | 124 | + return manageVlanEncap(intent); |
126 | - rules = Collections.emptyList(); | 125 | + // TODO: implement MPLS case here |
127 | - } | 126 | + default: |
127 | + return Collections.<FlowRule>emptyList(); | ||
128 | + } | ||
129 | + }) | ||
130 | + .orElse(Collections.emptyList()); | ||
128 | 131 | ||
129 | return ImmutableList.of(new FlowRuleIntent(appId, null, rules, intent.resources())); | 132 | return ImmutableList.of(new FlowRuleIntent(appId, null, rules, intent.resources())); |
130 | } | 133 | } | ... | ... |
-
Please register or login to post a comment