Cosmetic fixes

- Changed Port#{asSwitchPort() -> getSwitchPort()}
- Added   Port#getPortNumber()
- Changed some formal param names: e.g., number -> portNumber

Change-Id: If93043489591e43e189137ee2f82907e863fdada
diff --git a/src/main/java/net/onrc/onos/core/topology/Port.java b/src/main/java/net/onrc/onos/core/topology/Port.java
index 50feb99..2e428c7 100644
--- a/src/main/java/net/onrc/onos/core/topology/Port.java
+++ b/src/main/java/net/onrc/onos/core/topology/Port.java
@@ -33,12 +33,19 @@
     public PortNumber getNumber();
 
     /**
+     * Gets the port number of this port.
+     *
+     * @return port number
+     */
+    public PortNumber getPortNumber();
+
+    /**
      * Gets a {@link SwitchPort} that represents this Port's dpid and port
      * number.
      *
      * @return a SwitchPort representing the Port
      */
-    public SwitchPort asSwitchPort();
+    public SwitchPort getSwitchPort();
 
     /**
      * Gets the hardware address of this port.
diff --git a/src/main/java/net/onrc/onos/core/topology/PortImpl.java b/src/main/java/net/onrc/onos/core/topology/PortImpl.java
index 4e0da5e..ec779e5 100644
--- a/src/main/java/net/onrc/onos/core/topology/PortImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/PortImpl.java
@@ -43,16 +43,21 @@
 
     @Override
     public Dpid getDpid() {
-        return asSwitchPort().getDpid();
+        return getSwitchPort().getDpid();
     }
 
     @Override
     public PortNumber getNumber() {
-        return asSwitchPort().getPortNumber();
+        return getPortNumber();
     }
 
     @Override
-    public SwitchPort asSwitchPort() {
+    public PortNumber getPortNumber() {
+        return getSwitchPort().getPortNumber();
+    }
+
+    @Override
+    public SwitchPort getSwitchPort() {
         return id;
     }
 
@@ -81,7 +86,7 @@
     public Link getOutgoingLink() {
         topology.acquireReadLock();
         try {
-            return topology.getOutgoingLink(asSwitchPort());
+            return topology.getOutgoingLink(getSwitchPort());
         } finally {
             topology.releaseReadLock();
         }
@@ -91,7 +96,7 @@
     public Link getOutgoingLink(String type) {
         topology.acquireReadLock();
         try {
-            return topology.getOutgoingLink(asSwitchPort(), type);
+            return topology.getOutgoingLink(getSwitchPort(), type);
         } finally {
             topology.releaseReadLock();
         }
@@ -101,7 +106,7 @@
     public Collection<Link> getOutgoingLinks() {
         topology.acquireReadLock();
         try {
-            return topology.getOutgoingLinks(asSwitchPort());
+            return topology.getOutgoingLinks(getSwitchPort());
         } finally {
             topology.releaseReadLock();
         }
@@ -111,7 +116,7 @@
     public Link getIncomingLink() {
         topology.acquireReadLock();
         try {
-            return topology.getIncomingLink(asSwitchPort());
+            return topology.getIncomingLink(getSwitchPort());
         } finally {
             topology.releaseReadLock();
         }
@@ -121,7 +126,7 @@
     public Link getIncomingLink(String type) {
         topology.acquireReadLock();
         try {
-            return topology.getIncomingLink(asSwitchPort(), type);
+            return topology.getIncomingLink(getSwitchPort(), type);
         } finally {
             topology.releaseReadLock();
         }
@@ -131,7 +136,7 @@
     public Collection<Link> getIncomingLinks() {
         topology.acquireReadLock();
         try {
-            return topology.getIncomingLinks(asSwitchPort());
+            return topology.getIncomingLinks(getSwitchPort());
         } finally {
             topology.releaseReadLock();
         }
@@ -141,7 +146,7 @@
     public Collection<Host> getHosts() {
         topology.acquireReadLock();
         try {
-            return topology.getHosts(this.asSwitchPort());
+            return topology.getHosts(this.getSwitchPort());
         } finally {
             topology.releaseReadLock();
         }
diff --git a/src/main/java/net/onrc/onos/core/topology/Switch.java b/src/main/java/net/onrc/onos/core/topology/Switch.java
index 58b10c7..67e9c94 100644
--- a/src/main/java/net/onrc/onos/core/topology/Switch.java
+++ b/src/main/java/net/onrc/onos/core/topology/Switch.java
@@ -33,11 +33,11 @@
     /**
      * Gets a port on switch by port number.
      *
-     * @param number port number
+     * @param portNumber port number
      * @return {@link Port} with {@code number} on this switch, or {@code null}
      *         if this switch did not have a port for specified port number
      */
-    public Port getPort(PortNumber number);
+    public Port getPort(PortNumber portNumber);
 
     // Graph traversal API
 
@@ -73,7 +73,6 @@
      */
     public Link getLinkToNeighbor(Dpid dpid);
 
