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/intent/IntentBatchOperation.java b/src/main/java/net/onrc/onos/api/intent/IntentBatchOperation.java
new file mode 100644
index 0000000..b5ca1aa
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/intent/IntentBatchOperation.java
@@ -0,0 +1,42 @@
+package net.onrc.onos.api.intent;
+
+import net.onrc.onos.api.batchoperation.BatchOperation;
+import net.onrc.onos.api.batchoperation.BatchOperationEntry;
+
+/**
+ * A list of intent operations.
+ */
+public class IntentBatchOperation extends
+ BatchOperation<BatchOperationEntry<IntentBatchOperation.Operator, ?>> {
+ /**
+ * The intent operators.
+ */
+ public enum Operator {
+ ADD,
+ REMOVE,
+ }
+
+ /**
+ * Adds an add-intent operation.
+ *
+ * @param intent the intent to be added
+ * @return the IntentBatchOperation object if succeeded, null otherwise
+ */
+ public IntentBatchOperation addAddIntentOperation(Intent intent) {
+ return (null == super.addOperation(
+ new BatchOperationEntry<Operator, Intent>(Operator.ADD, intent)))
+ ? null : this;
+ }
+
+ /**
+ * Adds a remove-intent operation.
+ *
+ * @param id the ID of intent to be removed
+ * @return the IntentBatchOperation object if succeeded, null otherwise
+ */
+ public IntentBatchOperation addRemoveIntentOperation(IntentId id) {
+ return (null == super.addOperation(
+ new BatchOperationEntry<Operator, IntentId>(Operator.REMOVE, id)))
+ ? null : this;
+ }
+}