Skeletons for Intent-runtime, Flow-manager and Match-action modules.
This task is a part of ONOS-1395.
(Sub-tasks: ONOS-1397, ONOS-1398, ONOS-1400)
Change-Id: I30064f658b6c193aee8419079dad380163364475
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
new file mode 100644
index 0000000..b51c8eb
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
@@ -0,0 +1,69 @@
+package net.onrc.onos.api.batchoperation;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * A list of BatchOperationEntry.
+ *
+ * @param <T> IBatchOperationTarget. This should be Intent, IFlow, or
+ * MatchAction.
+ */
+public class BatchOperation<T extends IBatchOperationTarget> {
+ private List<BatchOperationEntry> ops;
+
+ /**
+ * Constructor.
+ */
+ public BatchOperation() {
+ ops = new LinkedList<BatchOperationEntry>();
+ }
+
+ /**
+ * Removes all operations maintained in this object.
+ */
+ public void clear() {
+ ops.clear();
+ }
+
+ /**
+ * Returns an iterator over the operations in this object.
+ *
+ * @return an iterator over the operations in this object.
+ */
+ public Iterator<BatchOperationEntry> iterator() {
+ return ops.iterator();
+ }
+
+ /**
+ * Adds an add-operation.
+ *
+ * @param intent Intent to be added.
+ * @return true if succeeded, false otherwise.
+ */
+ public boolean addAddOperation(T target) {
+ return ops.add(new AddOperation(target));
+ }
+
+ /**
+ * Adds a remove-operation.
+ *
+ * @param id ID of the target to be removed.
+ * @return true if succeeded, false otherwise.
+ */
+ public boolean addRemoveOperation(String id) {
+ return ops.add(new RemoveOperation(id));
+ }
+
+ /**
+ * Adds a update-operation.
+ *
+ * @param oldtargetId ID of the existing target to be overwritten.
+ * @param newTarget The new target to be added.
+ * @return true if succeeded, false otherwise.
+ */
+ public boolean addUpdateOperation(String oldTargetId, T newTarget) {
+ return ops.add(new UpdateOperation(oldTargetId, newTarget));
+ }
+}