Remove PortEvent.SwitchPort
- JSON format of util.SwitchPort has changed to match PortEvent.SwitchPort.
(not sure if it was currently used in public API)
- Note: SwitchPort#toString() format is different. Log messages, etc. may have changed.
PortEvent.SwitchPort : "(dpid@number)" both decimal
util.SwitchPort : "00:00:...:01/number" dpid as HexString, number as decimal
- Part of ONOS-1564
Change-Id: I19ea06de7a701f0f7aaae0a7ed6f0726c0133a91
diff --git a/src/main/java/net/onrc/onos/core/util/SwitchPort.java b/src/main/java/net/onrc/onos/core/util/SwitchPort.java
index b3ed985..c2079a0 100644
--- a/src/main/java/net/onrc/onos/core/util/SwitchPort.java
+++ b/src/main/java/net/onrc/onos/core/util/SwitchPort.java
@@ -1,19 +1,22 @@
package net.onrc.onos.core.util;
-import org.codehaus.jackson.annotate.JsonProperty;
+import net.onrc.onos.core.util.serializers.SwitchPortSerializer;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing a Switch-Port.
* This class is immutable.
*/
+@JsonSerialize(using = SwitchPortSerializer.class)
public final class SwitchPort {
private final Dpid dpid; // The DPID of the switch
private final PortNumber port; // The port of the switch
/**
- * Default constructor.
+ * Default constructor for Serializer to use.
*/
- public SwitchPort() {
+ protected SwitchPort() {
this.dpid = null;
this.port = null;
}
@@ -41,26 +44,53 @@
}
/**
+ * Constructor for the specified primitive values of a DPID and port.
+ *
+ * @param dpid the DPID to use
+ * @param port the port number to use
+ */
+ public SwitchPort(Long dpid, Long port) {
+ this.dpid = new Dpid(dpid);
+ this.port = new PortNumber(port.shortValue());
+ }
+
+ /**
* 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.
+ */
+ public Dpid getDpid() {
+ return dpid;
+ }
+
+ /**
* Get the port value of the Switch-Port.
*
* @return the port value of the Switch-Port.
*/
- @JsonProperty("port")
public PortNumber port() {
return port;
}
/**
+ * Get the port value of the Switch-Port.
+ *
+ * @return the port value of the Switch-Port.
+ */
+ public PortNumber getNumber() {
+ return port;
+ }
+
+ /**
* Convert the Switch-Port value to a string.
* <p/>
* The string has the following form: