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/intent/IIntentRuntimeService.java b/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java
index 5e9ed52..2b8774b 100644
--- a/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java
+++ b/src/main/java/net/onrc/onos/api/intent/IIntentRuntimeService.java
@@ -32,7 +32,7 @@
* @param id ID of the intent to be removed.
* @return true if succeeded, false otherwise.
*/
- boolean removeIntent(String id);
+ boolean removeIntent(IntentId id);
/**
* Overwrites existing intent by new specified intent.
@@ -41,7 +41,7 @@
* @param intent The new intent to be added.
* @return true if succeeded, false otherwise.
*/
- boolean updateIntent(String id, Intent intent);
+ boolean updateIntent(IntentId id, Intent intent);
/**
* Gets specific intent.
@@ -49,7 +49,7 @@
* @param id ID of the intent should be retrieved
* @return Intent if it exists, null otherwise.
*/
- Intent getIntent(String id);
+ Intent getIntent(IntentId id);
/**
* Gets all intents.
diff --git a/src/main/java/net/onrc/onos/api/intent/Intent.java b/src/main/java/net/onrc/onos/api/intent/Intent.java
index 93d6459..048bdee 100644
--- a/src/main/java/net/onrc/onos/api/intent/Intent.java
+++ b/src/main/java/net/onrc/onos/api/intent/Intent.java
@@ -20,7 +20,7 @@
* data-plane to satisfy those constraints.
*/
public abstract class Intent implements IBatchOperationTarget {
- protected String id;
+ protected final IntentId id;
/**
* Constructor.
@@ -28,7 +28,7 @@
* @param id ID for this Intent object.
*/
public Intent(String id) {
- this.id = id;
+ this.id = new IntentId(id);
}
/**
@@ -37,7 +37,7 @@
* @return ID for this Intent object.
*/
@Override
- public String getId() {
+ public IntentId getId() {
return id;
}
diff --git a/src/main/java/net/onrc/onos/api/intent/IntentId.java b/src/main/java/net/onrc/onos/api/intent/IntentId.java
new file mode 100644
index 0000000..d488183
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/intent/IntentId.java
@@ -0,0 +1,30 @@
+package net.onrc.onos.api.intent;
+
+import net.onrc.onos.api.batchoperation.BatchOperationTargetId;
+
+public class IntentId extends BatchOperationTargetId {
+ private final String value;
+
+ public IntentId(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 IntentId) {
+ IntentId other = (IntentId) obj;
+ return (this.value.equals(other.value));
+ }
+ return false;
+ }
+}