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/AddOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/AddOperation.java
new file mode 100644
index 0000000..556a0cb
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/batchoperation/AddOperation.java
@@ -0,0 +1,31 @@
+package net.onrc.onos.api.batchoperation;
+
+/**
+ * An add-operation entry of a batch operation.
+ */
+public class AddOperation implements BatchOperationEntry {
+    protected IBatchOperationTarget target;
+
+    /**
+     * Creates a add-operation with specified target.
+     *
+     * @param target The target object to be assigned to this add-operation.
+     */
+    public AddOperation(IBatchOperationTarget target) {
+        this.target = target;
+    }
+
+    @Override
+    public BatchOperator getOperator() {
+        return BatchOperator.ADD;
+    }
+
+    /**
+     * Gets the target object which assigned to this add-operation.
+     *
+     * @return The target object which assigned to this add-operation.
+     */
+    public IBatchOperationTarget getTarget() {
+        return target;
+    }
+}
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));
+    }
+}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationEntry.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationEntry.java
new file mode 100644
index 0000000..fce31d1
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperationEntry.java
@@ -0,0 +1,16 @@
+package net.onrc.onos.api.batchoperation;
+
+/**
+ * An interface for batch operation entry classes.
+ * <p>
+ * This is the interface to AddOperation, UpdateOperation and RemoveOperation
+ * classes which are the entry maintained by BatchOperation.
+ */
+public interface BatchOperationEntry {
+    /**
+     * Gets the BatchOperator of this operation.
+     *
+     * @return The BatchOperator of this operation.
+     */
+    public BatchOperator getOperator();
+}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperator.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperator.java
new file mode 100644
index 0000000..00ab908
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperator.java
@@ -0,0 +1,26 @@
+package net.onrc.onos.api.batchoperation;
+
+/**
+ * Operators used by BatchOperation classes.
+ */
+public enum BatchOperator {
+    /**
+     * Adds new intent.
+     */
+    ADD,
+
+    /**
+     * Removes existing intent specified by intent ID.
+     */
+    REMOVE,
+
+    /**
+     * Overwrites existing intent using new intent.
+     */
+    UPDATE,
+
+    /**
+     * Unknown type.
+     */
+    UNKNOWN,
+}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/IBatchOperationTarget.java b/src/main/java/net/onrc/onos/api/batchoperation/IBatchOperationTarget.java
new file mode 100644
index 0000000..d08528f
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/batchoperation/IBatchOperationTarget.java
@@ -0,0 +1,13 @@
+package net.onrc.onos.api.batchoperation;
+
+/**
+ * An interface of the class which is assigned to BatchOperation.
+ */
+public interface IBatchOperationTarget {
+    /**
+     * Gets ID of the object.
+     *
+     * @return ID of the object.
+     */
+    public String getId();
+}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/RemoveOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/RemoveOperation.java
new file mode 100644
index 0000000..c86e427
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/batchoperation/RemoveOperation.java
@@ -0,0 +1,32 @@
+package net.onrc.onos.api.batchoperation;
+
+/**
+ * A remove-operation entry of a batch operation.
+ */
+public class RemoveOperation implements BatchOperationEntry {
+    protected String targetId;
+
+    /**
+     * Creates a remove-operation with specified target.
+     *
+     * @param targetId The target object ID to be assigned to this
+     *        remove-operation.
+     */
+    public RemoveOperation(String targetId) {
+        this.targetId = targetId;
+    }
+
+    @Override
+    public BatchOperator getOperator() {
+        return BatchOperator.REMOVE;
+    }
+
+    /**
+     * Gets the target ID to be removed.
+     *
+     * @return The target ID to be removed.
+     */
+    public String getTargetId() {
+        return targetId;
+    }
+}
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java
new file mode 100644
index 0000000..45772ce
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/batchoperation/UpdateOperation.java
@@ -0,0 +1,44 @@
+package net.onrc.onos.api.batchoperation;
+
+/**
+ * An update-operation entry of a batch operation.
+ */
+public class UpdateOperation implements BatchOperationEntry {
+    public String oldTargetId;
+    public IBatchOperationTarget newTarget;
+
+    /**
+     * Creates a update-operation with specified targets.
+     *
+     * @param oldTargetId The ID to be overwritten.
+     * @param newTarget The new target to be added.
+     */
+    public UpdateOperation(String oldTargetId, IBatchOperationTarget newTarget) {
+        this.oldTargetId = oldTargetId;
+        this.newTarget = newTarget;
+    }
+
+    @Override
+    public BatchOperator getOperator() {
+        return BatchOperator.UPDATE;
+    }
+
+    /**
+     * Gets the old target ID to be overwritten.
+     *
+     * @return The old target ID to be overwritten
+     */
+    public String getOldTargetId() {
+        return oldTargetId;
+    }
+
+    /**
+     * Gets the new target object to be added.
+     *
+     * @return The new target object to be added.
+     */
+    public IBatchOperationTarget getNewTarget() {
+        return newTarget;
+    }
+
+}