[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/cluster/NodeId.java b/core/api/src/main/java/org/onosproject/cluster/NodeId.java
index 8b7d540..2ff2cf5 100644
--- a/core/api/src/main/java/org/onosproject/cluster/NodeId.java
+++ b/core/api/src/main/java/org/onosproject/cluster/NodeId.java
@@ -52,5 +52,4 @@
     public int compareTo(NodeId that) {
         return identifier.compareTo(that.identifier);
     }
-
 }
diff --git a/core/api/src/main/java/org/onosproject/cluster/PartitionId.java b/core/api/src/main/java/org/onosproject/cluster/PartitionId.java
index f1deedb..12af622 100644
--- a/core/api/src/main/java/org/onosproject/cluster/PartitionId.java
+++ b/core/api/src/main/java/org/onosproject/cluster/PartitionId.java
@@ -15,16 +15,14 @@
  */
 package org.onosproject.cluster;
 
-import static com.google.common.base.Preconditions.checkArgument;
+import org.onlab.util.Identifier;
 
-import java.util.Objects;
+import static com.google.common.base.Preconditions.checkArgument;
 
 /**
  * {@link Partition} identifier.
  */
-public class PartitionId implements Comparable<PartitionId> {
-
-    private final int id;
+public class PartitionId extends Identifier<Integer> implements Comparable<PartitionId> {
 
     /**
      * Creates a partition identifier from an integer.
@@ -32,8 +30,8 @@
      * @param id input integer
      */
     public PartitionId(int id) {
+        super(id);
         checkArgument(id >= 0, "partition id must be non-negative");
-        this.id = id;
     }
 
     /**
@@ -51,33 +49,11 @@
      * @return number
      */
     public int asInt() {
-        return id;
-    }
-
-    @Override
-    public int hashCode() {
-        return id;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof PartitionId) {
-            final PartitionId other = (PartitionId) obj;
-            return Objects.equals(this.id, other.id);
-        }
-        return false;
-    }
-
-    @Override
-    public String toString() {
-        return String.valueOf(id);
+        return id();
     }
 
     @Override
     public int compareTo(PartitionId that) {
-        return Integer.compare(this.id, that.id);
+        return Integer.compare(this.identifier, that.identifier);
     }
 }
\ No newline at end of file
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 243e521..7467c3c 100644
--- a/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java
+++ b/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java
@@ -22,6 +22,7 @@
 /**
  * Default implementation of {@link GroupId}.
  */
+// TODO: require refactor to extend from Identifier base class
 public class DefaultGroupId implements GroupId {
 
     private final int id;
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 739fc7f..3bfd290 100644
--- a/core/api/src/main/java/org/onosproject/core/GroupId.java
+++ b/core/api/src/main/java/org/onosproject/core/GroupId.java
@@ -18,6 +18,7 @@
 /**
  * Group identifier.
  */
+// TODO: require refactor to extend from Identifier base class
 public interface GroupId {
 
     /**
diff --git a/core/api/src/main/java/org/onosproject/net/NshServicePathId.java b/core/api/src/main/java/org/onosproject/net/NshServicePathId.java
index 16fbc4e..1fd478f 100644
--- a/core/api/src/main/java/org/onosproject/net/NshServicePathId.java
+++ b/core/api/src/main/java/org/onosproject/net/NshServicePathId.java
@@ -15,16 +15,12 @@
  */
 package org.onosproject.net;
 
-import java.util.Objects;
-
-import com.google.common.base.MoreObjects;
+import org.onlab.util.Identifier;
 
 /*
  * Representation of NSH Service path Identifier
  */
-public final class NshServicePathId {
-
-    private final int servicePathId;
+public final class NshServicePathId extends Identifier<Integer> {
 
     /**
      * Default constructor.
@@ -32,7 +28,7 @@
      * @param servicePathId nsh service path identifier
      */
     private NshServicePathId(int servicePathId) {
-        this.servicePathId = servicePathId;
+        super(servicePathId);
     }
 
     /**
@@ -45,39 +41,13 @@
         return new NshServicePathId(servicePathId);
     }
 
-
     /**
      * Returns nsh context service path identifier.
      *
      * @return the nsh context service path id
      */
     public int servicePathId() {
-        return servicePathId;
-    }
-
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(servicePathId);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof NshServicePathId)) {
-            return false;
-        }
-        final NshServicePathId other = (NshServicePathId) obj;
-        return   Objects.equals(this.servicePathId, other.servicePathId);
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(this)
-                .add("servicePathId", servicePathId)
-                .toString();
+        return identifier;
     }
 }
 
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowId.java b/core/api/src/main/java/org/onosproject/net/flow/FlowId.java
index 52500f5..b6d952f 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowId.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowId.java
@@ -15,17 +15,15 @@
  */
 package org.onosproject.net.flow;
 
