Change FlowBatchHandle to be interface class.

- Users can access to the shared flow batch operation map
  using the FlowBatchHandle.
- FlowBatchHandle is an interface and the instance of it
  can be obtained from APIs defined by FlowManagerService.
- The implementation of the map can be accessed only from
  the implementation of the FlowBatchHandle.
- This task is a part of ONOS-1692 and ONOS-1842.

Change-Id: I651a2886d166765ca5aae6abcc2b844153ffb2bc
diff --git a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
index 6232a86..65836c4 100644
--- a/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
+++ b/src/main/java/net/onrc/onos/api/batchoperation/BatchOperation.java
@@ -1,5 +1,7 @@
 package net.onrc.onos.api.batchoperation;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
@@ -15,13 +17,23 @@
     private List<T> ops;
 
     /**
-     * Constructor.
+     * Creates new {@link BatchOperation} object.
      */
     public BatchOperation() {
         ops = new LinkedList<>();
     }
 
     /**
+     * Creates {@link BatchOperation} object from a list of batch operation
+     * entries.
+     *
+     * @param batchOperations the list of batch operation entries.
+     */
+    public BatchOperation(List<T> batchOperations) {
+        ops = new LinkedList<>(checkNotNull(batchOperations));
+    }
+
+    /**
      * Removes all operations maintained in this object.
      */
     public void clear() {
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchHandle.java b/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchHandle.java
index 351d9e9..1f1836a 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchHandle.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchHandle.java
@@ -1,40 +1,25 @@
 package net.onrc.onos.api.flowmanager;
 
-import net.onrc.onos.core.flowmanager.FlowOperationMap;
-
-
 /**
- * Handle class to handle flow batch operation.
+ * An interface for handling flow batch operation.
  */
-public class FlowBatchHandle {
-    private final FlowOperationMap flowOperationMap;
-    private final FlowBatchId batchId;
+public interface FlowBatchHandle {
+    /**
+     * Gets the flow batch operation.
+     *
+     * @return the flow batch operation
+     */
+    public FlowBatchOperation getFlowBatchOperation();
 
     /**
-     * Creates a handle using batch operation ID.
-     * <p>
-     * The ID is automatically generated and assigned by FlowManager, and used
-     * as an internal key for the flow batch operation map.
+     * Gets the state for the flow batch operation.
      *
-     * @param opMap the FlowOperationMap object which maintains the flow batch
-     *        operation
-     * @param id the batch operation ID
+     * @return the state for the flow batch operation
      */
-    public FlowBatchHandle(FlowOperationMap opMap, FlowBatchId id) {
-        flowOperationMap = opMap;
-        batchId = id;
-    }
+    public FlowBatchState getState();
 
     /**
-     * Gets the flow batch operation ID.
-     *
-     * @return the flow batch operation ID
+     * Purge the flow batch operation from the map.
      */
-    public FlowBatchId getBatchOperationId() {
-        return batchId;
-    }
-
-    public FlowBatchState getState() {
-        return flowOperationMap.getState(batchId);
-    }
+    public void purge();
 }
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchOperation.java b/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchOperation.java
index 71d5378..f59bee5 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchOperation.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/FlowBatchOperation.java
@@ -1,5 +1,7 @@
 package net.onrc.onos.api.flowmanager;
 
+import java.util.List;
+
 import net.onrc.onos.api.batchoperation.BatchOperation;
 import net.onrc.onos.api.batchoperation.BatchOperationEntry;
 
@@ -24,6 +26,24 @@
     }
 
     /**
+     * Creates new {@link FlowBatchOperation} object.
+     */
+    public FlowBatchOperation() {
+        super();
+    }
+
+    /**
+     * Creates new {@link FlowBatchOperation} object from a list of flow batch
+     * operation entries.
+     *
+     * @param batchOperations the list of flow batch operation entries
+     */
+    public FlowBatchOperation(
+            List<BatchOperationEntry<FlowBatchOperation.Operator, ?>> batchOperations) {
+        super(batchOperations);
+    }
+
+    /**
      * Adds an add-flow operation.
      *
      * @param flow the flow to be added