Renamed devicemanager, flowprogrammer, linkdiscovery and util packages
net.onrc.onos.ofcontroller.devicemanager.* => net.onrc.onos.core.devicemanager.*
net.onrc.onos.ofcontroller.flowprogrammer.* => net.onrc.onos.core.flowprogrammer.*
net.onrc.onos.ofcontroller.linkdiscovery.* => net.onrc.onos.core.linkdiscovery.*
net.onrc.onos.ofcontroller.util.* => net.onrc.onos.core.util.*
Change-Id: Iaa865af552e8fb3a589e73d006569ac79f5a0f08
diff --git a/src/main/java/net/onrc/onos/core/util/Dpid.java b/src/main/java/net/onrc/onos/core/util/Dpid.java
new file mode 100644
index 0000000..dcc3a7c
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/util/Dpid.java
@@ -0,0 +1,88 @@
+package net.onrc.onos.core.util;
+
+import net.onrc.onos.core.util.serializers.DpidDeserializer;
+import net.onrc.onos.core.util.serializers.DpidSerializer;
+
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.openflow.util.HexString;
+
+/**
+ * The class representing a network switch DPID.
+ */
+@JsonDeserialize(using=DpidDeserializer.class)
+@JsonSerialize(using=DpidSerializer.class)
+public class Dpid {
+ static public final long UNKNOWN = 0;
+
+ private long value;
+
+ /**
+ * Default constructor.
+ */
+ public Dpid() {
+ this.value = Dpid.UNKNOWN;
+ }
+
+ /**
+ * Constructor from a long value.
+ *
+ * @param value the value to use.
+ */
+ public Dpid(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public Dpid(String value) {
+ this.value = HexString.toLong(value);
+ }
+
+ /**
+ * Get the value of the DPID.
+ *
+ * @return the value of the DPID.
+ */
+ public long value() { return value; }
+
+ /**
+ * Set the value of the DPID.
+ *
+ * @param value the value to set.
+ */
+ public void setValue(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Convert the DPID value to a ':' separated hexadecimal string.
+ *
+ * @return the DPID value as a ':' separated hexadecimal string.
+ */
+ @Override
+ public String toString() {
+ return HexString.toHexString(this.value);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof Dpid)) {
+ return false;
+ }
+
+ Dpid otherDpid = (Dpid) other;
+
+ return value == otherDpid.value;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 17;
+ hash += 31 * hash + (int)(value ^ value >>> 32);
+ return hash;
+ }
+}