-import com.google.common.base.Objects;
+import org.onlab.util.Identifier;
 
 /**
  * Representation of a Flow ID.
  */
-public final class FlowId {
-
-    private final long flowid;
+public final class FlowId extends Identifier<Long> {
 
     private FlowId(long id) {
-        this.flowid = id;
+        super(id);
     }
 
     public static FlowId valueOf(long id) {
@@ -33,26 +31,6 @@
     }
 
     public long value() {
-        return flowid;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (obj.getClass()  == this.getClass()) {
-            FlowId that = (FlowId) obj;
-            return Objects.equal(this.flowid, that.flowid);
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hashCode(this.flowid);
+        return this.identifier;
     }
 }
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);
     }
 
 }
diff --git a/core/api/src/main/java/org/onosproject/net/meter/MeterId.java b/core/api/src/main/java/org/onosproject/net/meter/MeterId.java
index 43c4141..4ed74b4 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/MeterId.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/MeterId.java
@@ -15,64 +15,39 @@
  */
 package org.onosproject.net.meter;
 
+import org.onlab.util.Identifier;
+
 import static com.google.common.base.Preconditions.checkArgument;
 
 /**
  * A representation of a meter id.
  * Uniquely identifies a meter in the scope of a single device.
  */
-public final class MeterId {
+public final class MeterId extends Identifier<Long> {
 
     static final long MAX = 0xFFFF0000;
 
-    private final long id;
-
     public static final MeterId SLOWPATH = new MeterId(0xFFFFFFFD);
     public static final MeterId CONTROLLER = new MeterId(0xFFFFFFFE);
     public static final MeterId ALL = new MeterId(0xFFFFFFFF);
 
     private MeterId(long id) {
+        super(id);
         checkArgument(id >= MAX, "id cannot be larger than 0xFFFF0000");
-        this.id = id;
-    }
-
-    /**
-     * The integer representation of the meter id.
-     *
-     * @return a long
-     */
-    public long id() {
-        return id;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-
-        MeterId meterId = (MeterId) o;
-
-        return id == meterId.id;
-
-    }
-
-    @Override
-    public int hashCode() {
-        return Long.hashCode(id);
     }
 
     @Override
     public String toString() {
-        return Long.toHexString(this.id);
+        return Long.toHexString(this.identifier);
     }
 
+    /**
+     * Creates a new meter identifier.
+     *
+     * @param id backing identifier value
+     * @return meter identifier
+     */
     public static MeterId meterId(long id) {
         return new MeterId(id);
-
     }
-
 }
diff --git a/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java b/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java
index 1e6780f..c9e28a0 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java
@@ -15,20 +15,16 @@
  */
 package org.onosproject.net.topology;
 
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
+import org.onlab.util.Identifier;
 
 /**
  * Representation of the topology cluster identity.
  */
-public final class ClusterId {
-
-    private final int id;
+public final class ClusterId extends Identifier<Integer> {
 
     // Public construction is prohibit
     private ClusterId(int id) {
-        this.id = id;
+        super(id);
     }
 
     /**
@@ -48,29 +44,6 @@
      * @return backing integer index
      */
     public int index() {
-        return id;
+        return identifier;
     }
-
-    @Override
-    public int hashCode() {
-        return id;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof ClusterId) {
-            final ClusterId other = (ClusterId) obj;
-            return Objects.equals(this.id, other.id);
-        }
-        return false;
-    }
-
-    @Override
-    public String toString() {
-        return toStringHelper(this).add("id", id).toString();
-    }
-
 }
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/TransactionId.java b/core/api/src/main/java/org/onosproject/store/primitives/TransactionId.java
index 21cf24b..c47de8b 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/TransactionId.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/TransactionId.java
@@ -15,42 +15,24 @@
  */
 package org.onosproject.store.primitives;
 
-import com.google.common.base.Objects;
+import org.onlab.util.Identifier;
 
 /**
  * Transaction identifier.
  */
-public final class TransactionId {
+public final class TransactionId extends Identifier<String> {
 
+    /**
+     * Creates a new transaction identifier.
+     *
+     * @param id backing identifier value
+     * @return transaction identifier
+     */
     public static TransactionId from(String id) {
         return new TransactionId(id);
     }
 
-    private final String id;
-
     private TransactionId(String id) {
-        this.id = id;
-    }
-
-    @Override
-    public String toString() {
-        return id;
-    }
-
-    @Override
-    public int hashCode() {
-        return id.hashCode();
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (this == other) {
-            return true;
-        }
-        if (other instanceof TransactionId) {
-            TransactionId that = (TransactionId) other;
-            return Objects.equal(this.id, that.id);
-        }
-        return false;
+        super(id);
     }
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java b/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java
index 05b7317..262c378 100644
--- a/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java
+++ b/core/api/src/main/java/org/onosproject/ui/topo/ButtonId.java
@@ -16,14 +16,12 @@
 
 package org.onosproject.ui.topo;
 
-import com.google.common.base.MoreObjects;
+import org.onlab.util.Identifier;
 
 /**
  * Designates the identity of a button on the topology view panels.
  */
-public class ButtonId {
-
-    private final String id;
+public class ButtonId extends Identifier<String> {
 
     /**
      * Creates a button ID with the given identifier.
@@ -31,39 +29,6 @@
      * @param id identifier for the button
      */
     public ButtonId(String id) {
-        this.id = id;
-    }
-
-    /**
-     * Returns the identifier for this button.
-     *
-     * @return identifier
-     */
-    public String id() {
-        return id;
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(getClass())
-                .add("id", id()).toString();
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-
-        ButtonId that = (ButtonId) o;
-        return id.equals(that.id);
-    }
-
-    @Override
-    public int hashCode() {
-        return id.hashCode();
+        super(id);
     }
 }
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java
index cd2b102..47559ae 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java
@@ -15,24 +15,20 @@
  */
 package org.onosproject.store.intent.impl;
 
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
+import org.onlab.util.Identifier;
 
 /**
  * Identifies a partition of the intent keyspace which will be assigned to and
  * processed by a single ONOS instance at a time.
  */
-final class PartitionId {
-    private final int id;
-
+final class PartitionId extends Identifier<Integer> {
     /**
      * Creates a new partition ID.
      *
      * @param id the partition ID
      */
     PartitionId(int id) {
-        this.id = id;
+        super(id);
     }
 
     /**
@@ -41,28 +37,6 @@
      * @return ID value
      */
     int value() {
-        return id;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (!(o instanceof PartitionId)) {
-            return false;
-        }
-
-        PartitionId that = (PartitionId) o;
-        return Objects.equals(this.id, that.id);
-    }
-
-    @Override
-    public int hashCode() {
-        return id;
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(getClass())
-                .add("partition ID", id)
-                .toString();
+        return identifier;
     }
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/domain/IntentDomainId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/domain/IntentDomainId.java
index 554702a..5b3248c 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/domain/IntentDomainId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/domain/IntentDomainId.java
@@ -16,8 +16,7 @@
 package org.onosproject.incubator.net.domain;
 
 import com.google.common.annotations.Beta;
-
-import java.util.Objects;
+import org.onlab.util.Identifier;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -25,10 +24,7 @@
  * Intent domain identifier.
  */
 @Beta
-public class IntentDomainId {
-
-    private final String id;
-
+public class IntentDomainId extends Identifier<String> {
     /**
      * Creates an intent domain identifier from the specified string representation.
      *
@@ -43,7 +39,7 @@
      * Constructor for serializer.
      */
     IntentDomainId() {
-        this.id = null;
+        super(null);
     }
 
     /**
@@ -52,28 +48,6 @@
      * @param value the underlying value of this ID
      */
     IntentDomainId(String value) {
-        this.id = checkNotNull(value, "Intent domain ID cannot be null.");
-    }
-
-    @Override
-    public int hashCode() {
-        return id.hashCode();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof IntentDomainId)) {
-            return false;
-        }
-        IntentDomainId that = (IntentDomainId) obj;
-        return Objects.equals(this.id, that.id);
-    }
-
-    @Override
-    public String toString() {
-        return id;
+        super(checkNotNull(value, "Intent domain ID cannot be null."));
     }
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityId.java
index 5bf8674..7b594c2 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmEntityId.java
@@ -15,29 +15,29 @@
  */
 package org.onosproject.incubator.net.faultmanagement.alarm;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import com.google.common.collect.ImmutableSet;
+import org.onlab.util.Identifier;
+
 import java.net.URI;
-import java.util.Objects;
 import java.util.Set;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 /**
  * Immutable representation of a alarm source. It is meaningful within the
  * context of a device.
  */
-public final class AlarmEntityId {
+public final class AlarmEntityId extends Identifier<URI> {
 
     public static final AlarmEntityId NONE = new AlarmEntityId(URI.create("none:none"));
     public static final Set<String> SCHEMES = ImmutableSet.of("none", "port", "och", "other");
 
-    private final URI uri;
-
     private AlarmEntityId(final URI uri) {
-        this.uri = uri;
+        super(uri);
     }
 
     protected AlarmEntityId() {
-        uri = NONE.uri;
+        super(NONE.identifier);
     }
 
     public static AlarmEntityId alarmEntityId(final String string) {
@@ -48,28 +48,4 @@
         checkArgument(SCHEMES.contains(uri.getScheme()), "Unexpected scheme");
         return new AlarmEntityId(uri);
     }
-
-    @Override
-    public String toString() {
-        return uri.toString();
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(uri);
-
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof AlarmEntityId) {
-            final AlarmEntityId other = (AlarmEntityId) obj;
-            return Objects.equals(this.uri, other.uri);
-        }
-        return false;
-    }
-
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java
index 4e65009..7c16d98 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java
@@ -16,8 +16,8 @@
 package org.onosproject.incubator.net.faultmanagement.alarm;
 
 import com.google.common.annotations.Beta;
-import java.util.Objects;
-import static com.google.common.base.MoreObjects.toStringHelper;
+import org.onlab.util.Identifier;
+
 import static com.google.common.base.Preconditions.checkArgument;
 /**
  * Alarm identifier suitable as an external key.
@@ -25,9 +25,8 @@
  * This class is immutable.</p>
  */
 @Beta
-public final class AlarmId {
+public final class AlarmId extends Identifier<Long> {
 
-    private final long id;
     public static final AlarmId NONE = new AlarmId();
 
     /**
@@ -36,12 +35,12 @@
      * @param id the id
      */
     private AlarmId(long id) {
+        super(id);
         checkArgument(id != 0L, "id must be non-zero");
-        this.id = id;
     }
 
     private AlarmId() {
-        this.id = 0L;
+        super(0L);
     }
 
     /**
@@ -60,29 +59,6 @@
      * @return backing integer index
      */
     public long fingerprint() {
-        return id;
+        return identifier;
     }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(id);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof AlarmId) {
-            AlarmId other = (AlarmId) obj;
-            return Objects.equals(this.id, other.id);
-        }
-        return false;
-    }
-
-    @Override
-    public String toString() {
-        return toStringHelper(this).add("id", id).toString();
-    }
-
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java
index 6fe7067..25af76d 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/resource/label/LabelResourceId.java
@@ -16,48 +16,36 @@
 package org.onosproject.incubator.net.resource.label;
 
 import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
 import org.onosproject.net.resource.ResourceId;
 
-import java.util.Objects;
-
 /**
  * Representation of a label.
  */
 @Beta
-public final class LabelResourceId implements ResourceId {
+public final class LabelResourceId extends Identifier<Long> implements ResourceId {
 
-    private long labelId;
-
+    /**
+     * Creates a new label identifier.
+     *
+     * @param labelResourceId backing identifier value
+     * @return label identifier
+     */
     public static LabelResourceId labelResourceId(long labelResourceId) {
         return new LabelResourceId(labelResourceId);
     }
 
     // Public construction is prohibited
     private LabelResourceId(long labelId) {
-        this.labelId = labelId;
+        super(labelId);
     }
 
+    /**
+     * Returns label identifier.
+     *
+     * @return label identifier
+     */
     public long labelId() {
-        return labelId;
+        return identifier;
     }
-
-    @Override
-    public int hashCode() {
-        return Objects.hashCode(labelId);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj instanceof LabelResourceId) {
-            LabelResourceId that = (LabelResourceId) obj;
-            return Objects.equals(this.labelId, that.labelId);
-        }
-        return false;
-    }
-
-    @Override
-    public String toString() {
-        return String.valueOf(this.labelId);
-    }
-
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DomainTunnelId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DomainTunnelId.java
index 430823c..a267c4e 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DomainTunnelId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DomainTunnelId.java
@@ -16,12 +16,12 @@
 
 package org.onosproject.incubator.net.tunnel;
 
+import org.onlab.util.Identifier;
+
 /**
  * A wrapper class for a long used to identify domain level tunnels.
  */
-public final class DomainTunnelId {
-
-    private final long value;
+public final class DomainTunnelId extends Identifier<Long> {
 
     /**
      * Creates a tunnel identifier from the specified tunnel.
@@ -47,7 +47,7 @@
      * Constructor for serializer.
      */
     protected DomainTunnelId() {
-        this.value = 0;
+        super(0L);
     }
 
     /**
@@ -56,37 +56,11 @@
      * @param value the underlying value of this domain ID
      */
     public DomainTunnelId(long value) {
-        this.value = value;
-    }
-
-    /**
-     * Returns the backing value of this domain ID.
-     *
-     * @return the long value
-     */
-    public long id() {
-        return value;
-    }
-
-    @Override
-    public int hashCode() {
-        return Long.hashCode(value);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof DomainTunnelId)) {
-            return false;
-        }
-        DomainTunnelId that = (DomainTunnelId) obj;
-        return this.value == that.value;
+        super(value);
     }
 
     @Override
     public String toString() {
-        return "0x" + Long.toHexString(value);
+        return "0x" + Long.toHexString(identifier);
     }
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/NetworkTunnelId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/NetworkTunnelId.java
index a3de788..e3c2338 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/NetworkTunnelId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/NetworkTunnelId.java
@@ -17,14 +17,13 @@
 package org.onosproject.incubator.net.tunnel;
 
 import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
 
 /**
  * Representation of a Network Tunnel Id.
  */
 @Beta
-public final class NetworkTunnelId {
-    private final long value;
-
+public final class NetworkTunnelId extends Identifier<Long> {
     /**
      * Creates an tunnel identifier from the specified tunnel.
      *
@@ -43,7 +42,7 @@
      * Constructor for serializer.
      */
     NetworkTunnelId() {
-        this.value = 0;
+        super(0L);
     }
 
     /**
@@ -52,38 +51,11 @@
      * @param value the underlying value of this ID
      */
     public NetworkTunnelId(long value) {
-        this.value = value;
-    }
-
-    /**
-     * Returns the backing value.
-     *
-     * @return the value
-     */
-    public long id() {
-        return value;
-    }
-
-    @Override
-    public int hashCode() {
-        return Long.hashCode(value);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof NetworkTunnelId)) {
-            return false;
-        }
-        NetworkTunnelId that = (NetworkTunnelId) obj;
-        return this.value == that.value;
+        super(value);
     }
 
     @Override
     public String toString() {
-        return "0x" + Long.toHexString(value);
+        return "0x" + Long.toHexString(identifier);
     }
-
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/OpticalLogicId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/OpticalLogicId.java
index d599486..2017850 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/OpticalLogicId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/OpticalLogicId.java
@@ -16,66 +16,44 @@
 
 package org.onosproject.incubator.net.tunnel;
 
-import java.util.Objects;
-
 import com.google.common.annotations.Beta;
 import com.google.common.primitives.UnsignedLongs;
+import org.onlab.util.Identifier;
 
 /**
  * Representation of a label Id, a logical port identifier.
  */
 @Beta
-public final class OpticalLogicId {
-        /**
-         * Represents a logical Id.
-        */
-        private final long logicId;
+public final class OpticalLogicId extends Identifier<Long> {
 
-        /**
-         * Constructor, public creation is prohibited.
-         */
-        private OpticalLogicId(long id) {
-            this.logicId = id;
-        }
+    /**
+     * Constructor, public creation is prohibited.
+     */
+    private OpticalLogicId(long id) {
+        super(id);
+    }
 
-        /**
-         * Returns the LabelId representing the specified long value.
-         *
-         * @param id identifier as long value
-         * @return LabelId
-         */
-        public static OpticalLogicId logicId(long id) {
-            return new OpticalLogicId(id);
-        }
+    /**
+     * Returns the LabelId representing the specified long value.
+     *
+     * @param id identifier as long value
+     * @return LabelId
+     */
+    public static OpticalLogicId logicId(long id) {
+        return new OpticalLogicId(id);
+    }
 
-        public static OpticalLogicId logicId(String string) {
-            return new OpticalLogicId(UnsignedLongs.decode(string));
-        }
+    /**
+     * Returns the LabelId representing the specified string value.
+     *
+     * @param string identifier as string value
+     * @return LabelId
+     */
+    public static OpticalLogicId logicId(String string) {
+        return new OpticalLogicId(UnsignedLongs.decode(string));
+    }
 
-        public long toLong() {
-            return logicId;
-        }
-
-        @Override
-        public String toString() {
-            return UnsignedLongs.toString(logicId);
-        }
-
-        @Override
-        public int hashCode() {
-            return Objects.hashCode(logicId);
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof OpticalLogicId) {
-                final OpticalLogicId other = (OpticalLogicId) obj;
-                return this.logicId == other.logicId;
-            }
-            return false;
-        }
-
+    public long toLong() {
+        return identifier;
+    }
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelId.java
index 5a3f97f..ac5e7e0 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelId.java
@@ -17,14 +17,13 @@
 package org.onosproject.incubator.net.tunnel;
 
 import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
 
 /**
  * Representation of a Tunnel Id.
  */
 @Beta
-public final class TunnelId {
-    private final long value;
-
+public final class TunnelId extends Identifier<Long> {
     /**
      * Creates an tunnel identifier from the specified tunnel.
      *
@@ -43,7 +42,7 @@
      * Constructor for serializer.
      */
     TunnelId() {
-        this.value = 0;
+        super(0L);
     }
 
     /**
@@ -52,38 +51,11 @@
      * @param value the underlying value of this ID
      */
     TunnelId(long value) {
-        this.value = value;
-    }
-
-    /**
-     * Returns the backing value.
-     *
-     * @return the value
-     */
-    public long id() {
-        return value;
-    }
-
-    @Override
-    public int hashCode() {
-        return Long.hashCode(value);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (!(obj instanceof TunnelId)) {
-            return false;
-        }
-        TunnelId that = (TunnelId) obj;
-        return this.value == that.value;
+        super(value);
     }
 
     @Override
     public String toString() {
-        return "0x" + Long.toHexString(value);
+        return "0x" + Long.toHexString(identifier);
     }
-
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/NetworkId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/NetworkId.java
index 2712328..b3d920b 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/NetworkId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/NetworkId.java
@@ -16,14 +16,13 @@
 package org.onosproject.incubator.net.virtual;
 
 import com.google.common.annotations.Beta;
-
-import java.util.Objects;
+import org.onlab.util.Identifier;
 
 /**
  * Representation of network identity.
  */
 @Beta
-public final class NetworkId {
+public final class NetworkId extends Identifier<Long> {
 
     /**
      * Represents no network, or an unspecified network.
@@ -35,18 +34,15 @@
      */
     public static final NetworkId PHYSICAL = networkId(0L);
 
-
-    private final long id;
-
     // Public construction is prohibited
     private NetworkId(long id) {
-        this.id = id;
+        super(id);
     }
 
 
     // Default constructor for serialization
     protected NetworkId() {
-        this.id = -1;
+        super(-1L);
     }
 
     /**
@@ -58,27 +54,4 @@
     public static NetworkId networkId(long id) {
         return new NetworkId(id);
     }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(id);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof NetworkId) {
-            final NetworkId that = (NetworkId) obj;
-            return this.getClass() == that.getClass() && this.id == that.id;
-        }
-        return false;
-    }
-
-    @Override
-    public String toString() {
-        return Long.toString(id);
-    }
-
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/TenantId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/TenantId.java
index 196c17d..7488be0 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/TenantId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/TenantId.java
@@ -16,8 +16,7 @@
 package org.onosproject.incubator.net.virtual;
 
 import com.google.common.annotations.Beta;
-
-import java.util.Objects;
+import org.onlab.util.Identifier;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
@@ -25,26 +24,22 @@
  * Representation of network tenant.
  */
 @Beta
-public final class TenantId {
+public final class TenantId extends Identifier<String> {
 
     /**
      * Represents no tenant, or an unspecified tenant.
      */
     public static final TenantId NONE = new TenantId();
 
-
-    private final String id;
-
     // Public construction is prohibited
     private TenantId(String id) {
+        super(id);
         checkArgument(id != null && id.length() > 0, "Tenant ID cannot be null or empty");
-        this.id = id;
     }
 
-
     // Default constructor for serialization
     protected TenantId() {
-        this.id = "";
+        super("");
     }
 
     /**
@@ -56,28 +51,4 @@
     public static TenantId tenantId(String id) {
         return new TenantId(id);
     }
-
-    @Override
-    public int hashCode() {
-        return id.hashCode();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof TenantId) {
-            final TenantId that = (TenantId) obj;
-            return this.getClass() == that.getClass() &&
-                    Objects.equals(this.id, that.id);
-        }
-        return false;
-    }
-
-    @Override
-    public String toString() {
-        return id;
-    }
-
 }