Fix for ONOS-5175. GroupId refactoring.
Change-Id: I951392bdc69fe1ef694d321164b0b49032617d6b
diff --git a/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java b/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java
index bb5695f..41dc7a2 100644
--- a/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java
+++ b/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java
@@ -22,28 +22,21 @@
/**
* Default implementation of {@link GroupId}.
*/
-// TODO: require refactor to extend from Identifier base class
-public class DefaultGroupId implements GroupId {
-
- private final int id;
+@Deprecated
+public class DefaultGroupId extends GroupId {
public DefaultGroupId(int id) {
- this.id = id;
+ super(id);
}
// Constructor for serialization
private DefaultGroupId() {
- this.id = 0;
- }
-
- @Override
- public int id() {
- return this.id;
+ super(0);
}
@Override
public int hashCode() {
- return id;
+ return identifier;
}
@Override
@@ -55,13 +48,13 @@
return false;
}
final DefaultGroupId other = (DefaultGroupId) obj;
- return Objects.equals(this.id, other.id);
+ return Objects.equals(this.identifier, other.identifier);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
- .add("id", "0x" + Integer.toHexString(id))
+ .add("id", "0x" + Integer.toHexString(identifier))
.toString();
}
}
diff --git a/core/api/src/main/java/org/onosproject/core/GroupId.java b/core/api/src/main/java/org/onosproject/core/GroupId.java
index 2ab398b..c2a9d26 100644
--- a/core/api/src/main/java/org/onosproject/core/GroupId.java
+++ b/core/api/src/main/java/org/onosproject/core/GroupId.java
@@ -15,18 +15,39 @@
*/
package org.onosproject.core;
+import com.google.common.base.MoreObjects;
+import org.onlab.util.Identifier;
+
/**
* Group identifier.
*/
-// TODO: require refactor to extend from Identifier base class
-public interface GroupId {
+public class GroupId extends Identifier<Integer> {
+
+ public GroupId(int id) {
+ super(id);
+ }
+
+ // Constructor for serialization
+ private GroupId() {
+ super(0);
+ }
/**
* Returns a group ID as an integer value.
* The method is not intended for use by application developers.
* Return data type may change in the future release.
*
- * @return a group ID as integer value
+ * @param id int value
+ * @return group ID
*/
- int id();
+ public static GroupId valueOf(int id) {
+ return new GroupId(id);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("id", "0x" + Integer.toHexString(identifier))
+ .toString();
+ }
}