Sho SHIMIZU

Add mapping function to simplify process() implementation

Change-Id: I732920bc81d6955b84a222b095bfa18c6974abe3
...@@ -571,6 +571,19 @@ public class FlowRuleManager ...@@ -571,6 +571,19 @@ public class FlowRuleManager
571 } 571 }
572 } 572 }
573 573
574 + private static FlowRuleBatchEntry.FlowRuleOperation mapOperationType(FlowRuleOperation.Type input) {
575 + switch (input) {
576 + case ADD:
577 + return FlowRuleBatchEntry.FlowRuleOperation.ADD;
578 + case MODIFY:
579 + return FlowRuleBatchEntry.FlowRuleOperation.MODIFY;
580 + case REMOVE:
581 + return FlowRuleBatchEntry.FlowRuleOperation.REMOVE;
582 + default:
583 + throw new UnsupportedOperationException("Unknown flow rule type " + input);
584 + }
585 + }
586 +
574 private class FlowOperationsProcessor implements Runnable { 587 private class FlowOperationsProcessor implements Runnable {
575 588
576 private final List<Set<FlowRuleOperation>> stages; 589 private final List<Set<FlowRuleOperation>> stages;
...@@ -599,25 +612,9 @@ public class FlowRuleManager ...@@ -599,25 +612,9 @@ public class FlowRuleManager
599 Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches = 612 Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches =
600 ArrayListMultimap.create(); 613 ArrayListMultimap.create();
601 614
602 - FlowRuleBatchEntry fbe;
603 for (FlowRuleOperation flowRuleOperation : ops) { 615 for (FlowRuleOperation flowRuleOperation : ops) {
604 - switch (flowRuleOperation.type()) { 616 + FlowRuleBatchEntry fbe =
605 - // FIXME: Brian needs imagination when creating class names. 617 + new FlowRuleBatchEntry(mapOperationType(flowRuleOperation.type()), flowRuleOperation.rule());
606 - case ADD:
607 - fbe = new FlowRuleBatchEntry(
608 - FlowRuleBatchEntry.FlowRuleOperation.ADD, flowRuleOperation.rule());
609 - break;
610 - case MODIFY:
611 - fbe = new FlowRuleBatchEntry(
612 - FlowRuleBatchEntry.FlowRuleOperation.MODIFY, flowRuleOperation.rule());
613 - break;
614 - case REMOVE:
615 - fbe = new FlowRuleBatchEntry(
616 - FlowRuleBatchEntry.FlowRuleOperation.REMOVE, flowRuleOperation.rule());
617 - break;
618 - default:
619 - throw new UnsupportedOperationException("Unknown flow rule type " + flowRuleOperation.type());
620 - }
621 pendingDevices.add(flowRuleOperation.rule().deviceId()); 618 pendingDevices.add(flowRuleOperation.rule().deviceId());
622 perDeviceBatches.put(flowRuleOperation.rule().deviceId(), fbe); 619 perDeviceBatches.put(flowRuleOperation.rule().deviceId(), fbe);
623 } 620 }
......