Update BatchOperation class to be more generic and extensible.
- addAddOperation() and addRemoveOperation() methods are removed
from BatchOperation class, and now the class has just addOperation() method.
- Removed AddOperation and RemoveOperation classes,
and defined IntentBatchOperation, FlowBatchOperation and MatchActionPhase classes
as sub-classes of BatchOperation class, for Intent, IFlow and MatchAction objects
respectively.
- These classes include definitions of add/remove operators and helper methods
specific to Intent, IFlow and MatchAction objects.
- Removed BatchOperationTargetId class.
- Updated unit tests.
- This task is a part of ONOS-1692.
Change-Id: Iba2f737af1fef6a6555e0e0166836865ed070fa3
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchOperation.java b/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchOperation.java
new file mode 100644
index 0000000..42eb81d
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchOperation.java
@@ -0,0 +1,49 @@
+package net.onrc.onos.api.flowmanager;
+
+import net.onrc.onos.api.batchoperation.BatchOperation;
+import net.onrc.onos.api.batchoperation.BatchOperationEntry;
+
+/**
+ * A list of flow operations.
+ */
+public class FlowBatchOperation extends
+ BatchOperation<BatchOperationEntry<FlowBatchOperation.Operator, ?>> {
+ /**
+ * The flow operations' operators.
+ */
+ public enum Operator {
+ /**
+ * Adds new flow.
+ */
+ ADD,
+
+ /**
+ * Removes the existing flow.
+ */
+ REMOVE,
+ }
+
+ /**
+ * Adds an add-flow operation.
+ *
+ * @param flow the flow to be added
+ * @return the FlowBatchOperation object if succeeded, null otherwise
+ */
+ public FlowBatchOperation addAddFlowOperation(IFlow flow) {
+ return (null == super.addOperation(
+ new BatchOperationEntry<Operator, IFlow>(Operator.ADD, flow)))
+ ? null : this;
+ }
+
+ /**
+ * Adds a remove-flow operation.
+ *
+ * @param flowId the ID of flow to be removed
+ * @return the FlowBatchOperation object if succeeded, null otherwise
+ */
+ public FlowBatchOperation addRemoveFlowOperation(FlowId flowId) {
+ return (null == super.addOperation(
+ new BatchOperationEntry<Operator, FlowId>(Operator.REMOVE, flowId)))
+ ? null : this;
+ }
+}