Sho SHIMIZU
Committed by Thomas Vachuska

Add mapping function to simplify process() implementation

Change-Id: I732920bc81d6955b84a222b095bfa18c6974abe3
......@@ -592,6 +592,19 @@ public class FlowRuleManager
}
}
private static FlowRuleBatchEntry.FlowRuleOperation mapOperationType(FlowRuleOperation.Type input) {
switch (input) {
case ADD:
return FlowRuleBatchEntry.FlowRuleOperation.ADD;
case MODIFY:
return FlowRuleBatchEntry.FlowRuleOperation.MODIFY;
case REMOVE:
return FlowRuleBatchEntry.FlowRuleOperation.REMOVE;
default:
throw new UnsupportedOperationException("Unknown flow rule type " + input);
}
}
private class FlowOperationsProcessor implements Runnable {
private final List<Set<FlowRuleOperation>> stages;
......@@ -620,25 +633,9 @@ public class FlowRuleManager
Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches =
ArrayListMultimap.create();
FlowRuleBatchEntry fbe;
for (FlowRuleOperation flowRuleOperation : ops) {
switch (flowRuleOperation.type()) {
// FIXME: Brian needs imagination when creating class names.
case ADD:
fbe = new FlowRuleBatchEntry(
FlowRuleBatchEntry.FlowRuleOperation.ADD, flowRuleOperation.rule());
break;
case MODIFY:
fbe = new FlowRuleBatchEntry(
FlowRuleBatchEntry.FlowRuleOperation.MODIFY, flowRuleOperation.rule());
break;
case REMOVE:
fbe = new FlowRuleBatchEntry(
FlowRuleBatchEntry.FlowRuleOperation.REMOVE, flowRuleOperation.rule());
break;
default:
throw new UnsupportedOperationException("Unknown flow rule type " + flowRuleOperation.type());
}
FlowRuleBatchEntry fbe =
new FlowRuleBatchEntry(mapOperationType(flowRuleOperation.type()), flowRuleOperation.rule());
pendingDevices.add(flowRuleOperation.rule().deviceId());
perDeviceBatches.put(flowRuleOperation.rule().deviceId(), fbe);
}
......