Implemented hashcode() and equals() on Dpid, Port and SwitchPort in order to make SwitchPort comparison easier
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/Dpid.java b/src/main/java/net/onrc/onos/ofcontroller/util/Dpid.java
index c3cf3aa..7f5406e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/Dpid.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/Dpid.java
@@ -13,58 +13,76 @@
 @JsonDeserialize(using=DpidDeserializer.class)
 @JsonSerialize(using=DpidSerializer.class)
 public class Dpid {
-    static public long UNKNOWN = 0;
+	static public long UNKNOWN = 0;
 
-    private long value;
+	private long value;
 
-    /**
-     * Default constructor.
-     */
-    public Dpid() {
-	this.value = Dpid.UNKNOWN;
-    }
+	/**
+	 * 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 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);
-    }
+	/**
+	 * 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; }
+	/**
+	 * 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;
-    }
+	/**
+	 * 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);
-    }
+	/**
+	 * 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;
+	}
 }
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/Port.java b/src/main/java/net/onrc/onos/ofcontroller/util/Port.java
index bb4851c..4979e0d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/Port.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/Port.java
@@ -7,128 +7,148 @@
  */
 
 public class Port {
-    /**
-     * Special port values.
-     *
-     * Those values are taken as-is from the OpenFlow-v1.0.0 specification
-     * (pp 18-19).
-     */
-    public enum PortValues {
-	/* Maximum number of physical switch ports. */
-	PORT_MAX		((short)0xff00),
+	/**
+	 * Special port values.
+	 *
+	 * Those values are taken as-is from the OpenFlow-v1.0.0 specification
+	 * (pp 18-19).
+	 */
+	// This is a duplicate of the OFPort enum in OpenflowJ.
+	// TODO Can we remove this?
+	public enum PortValues {
+		/* Maximum number of physical switch ports. */
+		PORT_MAX		((short)0xff00),
 
-	/* Fake output "ports". */
+		/* Fake output "ports". */
 
-	/* Send the packet out the input port. This
+		/* Send the packet out the input port. This
 	   virtual port must be explicitly used
 	   in order to send back out of the input
 	   port. */
-	PORT_IN_PORT		((short)0xfff8),
+		PORT_IN_PORT		((short)0xfff8),
 
-	/* Perform actions in flow table.
+		/* Perform actions in flow table.
 	   NB: This can only be the destination
 	   port for packet-out messages. */
-	PORT_TABLE		((short)0xfff9),
+		PORT_TABLE		((short)0xfff9),
 
-	/* Process with normal L2/L3 switching. */
-	PORT_NORMAL		((short)0xfffa),
+		/* Process with normal L2/L3 switching. */
+		PORT_NORMAL		((short)0xfffa),
 
-	/* All physical ports except input port and
+		/* All physical ports except input port and
 	   those disabled by STP. */
-	PORT_FLOOD		((short)0xfffb),
+		PORT_FLOOD		((short)0xfffb),
 
-	/* All physical ports except input port. */
-	PORT_ALL		((short)0xfffc),
+		/* All physical ports except input port. */
+		PORT_ALL		((short)0xfffc),
 
-	/* Send to controller. */
-	PORT_CONTROLLER		((short)0xfffd),
+		/* Send to controller. */
+		PORT_CONTROLLER		((short)0xfffd),
 
-	/* Local openflow "port". */
-	PORT_LOCAL		((short)0xfffe),
+		/* Local openflow "port". */
+		PORT_LOCAL		((short)0xfffe),
 
-	/* Not associated with a physical port. */
-	PORT_NONE		((short)0xffff);
+		/* Not associated with a physical port. */
+		PORT_NONE		((short)0xffff);
 
-	private final short value;	// The value
+		private final short value;	// The value
+
+		/**
+		 * Constructor for a given value.
+		 *
+		 * @param value the value to use for the initialization.
+		 */
+		private PortValues(short value) {
+			this.value = value;
+		}
+
+		/**
+		 * Get the value as a short integer.
+		 *
+		 * @return the value as a short integer.
+		 */
+		private short value() { return this.value; }
+	}
+
+	private short value;
 
 	/**
-	 * Constructor for a given value.
-	 *
-	 * @param value the value to use for the initialization.
+	 * Default constructor.
 	 */
-	private PortValues(short value) {
-	    this.value = value;
+	public Port() {
+		this.value = 0;
 	}
 
 	/**
-	 * Get the value as a short integer.
+	 * Copy constructor.
 	 *
-	 * @return the value as a short integer.
+	 * @param other the object to copy from.
 	 */
-	private short value() { return this.value; }
-    }
+	public Port(Port other) {
+		this.value = other.value();
+	}
 
-    private short value;
+	/**
+	 * Constructor from a short integer value.
+	 *
+	 * @param value the value to use.
+	 */
+	public Port(short value) {
+		this.value = value;
+	}
 
-    /**
-     * Default constructor.
-     */
-    public Port() {
-	this.value = 0;
-    }
+	/**
+	 * Constructor from a PortValues enum value.
+	 *
+	 * @param value the value to use.
+	 */
+	public Port(PortValues value) {
+		this.value = value.value();
+	}
 
-    /**
-     * Copy constructor.
-     *
-     * @param other the object to copy from.
-     */
-    public Port(Port other) {
-	this.value = other.value();
-    }
+	/**
+	 * Get the value of the port.
+	 *
+	 * @return the value of the port.
+	 */
+	@JsonProperty("value")
+	public short value() { return value; }
 
-    /**
-     * Constructor from a short integer value.
-     *
-     * @param value the value to use.
-     */
-    public Port(short value) {
-	this.value = value;
-    }
+	/**
+	 * Set the value of the port.
+	 *
+	 * @param value the value to set.
+	 */
+	@JsonProperty("value")
+	public void setValue(short value) {
+		this.value = value;
+	}
 
-    /**
-     * Constructor from a PortValues enum value.
-     *
-     * @param value the value to use.
-     */
-    public Port(PortValues value) {
-	this.value = value.value();
-    }
+	/**
+	 * Convert the port value to a string.
+	 *
+	 * @return the port value as a string.
+	 */
+	@Override
+	public String toString() {
+		return Short.toString(this.value);
+	}
 
-    /**
-     * Get the value of the port.
-     *
-     * @return the value of the port.
-     */
-    @JsonProperty("value")
-    public short value() { return value; }
+	@Override
+	public boolean equals(Object other) {
+		if (!(other instanceof Port)) {
+			return false;
+		}
 
-    /**
-     * Set the value of the port.
-     *
-     * @param value the value to set.
-     */
-    @JsonProperty("value")
-    public void setValue(short value) {
-	this.value = value;
-    }
+		Port otherPort = (Port) other;
 
-    /**
-     * Convert the port value to a string.
-     *
-     * @return the port value as a string.
-     */
-    @Override
-    public String toString() {
-	return Short.toString(this.value);
-    }
+		return value == otherPort.value;
+	}
+
+	@Override
+	public int hashCode() {
+		int hash = 17;
+		hash += 31 * hash + (int)value; 
+		return hash;
+	}
 }
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/SwitchPort.java b/src/main/java/net/onrc/onos/ofcontroller/util/SwitchPort.java
index 95a934f..898b9b0 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/SwitchPort.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/SwitchPort.java
@@ -6,83 +6,103 @@
  * The class representing a Switch-Port.
  */
 public class SwitchPort {
-    private Dpid dpid;		// The DPID of the switch
-    private Port port;		// The port of the switch
+	private Dpid dpid;		// The DPID of the switch
+	private Port port;		// The port of the switch
 
-    /**
-     * Default constructor.
-     */
-    public SwitchPort() {
-    }
+	/**
+	 * Default constructor.
+	 */
+	public SwitchPort() {
+	}
 
-    /**
-     * Constructor for a given DPID and a port.
-     *
-     * @param dpid the DPID to use.
-     * @param port the port to use.
-     */
-    public SwitchPort(Dpid dpid, Port port) {
-	this.dpid = dpid;
-	this.port = port;
-    }
+	/**
+	 * Constructor for a given DPID and a port.
+	 *
+	 * @param dpid the DPID to use.
+	 * @param port the port to use.
+	 */
+	public SwitchPort(Dpid dpid, Port port) {
+		this.dpid = dpid;
+		this.port = port;
+	}
 
-    /**
-     * Get the DPID value of the Switch-Port.
-     *
-     * @return the DPID value of the Switch-Port.
-     */
-    @JsonProperty("dpid")
-    public Dpid dpid() { return dpid; }
+	/**
+	 * Get the DPID value of the Switch-Port.
+	 *
+	 * @return the DPID value of the Switch-Port.
+	 */
+	@JsonProperty("dpid")
+	public Dpid dpid() { return dpid; }
 
-    /**
-     * Set the DPID value of the Switch-Port.
-     *
-     * @param dpid the DPID to use.
-     */
-    @JsonProperty("dpid")
-    public void setDpid(Dpid dpid) {
-	this.dpid = dpid;
-    }
+	/**
+	 * Set the DPID value of the Switch-Port.
+	 *
+	 * @param dpid the DPID to use.
+	 */
+	@JsonProperty("dpid")
+	public void setDpid(Dpid dpid) {
+		this.dpid = dpid;
+	}
 
-    /**
-     * Get the port value of the Switch-Port.
-     *
-     * @return the port value of the Switch-Port.
-     */
-    @JsonProperty("port")
-    public Port port() { return port; }
+	/**
+	 * Get the port value of the Switch-Port.
+	 *
+	 * @return the port value of the Switch-Port.
+	 */
+	@JsonProperty("port")
+	public Port port() { return port; }
 
-    /**
-     * Set the port value of the Switch-Port.
-     *
-     * @param port the port to use.
-     */
-    @JsonProperty("port")
-    public void setPort(Port port) {
-	this.port = port;
-    }
+	/**
+	 * Set the port value of the Switch-Port.
+	 *
+	 * @param port the port to use.
+	 */
+	@JsonProperty("port")
+	public void setPort(Port port) {
+		this.port = port;
+	}
 
-    /**
-     * Set the DPID and port values of the Switch-Port.
-     *
-     * @param dpid the DPID to use.
-     * @param port the port to use.
-     */
-    public void setValue(Dpid dpid, Port port) {
-	this.dpid = dpid;
-	this.port = port;
-    }
+	/**
+	 * Set the DPID and port values of the Switch-Port.
+	 *
+	 * @param dpid the DPID to use.
+	 * @param port the port to use.
+	 */
+	public void setValue(Dpid dpid, Port port) {
+		this.dpid = dpid;
+		this.port = port;
+	}
 
-    /**
-     * Convert the Switch-Port value to a string.
-     *
-     * The string has the following form:
-     *  01:02:03:04:05:06:07:08/1234
-     *
-     * @return the Switch-Port value as a string.
-     */
-    @Override
-    public String toString() {
-	return this.dpid.toString() + "/" + this.port;
-    }
+	/**
+	 * Convert the Switch-Port value to a string.
+	 *
+	 * The string has the following form:
+	 *  01:02:03:04:05:06:07:08/1234
+	 *
+	 * @return the Switch-Port value as a string.
+	 */
+	@Override
+	public String toString() {
+		return this.dpid.toString() + "/" + this.port;
+	}
+
+	@Override
+	public boolean equals(Object other) {
+		if (!(other instanceof SwitchPort)) {
+			return false;
+		}
+
+		SwitchPort otherSwitchPort = (SwitchPort) other;
+
+		return (dpid.equals(otherSwitchPort.dpid) &&
+				port.equals(otherSwitchPort.port));
+	}
+
+	@Override
+	public int hashCode() {
+		int hash = 17;
+		hash += 31 * hash + dpid.hashCode();
+		hash += 31 * hash + port.hashCode();
+		return hash;
+	}
 }