Change some of the basic classes in the "unit/" directory to immutable:
* Change each class to "final"
* Change the fields to "final"
* Remove the "set" methods
Change-Id: I3499489024403b55328ffb1827fc8c3b5ffd231e
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 eb72b72..9178267 100644
--- a/src/main/java/net/onrc/onos/core/util/SwitchPort.java
+++ b/src/main/java/net/onrc/onos/core/util/SwitchPort.java
@@ -4,15 +4,18 @@
/**
* The class representing a Switch-Port.
+ * This class is immutable.
*/
-public class SwitchPort {
- private Dpid dpid; // The DPID of the switch
- private Port port; // The port of the switch
+public final class SwitchPort {
+ private final Dpid dpid; // The DPID of the switch
+ private final Port port; // The port of the switch
/**
* Default constructor.
*/
public SwitchPort() {
+ this.dpid = null;
+ this.port = null;
}
/**
@@ -37,16 +40,6 @@
}
/**
- * 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.
@@ -57,27 +50,6 @@
}
/**
- * 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;
- }
-
- /**
* Convert the Switch-Port value to a string.
* <p/>
* The string has the following form:
@@ -90,7 +62,6 @@
return this.dpid.toString() + "/" + this.port;
}
-
@Override
public boolean equals(Object other) {
if (!(other instanceof SwitchPort)) {