[ONOS-4014] Refactor *Id classes to extend from Identifier class
- Refactor most of *Id classes in onos-api package
- Refactor all of *Id classes in incubator package
Change-Id: Ief6322d3fb42c80e82f695e9d4dcee439346215b
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentId.java b/core/api/src/main/java/org/onosproject/net/intent/IntentId.java
index b9a30d2..4494eea 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentId.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentId.java
@@ -16,6 +16,7 @@
package org.onosproject.net.intent;
import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
import org.onosproject.net.newresource.ResourceConsumer;
/**
@@ -23,9 +24,7 @@
* <p>This class is immutable.</p>
*/
@Beta
-public final class IntentId implements ResourceConsumer {
-
- private final long value;
+public final class IntentId extends Identifier<Long> implements ResourceConsumer {
/**
* Creates an intent identifier from the specified long representation.
@@ -41,7 +40,7 @@
* Constructor for serializer.
*/
IntentId() {
- this.value = 0;
+ super(0L);
}
/**
@@ -50,7 +49,7 @@
* @param value the underlying value of this ID
*/
IntentId(long value) {
- this.value = value;
+ super(value);
}
/**
@@ -59,29 +58,12 @@
* @return the value
*/
public long fingerprint() {
- return value;
- }
-
- @Override
- public int hashCode() {
- return Long.hashCode(value);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof IntentId)) {
- return false;
- }
- IntentId that = (IntentId) obj;
- return this.value == that.value;
+ return identifier;
}
@Override
public String toString() {
- return "0x" + Long.toHexString(value);
+ return "0x" + Long.toHexString(identifier);
}
}