Define ID representation for Intent, IFlow and MatchAction

- Defines BatchOperationTargetId abstract class.
- The above class is the base class of IntentId, FlowId, and MatchActionId.
 -- Intent objects use IntentId class for its ID.
 -- IFlow objects use FlowId class for its ID.
 -- MatchAction objects use MatchActionId class for its ID.
- BatchOperation classes requires the BatchOperationTargetId as the target object's ID.
- This work is a part of ONOS-1758.

Change-Id: I71bb4e6acd3836d1ced3beb6fb331bca451abdc3
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
index 0d56ad3..0c5be10 100644
--- a/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowManagerModule.java
@@ -5,6 +5,7 @@
 
 import net.onrc.onos.api.batchoperation.BatchOperation;
 import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
+import net.onrc.onos.api.flowmanager.FlowId;
 import net.onrc.onos.api.flowmanager.IFlow;
 import net.onrc.onos.api.flowmanager.IFlowManagerService;
 
@@ -32,7 +33,7 @@
     }
 
     @Override
-    public boolean removeFlow(String id) {
+    public boolean removeFlow(FlowId id) {
         BatchOperation<IFlow> ops = new BatchOperation<IFlow>();
         ops.addRemoveOperation(id);
         return executeBatch(ops);
@@ -46,7 +47,7 @@
     }
 
     @Override
-    public IFlow getFlow(String id) {
+    public IFlow getFlow(FlowId id) {
         // TODO Auto-generated method stub
         return null;
     }
diff --git a/src/main/java/net/onrc/onos/core/matchaction/IMatchActionService.java b/src/main/java/net/onrc/onos/core/matchaction/IMatchActionService.java
index 9b829a5..9a87da9 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/IMatchActionService.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/IMatchActionService.java
@@ -23,7 +23,7 @@
      * @param id ID for MatchaAction object to be removed.
      * @return true if succeeded, false otherwise.
      */
-    boolean removeMatchAction(String id);
+    boolean removeMatchAction(MatchActionId id);
 
     /**
      * Replaces the existing match-action entry by specified match-action entry.
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchAction.java b/src/main/java/net/onrc/onos/core/matchaction/MatchAction.java
index 2f21baf..cf4bf0f 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchAction.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchAction.java
@@ -18,7 +18,7 @@
  * A filter and actions for traffic.
  */
 public class MatchAction implements IBatchOperationTarget {
-    protected String id;
+    protected final MatchActionId id;
     protected SwitchPort port;
     protected List<IMatch> matches;
     protected List<IAction> actions;
@@ -33,7 +33,7 @@
      */
     public MatchAction(String id, SwitchPort port, List<IMatch> matches,
             List<IAction> actions) {
-        this.id = id;
+        this.id = new MatchActionId(id);
         this.port = port;
         this.matches = matches;
         this.actions = actions;
@@ -64,7 +64,7 @@
     }
 
     @Override
-    public String getId() {
+    public MatchActionId getId() {
         return id;
     }
 
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionId.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionId.java
new file mode 100644
index 0000000..d4acae6
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionId.java
@@ -0,0 +1,31 @@
+package net.onrc.onos.core.matchaction;
+
+import net.onrc.onos.api.batchoperation.BatchOperationTargetId;
+
+public class MatchActionId extends BatchOperationTargetId {
+    private final String value;
+
+    public MatchActionId(String id) {
+        value = id;
+    }
+
+    @Override
+    public String toString() {
+        return value;
+    }
+
+    @Override
+    public int hashCode() {
+        return value.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof MatchActionId) {
+            MatchActionId other = (MatchActionId) obj;
+            return (this.value.equals(other.value));
+        }
+        return false;
+    }
+
+}
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
index e0957f0..a734026 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionModule.java
@@ -23,7 +23,7 @@
     }
 
     @Override
-    public boolean removeMatchAction(String id) {
+    public boolean removeMatchAction(MatchActionId id) {
         BatchOperation<MatchAction> phase = new BatchOperation<MatchAction>();
         phase.addRemoveOperation(id);
         MatchActionPlan plan = new MatchActionPlan();
diff --git a/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java b/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java
index 6a2cf8c..8410400 100644
--- a/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java
+++ b/src/main/java/net/onrc/onos/core/newintent/IntentRuntimeModule.java
@@ -8,6 +8,7 @@
 import net.onrc.onos.api.flowmanager.IFlow;
 import net.onrc.onos.api.intent.IIntentRuntimeService;
 import net.onrc.onos.api.intent.Intent;
+import net.onrc.onos.api.intent.IntentId;
 
 /**
  * Implementation of Intent-Runtime Service.
@@ -25,21 +26,21 @@
     }
 
     @Override
-    public boolean removeIntent(String id) {
+    public boolean removeIntent(IntentId id) {
         BatchOperation<Intent> ops = new BatchOperation<Intent>();
         ops.addRemoveOperation(id);
         return executeBatch(ops);
     }
 
     @Override
-    public boolean updateIntent(String id, Intent intent) {
+    public boolean updateIntent(IntentId id, Intent intent) {
         BatchOperation<Intent> ops = new BatchOperation<Intent>();
         ops.addUpdateOperation(id, intent);
         return executeBatch(ops);
     }
 
     @Override
-    public Intent getIntent(String id) {
+    public Intent getIntent(IntentId id) {
         // TODO Auto-generated method stub
         // - retrieves intents from global distributed maps
         return null;