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/api/flowmanager/FlowId.java b/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java
new file mode 100644
index 0000000..b3c42d6
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java
@@ -0,0 +1,38 @@
+package net.onrc.onos.api.flowmanager;
+
+import net.onrc.onos.api.batchoperation.BatchOperationTargetId;
+
+/**
+ * Represents ID for IFlow objects.
+ */
+public class FlowId extends BatchOperationTargetId {
+ private final String value;
+
+ /**
+ * Creates new instance with string ID.
+ *
+ * @param id String representation of the ID.
+ */
+ public FlowId(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 FlowId) {
+ FlowId other = (FlowId) obj;
+ return (this.value.equals(other.value));
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/IFlow.java b/src/main/java/net/onrc/onos/api/flowmanager/IFlow.java
index 66f116a..25b9aea 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/IFlow.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/IFlow.java
@@ -18,7 +18,7 @@
* @return ID for this object.
*/
@Override
- public String getId();
+ public FlowId getId();
/**
* Gets traffic filter for this flow object.
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/IFlowManagerService.java b/src/main/java/net/onrc/onos/api/flowmanager/IFlowManagerService.java
index edd3c85..ca4e5f7 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/IFlowManagerService.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/IFlowManagerService.java
@@ -31,7 +31,7 @@
* @param id ID for IFlow object to be removed.
* @return true if succeeded, false otherwise.
*/
- boolean removeFlow(String id);
+ boolean removeFlow(FlowId id);
/**
* Updates IFlow object, calculates match-action plan and executes it.
@@ -50,7 +50,7 @@
* @param id ID of IFlow object.
* @return IFlow object if found, null otherwise.
*/
- IFlow getFlow(String id);
+ IFlow getFlow(FlowId id);
/**
* Gets All IFlow objects.
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/PathFlow.java b/src/main/java/net/onrc/onos/api/flowmanager/PathFlow.java
index baf163f..50db020 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/PathFlow.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/PathFlow.java
@@ -14,7 +14,7 @@
* have only the PacketPathFlow and OpticalPathFlow classes?
*/
public class PathFlow implements IFlow {
- protected final String id;
+ protected final FlowId id;
protected IMatch match;
protected PortNumber ingressPort;
protected Path path;
@@ -32,7 +32,7 @@
*/
public PathFlow(String id,
IMatch match, PortNumber ingressPort, Path path, List<IAction> edgeActions) {
- this.id = id;
+ this.id = new FlowId(id);
this.match = match;
this.ingressPort = ingressPort;
this.path = path;
@@ -40,7 +40,7 @@
}
@Override
- public String getId() {
+ public FlowId getId() {
return id;
}
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/SingleDstTreeFlow.java b/src/main/java/net/onrc/onos/api/flowmanager/SingleDstTreeFlow.java
index 82a9b50..473b7e8 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/SingleDstTreeFlow.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/SingleDstTreeFlow.java
@@ -18,7 +18,7 @@
* address modifications or other the label-switching-like schemes.
*/
public class SingleDstTreeFlow implements IFlow {
- protected String id;
+ protected final FlowId id;
protected PacketMatch match;
protected Set<SwitchPort> ingressPorts;
protected Tree tree;
@@ -35,7 +35,7 @@
*/
public SingleDstTreeFlow(String id, PacketMatch match,
Collection<SwitchPort> ingressPorts, Tree tree, OutputAction outputAction) {
- this.id = id;
+ this.id = new FlowId(id);
this.match = match;
this.ingressPorts = new HashSet<SwitchPort>(ingressPorts);
this.tree = tree;
@@ -46,7 +46,7 @@
}
@Override
- public String getId() {
+ public FlowId getId() {
return id;
}
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/SingleSrcTreeFlow.java b/src/main/java/net/onrc/onos/api/flowmanager/SingleSrcTreeFlow.java
index cecb605..e401bdc 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/SingleSrcTreeFlow.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/SingleSrcTreeFlow.java
@@ -14,7 +14,7 @@
* layer.
*/
public class SingleSrcTreeFlow implements IFlow {
- protected String id;
+ protected final FlowId id;
protected PacketMatch match;
protected SwitchPort ingressPort;
protected Tree tree;
@@ -32,7 +32,7 @@
*/
public SingleSrcTreeFlow(String id, PacketMatch match,
SwitchPort ingressPort, Tree tree, Set<Pair<Dpid, OutputAction>> outputActions) {
- this.id = id;
+ this.id = new FlowId(id);
this.match = match;
this.ingressPort = ingressPort;
this.tree = tree;
@@ -43,7 +43,7 @@
}
@Override
- public String getId() {
+ public FlowId getId() {
return id;
}