-    // XXX Iterable or Collection?
     /**
      * Gets all the devices attached to this switch.
      *
diff --git a/src/main/java/net/onrc/onos/core/topology/Topology.java b/src/main/java/net/onrc/onos/core/topology/Topology.java
index ef30379..4e1b61e 100644
--- a/src/main/java/net/onrc/onos/core/topology/Topology.java
+++ b/src/main/java/net/onrc/onos/core/topology/Topology.java
@@ -37,10 +37,10 @@
      * Gets the port on a switch.
      *
      * @param dpid   the switch DPID.
-     * @param number the switch port number.
+     * @param portNumber the switch port number.
      * @return the switch port if found, otherwise null.
      */
-    public Port getPort(Dpid dpid, PortNumber number);
+    public Port getPort(Dpid dpid, PortNumber portNumber);
 
     /**
      * Gets the port on a switch.
@@ -65,20 +65,20 @@
      * returns it if found, else return whichever link is found first.
      *
      * @param dpid   the switch DPID.
-     * @param number the switch port number.
+     * @param portNumber the switch port number.
      * @return the outgoing link if found, otherwise null.
      */
-    public Link getOutgoingLink(Dpid dpid, PortNumber number);
+    public Link getOutgoingLink(Dpid dpid, PortNumber portNumber);
 
     /**
      * Gets the outgoing link from a switch port.
      *
      * @param dpid   the switch DPID.
-     * @param number the switch port number.
+     * @param portNumber the switch port number.
      * @param type   type of the link
      * @return the outgoing link if found, otherwise null.
      */
-    public Link getOutgoingLink(Dpid dpid, PortNumber number, String type);
+    public Link getOutgoingLink(Dpid dpid, PortNumber portNumber, String type);
 
     /**
      * Gets the outgoing link from a switch port.
@@ -115,10 +115,10 @@
      * returns it if found, else return whichever link is found first.
      *
      * @param dpid   the switch DPID.
-     * @param number the switch port number.
+     * @param portNumber the switch port number.
      * @return the incoming link if found, otherwise null.
      */
-    public Link getIncomingLink(Dpid dpid, PortNumber number);
+    public Link getIncomingLink(Dpid dpid, PortNumber portNumber);
 
     /**
      * Gets the incoming link to a switch port.
@@ -127,11 +127,11 @@
      * returns it if found, else return whichever link is found first.
      *
      * @param dpid   the switch DPID.
-     * @param number the switch port number.
+     * @param portNumber the switch port number.
      * @param type type of the link
      * @return the incoming link if found, otherwise null.
      */
-    public Link getIncomingLink(Dpid dpid, PortNumber number, String type);
+    public Link getIncomingLink(Dpid dpid, PortNumber portNumber, String type);
 
 
     /**
@@ -167,27 +167,27 @@
      * a port.
      *
      * @param srcDpid   the source switch DPID.
-     * @param srcNumber the source switch port number.
+     * @param srcPortNumber the source switch port number.
      * @param dstDpid   the destination switch DPID.
-     * @param dstNumber the destination switch port number.
+     * @param dstPortNumber the destination switch port number.
      * @return the outgoing link if found, otherwise null.
      */
-    public Link getLink(Dpid srcDpid, PortNumber srcNumber,
-                        Dpid dstDpid, PortNumber dstNumber);
+    public Link getLink(Dpid srcDpid, PortNumber srcPortNumber,
+                        Dpid dstDpid, PortNumber dstPortNumber);
 
     /**
      * Gets the outgoing link from a switch and a port to another switch and
      * a port.
      *
      * @param srcDpid   the source switch DPID.
-     * @param srcNumber the source switch port number.
+     * @param srcPortNumber the source switch port number.
      * @param dstDpid   the destination switch DPID.
-     * @param dstNumber the destination switch port number.
+     * @param dstPortNumber the destination switch port number.
      * @param type      type of the link
      * @return the outgoing link if found, otherwise null.
      */
