Sho SHIMIZU
Committed by Thomas Vachuska

Add mapping function to simplify process() implementation

Change-Id: I732920bc81d6955b84a222b095bfa18c6974abe3
...@@ -592,6 +592,19 @@ public class FlowRuleManager ...@@ -592,6 +592,19 @@ public class FlowRuleManager
592 } 592 }
593 } 593 }
594 594
595 + private static FlowRuleBatchEntry.FlowRuleOperation mapOperationType(FlowRuleOperation.Type input) {
596 + switch (input) {
597 + case ADD:
598 + return FlowRuleBatchEntry.FlowRuleOperation.ADD;
599 + case MODIFY:
600 + return FlowRuleBatchEntry.FlowRuleOperation.MODIFY;
601 + case REMOVE:
602 + return FlowRuleBatchEntry.FlowRuleOperation.REMOVE;
603 + default:
604 + throw new UnsupportedOperationException("Unknown flow rule type " + input);
605 + }
606 + }
607 +
595 private class FlowOperationsProcessor implements Runnable { 608 private class FlowOperationsProcessor implements Runnable {
596 609
597 private final List<Set<FlowRuleOperation>> stages; 610 private final List<Set<FlowRuleOperation>> stages;
...@@ -620,25 +633,9 @@ public class FlowRuleManager ...@@ -620,25 +633,9 @@ public class FlowRuleManager
620 Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches = 633 Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches =
621 ArrayListMultimap.create(); 634 ArrayListMultimap.create();
622 635
623 - FlowRuleBatchEntry fbe;
624 for (FlowRuleOperation flowRuleOperation : ops) { 636 for (FlowRuleOperation flowRuleOperation : ops) {
625 - switch (flowRuleOperation.type()) { 637 + FlowRuleBatchEntry fbe =
626 - // FIXME: Brian needs imagination when creating class names. 638 + new FlowRuleBatchEntry(mapOperationType(flowRuleOperation.type()), flowRuleOperation.rule());
627 - case ADD:
628 - fbe = new FlowRuleBatchEntry(
629 - FlowRuleBatchEntry.FlowRuleOperation.ADD, flowRuleOperation.rule());
630 - break;
631 - case MODIFY:
632 - fbe = new FlowRuleBatchEntry(
633 - FlowRuleBatchEntry.FlowRuleOperation.MODIFY, flowRuleOperation.rule());
634 - break;
635 - case REMOVE:
636 - fbe = new FlowRuleBatchEntry(
637 - FlowRuleBatchEntry.FlowRuleOperation.REMOVE, flowRuleOperation.rule());
638 - break;
639 - default:
640 - throw new UnsupportedOperationException("Unknown flow rule type " + flowRuleOperation.type());
641 - }
642 pendingDevices.add(flowRuleOperation.rule().deviceId()); 639 pendingDevices.add(flowRuleOperation.rule().deviceId());
643 perDeviceBatches.put(flowRuleOperation.rule().deviceId(), fbe); 640 perDeviceBatches.put(flowRuleOperation.rule().deviceId(), fbe);
644 } 641 }
......