[ONOS-4014] Refactor *Id classes to extend from Identifier class
- Refactor all of *Id classes in protocols package
- Refactor all of *Id classes in utils package
Change-Id: Ie53f078174d0bd0cb5ab4ef6786f1025a7d70846
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java
index 60146c8..bed44fb 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java
@@ -15,19 +15,17 @@
*/
package org.onosproject.ovsdb.controller;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
import org.onlab.packet.IpAddress;
+import org.onlab.util.Identifier;
+
+import static com.google.common.base.Preconditions.checkNotNull;
/**
* The class representing a nodeId of node which using ovsdb connection.
* This class is immutable.
*/
-public final class OvsdbNodeId {
+public final class OvsdbNodeId extends Identifier<String> {
private static final String SCHEME = "ovsdb";
- private final String nodeId;
private final String ipAddress;
/**
@@ -37,30 +35,14 @@
* @param port node port
*/
public OvsdbNodeId(IpAddress ipAddress, long port) {
- checkNotNull(ipAddress, "ipAddress is not null");
+ // TODO: port is currently not in use, need to remove it later
+ super(checkNotNull(ipAddress, "ipAddress is not null").toString());
this.ipAddress = ipAddress.toString();
- this.nodeId = ipAddress.toString();
- }
-
- @Override
- public int hashCode() {
- return nodeId.hashCode();
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof OvsdbNodeId)) {
- return false;
- }
-
- OvsdbNodeId otherNodeId = (OvsdbNodeId) other;
-
- return Objects.equals(otherNodeId.nodeId, this.nodeId);
}
@Override
public String toString() {
- return SCHEME + ":" + nodeId;
+ return SCHEME + ":" + identifier;
}
/**
@@ -69,7 +51,7 @@
* @return the value of the NodeId.
*/
public String nodeId() {
- return SCHEME + ":" + nodeId;
+ return SCHEME + ":" + identifier;
}
/**