-    public Link getLink(Dpid srcDpid, PortNumber srcNumber,
-                        Dpid dstDpid, PortNumber dstNumber,
+    public Link getLink(Dpid srcDpid, PortNumber srcPortNumber,
+                        Dpid dstDpid, PortNumber dstPortNumber,
                         String type);
 
     /**
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java b/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
index d79d204..fcf3caa 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
@@ -282,7 +282,7 @@
             if (link == null) {
                 continue;
             }
-            if (link.getDstPort().asSwitchPort().equals(dstSwitchPort)) {
+            if (link.getDstPort().getSwitchPort().equals(dstSwitchPort)) {
                 return link;
             }
         }
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
index dccef16..aa6642c 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
@@ -931,7 +931,7 @@
         for (Port port : topology.getPorts(dpid)) {
             log.warn("Port {} on Switch {} should be removed prior to removing Switch. Removing Port now.",
                     port, switchEvent);
-            PortEvent portEvent = new PortEvent(port.asSwitchPort());
+            PortEvent portEvent = new PortEvent(port.getSwitchPort());
             portsToRemove.add(portEvent);
         }
         for (PortEvent portEvent : portsToRemove) {
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
index 19425e5..80bbe24 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/HostSerializer.java
@@ -38,7 +38,7 @@
         jsonGenerator.writeFieldName("attachmentPoints");
         jsonGenerator.writeStartArray();
         for (Port port : host.getAttachmentPoints()) {
-            jsonGenerator.writeObject(port.asSwitchPort());
+            jsonGenerator.writeObject(port.getSwitchPort());
         }
         jsonGenerator.writeEndArray();
         jsonGenerator.writeEndObject();
diff --git a/src/main/java/net/onrc/onos/core/topology/web/serializers/LinkSerializer.java b/src/main/java/net/onrc/onos/core/topology/web/serializers/LinkSerializer.java
index 10b29ea..b0984da 100644
--- a/src/main/java/net/onrc/onos/core/topology/web/serializers/LinkSerializer.java
+++ b/src/main/java/net/onrc/onos/core/topology/web/serializers/LinkSerializer.java
@@ -34,8 +34,8 @@
         //
         jsonGenerator.writeStartObject();
         jsonGenerator.writeStringField(TopologyElement.TYPE, link.getType());
-        jsonGenerator.writeObjectField("src", link.getSrcPort().asSwitchPort());
-        jsonGenerator.writeObjectField("dst", link.getDstPort().asSwitchPort());
+        jsonGenerator.writeObjectField("src", link.getSrcPort().getSwitchPort());
+        jsonGenerator.writeObjectField("dst", link.getDstPort().getSwitchPort());
         jsonGenerator.writeObjectFieldStart("stringAttributes");
         for (Entry<String, String> entry : link.getAllStringAttributes().entrySet()) {
             jsonGenerator.writeStringField(entry.getKey(), entry.getValue());
diff --git a/src/test/java/net/onrc/onos/core/topology/MockTopology.java b/src/test/java/net/onrc/onos/core/topology/MockTopology.java
index 3208a0d..3cfcb18 100644
--- a/src/test/java/net/onrc/onos/core/topology/MockTopology.java
+++ b/src/test/java/net/onrc/onos/core/topology/MockTopology.java
@@ -126,13 +126,13 @@
 
         MACAddress mac1 = MACAddress.valueOf("00:44:33:22:11:00");
         HostEvent host1 = new HostEvent(mac1);
-        host1.addAttachmentPoint(port15.asSwitchPort());
+        host1.addAttachmentPoint(port15.getSwitchPort());
         host1.setLastSeenTime(1L);
         this.putHost(host1);
 
         MACAddress mac3 = MACAddress.valueOf("00:11:22:33:44:55");
         HostEvent host3 = new HostEvent(mac3);
-        host3.addAttachmentPoint(port35.asSwitchPort());
+        host3.addAttachmentPoint(port35.getSwitchPort());
         host3.setLastSeenTime(1L);
         this.putHost(host3);
 
diff --git a/src/test/java/net/onrc/onos/core/topology/TopologyImplTest.java b/src/test/java/net/onrc/onos/core/topology/TopologyImplTest.java
index df0818f..141a4f0 100644
--- a/src/test/java/net/onrc/onos/core/topology/TopologyImplTest.java
+++ b/src/test/java/net/onrc/onos/core/topology/TopologyImplTest.java
@@ -64,12 +64,12 @@
             final Dpid dpidA = new Dpid(switchID);
             final Dpid dpidB = new Dpid(switchID % TEST_SWITCH_NUM + 1);
             LinkEvent testLinkEast = new LinkEvent(
-                    testTopology.getPort(dpidA, PORT_NUMBER_2).asSwitchPort(),
-                    testTopology.getPort(dpidB, PORT_NUMBER_1).asSwitchPort()
+                    testTopology.getPort(dpidA, PORT_NUMBER_2).getSwitchPort(),
+                    testTopology.getPort(dpidB, PORT_NUMBER_1).getSwitchPort()
                     );
             LinkEvent testLinkWest = new LinkEvent(
-                    testTopology.getPort(dpidB, PORT_NUMBER_1).asSwitchPort(),
-                    testTopology.getPort(dpidA, PORT_NUMBER_2).asSwitchPort()
+                    testTopology.getPort(dpidB, PORT_NUMBER_1).getSwitchPort(),
+                    testTopology.getPort(dpidA, PORT_NUMBER_2).getSwitchPort()
                     );
             testTopology.putLink(testLinkEast);
             testTopology.putLink(testLinkWest);
@@ -300,7 +300,7 @@
                 testTopology.removeHost(itr.next().getMacAddress());
             }
             for (Port port : testTopology.getSwitch(dpid).getPorts()) {
-                testTopology.removePort(port.asSwitchPort());
+                testTopology.removePort(port.getSwitchPort());
             }
             testTopology.removeSwitch(dpid);