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/core/flowmanager/FlowOperationMap.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowOperationMap.java
index e9d66c3..6535269 100644
--- a/src/main/java/net/onrc/onos/core/flowmanager/FlowOperationMap.java
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowOperationMap.java
@@ -4,46 +4,79 @@
 import net.onrc.onos.api.flowmanager.FlowBatchId;
 import net.onrc.onos.api.flowmanager.FlowBatchOperation;
 import net.onrc.onos.api.flowmanager.FlowBatchState;
+import net.onrc.onos.core.util.IdBlockAllocator;
 
 /**
  * Manages the set of flow operations throughout the ONOS instances.
+ * <p>
+ * Application can access to this map using {@link FlowBatchHandle}.
  */
 public class FlowOperationMap {
-    public FlowBatchHandle putOperation(FlowBatchOperation ops) {
-        FlowBatchId id = getUniqueBatchOperationId();
-        if (id == null) {
-            return null;
-        }
-        if (putBatchOperation(id, ops)) {
-            return null;
-        }
+    private final FlowBatchIdGeneratorWithIdBlockAllocator flowBatchIdGenerator;
 
-        return new FlowBatchHandle(this, id);
+    /**
+     * Creates a driver for the shared flow batch operation map.
+     *
+     * @param allocator {@link IdBlockAllocator} to be used for batch IDs
+     */
+    FlowOperationMap(IdBlockAllocator allocator) {
+        flowBatchIdGenerator = new FlowBatchIdGeneratorWithIdBlockAllocator(allocator);
     }
 
-    public void setState(long id, FlowBatchState state) {
-        // TODO implement it
+    /**
+     * Adds a flow batch operation to the map.
+     *
+     * @param ops the flow batch operation to be added
+     * @return {@link FlowBatchHandle} handle if succeeded, null otherwise
+     */
+    FlowBatchHandle putBatchOperation(FlowBatchOperation ops) {
+        FlowBatchId id = flowBatchIdGenerator.getNewId();
+
+        // TODO: put batch operation to map
+
+        boolean succeeded = false;
+
+        return succeeded ? new FlowBatchHandleImpl(this, id) : null;
     }
 
-    public FlowBatchOperation getOperation(long id) {
+    /**
+     * Gets the flow batch operation from the map specified with an ID.
+     *
+     * @param id the ID for the operation
+     * @return the flow batch operation if exists, null otherwise
+     */
+    FlowBatchOperation getBatchOperation(FlowBatchId id) {
+        // TODO: implement it
+        return null;
+    }
+
+    /**
+     * Removes the flow batch operation from the map specified with an ID.
+     */
+    void removeBatchOperation(FlowBatchId id) {
+        // TODO: implement it
+    }
+
+    /**
+     * Gets the state for the flow batch operation specified with an ID.
+     *
+     * @param id the ID for the batch operation
+     * @return the state of the batch operation
+     */
+    FlowBatchState getState(FlowBatchId id) {
         // TODO implement it
         return null;
     }
 
-    public FlowBatchState getState(FlowBatchId id) {
-        // TODO implement it
-        return null;
-    }
-
-    // ====== private methods
-
-    private FlowBatchId getUniqueBatchOperationId() {
-        // TODO implement it
-        return null;
-    }
-
-    private boolean putBatchOperation(FlowBatchId id, FlowBatchOperation ops) {
-        // TODO implement it
+    /**
+     * Updates the state for the flow batch operation specified with an ID.
+     *
+     * @param id the ID for the batch operation
+     * @param state new state for the batch operation
+     * @return true if succeeded, false otherwise
+     */
+    boolean setState(FlowBatchId id, FlowBatchState state) {
+        // TODO: implement it
         return false;
     }
 }