Remove constructors/methods using Long

Change-Id: I1da6af2af3272de5be2f930653c5d96b594eff3f
diff --git a/src/main/java/net/onrc/onos/core/topology/LinkEvent.java b/src/main/java/net/onrc/onos/core/topology/LinkEvent.java
index d73f80f..a975e60 100644
--- a/src/main/java/net/onrc/onos/core/topology/LinkEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/LinkEvent.java
@@ -60,17 +60,13 @@
         this.dst = original.dst;
     }
 
-    public LinkEvent(Long srcDpid, Long srcPortNo, Long dstDpid,
-                     Long dstPortNo) {
-        src = new SwitchPort(srcDpid, srcPortNo);
-        dst = new SwitchPort(dstDpid, dstPortNo);
-    }
-
+    // TODO probably want to remove this
     public LinkEvent(Link link) {
         src = new SwitchPort(link.getSrcSwitch().getDpid(),
                 link.getSrcPort().getNumber());
         dst = new SwitchPort(link.getDstSwitch().getDpid(),
                 link.getDstPort().getNumber());
+        // FIXME losing attributes here
     }
 
     /**
diff --git a/src/main/java/net/onrc/onos/core/topology/PortEvent.java b/src/main/java/net/onrc/onos/core/topology/PortEvent.java
index 222a641..e9256af 100644
--- a/src/main/java/net/onrc/onos/core/topology/PortEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/PortEvent.java
@@ -69,11 +69,6 @@
         this.id = original.id;
     }
 
-    // TODO remove me when ready
-    public PortEvent(Long dpid, Long number) {
-        this.id = new SwitchPort(dpid, number);
-    }
-
     /**
      * Gets the SwitchPort identifying this port.
      *
diff --git a/src/main/java/net/onrc/onos/core/topology/SwitchEvent.java b/src/main/java/net/onrc/onos/core/topology/SwitchEvent.java
index b6246d4..b61f7a5 100644
--- a/src/main/java/net/onrc/onos/core/topology/SwitchEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/SwitchEvent.java
@@ -48,11 +48,6 @@
         this.dpid = original.dpid;
     }
 
-    // TODO remove me when ready
-    public SwitchEvent(Long dpid) {
-        this.dpid = new Dpid(dpid);
-    }
-
     /**
      * Gets the DPID identifying this switch.
      *
diff --git a/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java b/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
index 7fbc43d..b00409e 100644
--- a/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
@@ -131,14 +131,6 @@
         return devices;
     }
 
-    // FIXME this should be removed from here and moved to MockTopology
-    Port addPort(Long portNumber) {
-        PortImpl port = new PortImpl(topology, getDpid(),
-                                new PortNumber(portNumber.shortValue()));
-        ((TopologyImpl) topology).putPort(port);
-        return port;
-    }
-
     void replaceStringAttributes(SwitchEvent updated) {
         Validate.isTrue(this.getDpid().equals(updated.getDpid()),
                 "Wrong SwitchEvent given.");
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 b079cae..eb2a799 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
@@ -26,6 +26,7 @@
 import net.onrc.onos.core.registry.IControllerRegistryService;
 import net.onrc.onos.core.util.Dpid;
 import net.onrc.onos.core.util.EventEntry;
+import net.onrc.onos.core.util.PortNumber;
 import net.onrc.onos.core.util.SwitchPort;
 import net.onrc.onos.core.util.serializers.KryoFactory;
 
@@ -1194,7 +1195,7 @@
                 continue;
             }
 
-            SwitchEvent switchEvent = new SwitchEvent(sw.getDpid());
+            SwitchEvent switchEvent = new SwitchEvent(new Dpid(sw.getDpid()));
             TopologyEvent topologyEvent = new TopologyEvent(switchEvent);
             EventEntry<TopologyEvent> eventEntry =
                     new EventEntry<TopologyEvent>(EventEntry.Type.ENTRY_ADD,
@@ -1208,7 +1209,9 @@
                 continue;
             }
 
-            PortEvent portEvent = new PortEvent(p.getDpid(), p.getNumber());
+            PortEvent portEvent = new PortEvent(
+                    new Dpid(p.getDpid()),
+                    new PortNumber(p.getNumber().shortValue()));
             TopologyEvent topologyEvent = new TopologyEvent(portEvent);
             EventEntry<TopologyEvent> eventEntry =
                     new EventEntry<TopologyEvent>(EventEntry.Type.ENTRY_ADD,
@@ -1226,10 +1229,9 @@
          }
 
         for (KVLink l : KVLink.getAllLinks()) {
-            LinkEvent linkEvent = new LinkEvent(l.getSrc().dpid,
-                    l.getSrc().number,
-                    l.getDst().dpid,
-                    l.getDst().number);
+            LinkEvent linkEvent = new LinkEvent(
+                    new SwitchPort(l.getSrc().dpid, l.getSrc().number),
+                    new SwitchPort(l.getDst().dpid, l.getDst().number));
             TopologyEvent topologyEvent = new TopologyEvent(linkEvent);
             EventEntry<TopologyEvent> eventEntry =
                     new EventEntry<TopologyEvent>(EventEntry.Type.ENTRY_ADD,
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
index 60b0823..6cb2bc1 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
@@ -123,7 +123,7 @@
                 log.debug("Got control to set switch {} INACTIVE",
                         HexString.toHexString(dpid));
 
-                SwitchEvent switchEvent = new SwitchEvent(dpid);
+                SwitchEvent switchEvent = new SwitchEvent(new Dpid(dpid));
                 topologyDiscoveryInterface.
                         removeSwitchDiscoveryEvent(switchEvent);
                 registryService.releaseControl(dpid);
@@ -193,13 +193,14 @@
 
     @Override
     public void switchPortRemoved(Long switchId, OFPhysicalPort port) {
+        final Dpid dpid = new Dpid(switchId);
 
-        PortEvent portEvent = new PortEvent(switchId, (long) port.getPortNumber());
+        PortEvent portEvent = new PortEvent(dpid, new PortNumber(port.getPortNumber()));
         if (registryService.hasControl(switchId)) {
             topologyDiscoveryInterface.removePortDiscoveryEvent(portEvent);
         } else {
             log.debug("Not the master for switch {}. Suppressed port del event {}.",
-                    new Dpid(switchId), portEvent);
+                    dpid, portEvent);
         }
     }
 
@@ -218,7 +219,7 @@
         // TODO Not very robust
         if (!registryService.hasControl(sw.getId())) {
             log.debug("Not the master for switch {}. Suppressed switch add event {}.",
-                    new Dpid(sw.getId()), switchEvent);
+                    dpid, switchEvent);
             return;
         }
 
diff --git a/src/test/java/net/onrc/onos/core/intent/IntentOperationListTest.java b/src/test/java/net/onrc/onos/core/intent/IntentOperationListTest.java
index afc903d..30cdfb8 100644
--- a/src/test/java/net/onrc/onos/core/intent/IntentOperationListTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/IntentOperationListTest.java
@@ -2,6 +2,7 @@
 
 import static org.junit.Assert.assertEquals;
 import net.onrc.onos.core.topology.LinkEvent;
+import net.onrc.onos.core.util.SwitchPort;
 import net.onrc.onos.core.util.serializers.KryoFactory;
 
 import org.junit.After;
@@ -33,9 +34,9 @@
                 new ConstrainedShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L, 1000.0);
 
         Path path = new Path();
-        path.add(new LinkEvent(1L, 2L, 3L, 4L));
-        path.add(new LinkEvent(5L, 6L, 7L, 8L));
-        path.add(new LinkEvent(9L, 0L, 1L, 2L));
+        path.add(new LinkEvent(new SwitchPort(1L, 2L), new SwitchPort(3L, 4L)));
+        path.add(new LinkEvent(new SwitchPort(5L, 6L), new SwitchPort(7L, 8L)));
+        path.add(new LinkEvent(new SwitchPort(9L, 0L), new SwitchPort(1L, 2L)));
 
         PathIntent pathIntent1 = new PathIntent("11", path, 123.45, cspIntent1);
         opList.add(IntentOperation.Operator.ADD, pathIntent1);
diff --git a/src/test/java/net/onrc/onos/core/intent/PathIntentTest.java b/src/test/java/net/onrc/onos/core/intent/PathIntentTest.java
index 9e00d1d..3149103 100644
--- a/src/test/java/net/onrc/onos/core/intent/PathIntentTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/PathIntentTest.java
@@ -4,6 +4,7 @@
 import net.onrc.onos.core.topology.LinkEvent;
 import net.onrc.onos.core.util.Dpid;
 import net.onrc.onos.core.util.PortNumber;
+import net.onrc.onos.core.util.SwitchPort;
 import net.onrc.onos.core.util.serializers.KryoFactory;
 
 import org.junit.After;
@@ -57,9 +58,9 @@
                 new ConstrainedShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L, 1000.0);
 
         Path path = new Path();
-        path.add(new LinkEvent(1L, 1L, 2L, 2L));
-        path.add(new LinkEvent(2L, 1L, 3L, 2L));
-        path.add(new LinkEvent(3L, 1L, 4L, 2L));
+        path.add(new LinkEvent(new SwitchPort(1L, 1L), new SwitchPort(2L, 2L)));
+        path.add(new LinkEvent(new SwitchPort(2L, 1L), new SwitchPort(3L, 2L)));
+        path.add(new LinkEvent(new SwitchPort(3L, 1L), new SwitchPort(4L, 2L)));
 
         PathIntent pathIntent1 = new PathIntent("11", path, 123.45, cspIntent1);
 
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
index 568b242..1ae1bb9 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
@@ -24,6 +24,7 @@
 import net.onrc.onos.core.topology.PortEvent;
 import net.onrc.onos.core.topology.SwitchEvent;
 import net.onrc.onos.core.topology.TopologyEvents;
+import net.onrc.onos.core.util.SwitchPort;
 
 import org.hamcrest.Description;
 import org.hamcrest.Factory;
@@ -462,8 +463,8 @@
         final MockTopology topology = mocks.getTopology();
         topology.removeLink(1L, 12L, 2L, 21L); // This link is used by the intent "1"
         topology.removeLink(2L, 21L, 1L, 12L);
-        LinkEvent linkEvent1 = new LinkEvent(1L, 12L, 2L, 21L);
-        LinkEvent linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
+        LinkEvent linkEvent1 = new LinkEvent(new SwitchPort(1L, 12L), new SwitchPort(2L, 21L));
+        LinkEvent linkEvent2 = new LinkEvent(new SwitchPort(2L, 21L), new SwitchPort(1L, 12L));
         removedLinkEvents.add(linkEvent1);
         removedLinkEvents.add(linkEvent2);
 
@@ -696,8 +697,8 @@
         final MockTopology topology = mocks.getTopology();
         topology.removeLink(1L, 12L, 2L, 21L); // This link is used by the intent "1"
         topology.removeLink(2L, 21L, 1L, 12L);
-        final LinkEvent linkEvent1 = new LinkEvent(1L, 12L, 2L, 21L);
-        final LinkEvent linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
+        final LinkEvent linkEvent1 = new LinkEvent(new SwitchPort(1L, 12L), new SwitchPort(2L, 21L));
+        final LinkEvent linkEvent2 = new LinkEvent(new SwitchPort(2L, 21L), new SwitchPort(1L, 12L));
         removedLinkEvents.add(linkEvent1);
         removedLinkEvents.add(linkEvent2);
 
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
index a5b8816..08150ec 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
@@ -38,6 +38,7 @@
 import net.onrc.onos.core.topology.SwitchEvent;
 import net.onrc.onos.core.topology.Topology;
 import net.onrc.onos.core.topology.TopologyEvents;
+import net.onrc.onos.core.util.SwitchPort;
 
 import org.junit.After;
 import org.junit.Before;
@@ -269,8 +270,8 @@
         // link down
         ((MockTopology) topology).removeLink(1L, 12L, 2L, 21L); // This link is used by the intent "1"
         ((MockTopology) topology).removeLink(2L, 21L, 1L, 12L);
-        LinkEvent linkEvent1 = new LinkEvent(1L, 12L, 2L, 21L);
-        LinkEvent linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
+        LinkEvent linkEvent1 = new LinkEvent(new SwitchPort(1L, 12L), new SwitchPort(2L, 21L));
+        LinkEvent linkEvent2 = new LinkEvent(new SwitchPort(2L, 21L), new SwitchPort(1L, 12L));
         removedLinkEvents.clear();
         removedLinkEvents.add(linkEvent1);
         removedLinkEvents.add(linkEvent2);
@@ -302,8 +303,8 @@
 
         // link up
         ((MockTopology) topology).addBidirectionalLinks(1L, 12L, 2L, 21L);
-        linkEvent1 = new LinkEvent(1L, 12L, 2L, 21L);
-        linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
+        linkEvent1 = new LinkEvent(new SwitchPort(1L, 12L), new SwitchPort(2L, 21L));
+        linkEvent2 = new LinkEvent(new SwitchPort(2L, 21L), new SwitchPort(1L, 12L));
         removedLinkEvents.clear();
         addedLinkEvents.clear();
         addedLinkEvents.add(linkEvent1);
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 80f309c..d285504 100644
--- a/src/test/java/net/onrc/onos/core/topology/MockTopology.java
+++ b/src/test/java/net/onrc/onos/core/topology/MockTopology.java
@@ -25,6 +25,13 @@
         return sw;
     }
 
+    public Port addPort(Switch sw, Long portNumber) {
+        PortImpl port = new PortImpl(this, sw.getDpid(),
+                                new PortNumber(portNumber.shortValue()));
+        ((TopologyImpl) this).putPort(port);
+        return port;
+    }
+
     public Link[] addBidirectionalLinks(Long srcDpid, Long srcPortNo, Long dstDpid, Long dstPortNo) {
         Link[] links = new Link[2];
         final Dpid srcDpidObj = new Dpid(srcDpid);
@@ -55,24 +62,24 @@
      */
     public void createSampleTopology1() {
         sw1 = (SwitchImpl) addSwitch(1L);
-        sw1.addPort(LOCAL_PORT);
+        addPort(sw1, LOCAL_PORT);
         sw2 = (SwitchImpl) addSwitch(2L);
-        sw2.addPort(LOCAL_PORT);
+        addPort(sw2, LOCAL_PORT);
         sw3 = (SwitchImpl) addSwitch(3L);
-        sw3.addPort(LOCAL_PORT);
+        addPort(sw3, LOCAL_PORT);
         sw4 = (SwitchImpl) addSwitch(4L);
-        sw4.addPort(LOCAL_PORT);
+        addPort(sw4, LOCAL_PORT);
 
-        sw1.addPort(12L); // sw1 -> sw2
-        sw1.addPort(14L); // sw1 -> sw4
-        sw2.addPort(21L); // sw2 -> sw1
-        sw2.addPort(23L); // sw2 -> sw3
-        sw2.addPort(24L); // sw2 -> sw4
-        sw3.addPort(32L); // sw3 -> sw2
-        sw3.addPort(34L); // sw3 -> sw4
-        sw4.addPort(41L); // sw4 -> sw1
-        sw4.addPort(42L); // sw4 -> sw2
-        sw4.addPort(43L); // sw4 -> sw3
+        addPort(sw1, 12L); // sw1 -> sw2
+        addPort(sw1, 14L); // sw1 -> sw4
+        addPort(sw2, 21L); // sw2 -> sw1
+        addPort(sw2, 23L); // sw2 -> sw3
+        addPort(sw2, 24L); // sw2 -> sw4
+        addPort(sw3, 32L); // sw3 -> sw2
+        addPort(sw3, 34L); // sw3 -> sw4
+        addPort(sw4, 41L); // sw4 -> sw1
+        addPort(sw4, 42L); // sw4 -> sw2
+        addPort(sw4, 43L); // sw4 -> sw3
 
         addBidirectionalLinks(1L, 12L, 2L, 21L);
         addBidirectionalLinks(2L, 23L, 3L, 32L);
@@ -99,26 +106,26 @@
      */
     public void createSampleTopology2() {
         sw1 = (SwitchImpl) addSwitch(1L);
-        sw1.addPort(LOCAL_PORT);
+        addPort(sw1, LOCAL_PORT);
         sw2 = (SwitchImpl) addSwitch(2L);
-        sw2.addPort(LOCAL_PORT);
+        addPort(sw2, LOCAL_PORT);
         sw3 = (SwitchImpl) addSwitch(3L);
-        sw3.addPort(LOCAL_PORT);
+        addPort(sw3, LOCAL_PORT);
         sw4 = (SwitchImpl) addSwitch(4L);
-        sw4.addPort(LOCAL_PORT);
+        addPort(sw4, LOCAL_PORT);
 
-        Port port12 = sw1.addPort(12L); // sw1 -> sw2
-        Port port14 = sw1.addPort(14L); // sw1 -> sw4
-        Port port15 = sw1.addPort(15L); // sw1 -> h1
-        Port port21 = sw2.addPort(21L); // sw2 -> sw1
-        Port port23 = sw2.addPort(23L); // sw2 -> sw3
-        Port port24 = sw2.addPort(24L); // sw2 -> sw4
-        Port port32 = sw3.addPort(32L); // sw3 -> sw2
-        Port port34 = sw3.addPort(34L); // sw3 -> sw4
-        Port port35 = sw3.addPort(35L); // sw3 -> h3
-        Port port41 = sw4.addPort(41L); // sw4 -> sw1
-        Port port42 = sw4.addPort(42L); // sw4 -> sw2
-        Port port43 = sw4.addPort(43L); // sw4 -> sw3
+        Port port12 = addPort(sw1, 12L); // sw1 -> sw2
+        Port port14 = addPort(sw1, 14L); // sw1 -> sw4
+        Port port15 = addPort(sw1, 15L); // sw1 -> h1
+        Port port21 = addPort(sw2, 21L); // sw2 -> sw1
+        Port port23 = addPort(sw2, 23L); // sw2 -> sw3
+        Port port24 = addPort(sw2, 24L); // sw2 -> sw4
+        Port port32 = addPort(sw3, 32L); // sw3 -> sw2
+        Port port34 = addPort(sw3, 34L); // sw3 -> sw4
+        Port port35 = addPort(sw3, 35L); // sw3 -> h3
+        Port port41 = addPort(sw4, 41L); // sw4 -> sw1
+        Port port42 = addPort(sw4, 42L); // sw4 -> sw2
+        Port port43 = addPort(sw4, 43L); // sw4 -> sw3
 
         MACAddress mac1 = MACAddress.valueOf("00:44:33:22:11:00");
         DeviceImpl dev1 = new DeviceImpl(this, mac1);
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 d604011..bffca36 100644
--- a/src/test/java/net/onrc/onos/core/topology/TopologyImplTest.java
+++ b/src/test/java/net/onrc/onos/core/topology/TopologyImplTest.java
@@ -40,14 +40,19 @@
         // Create a number of switches and install two ports for each switch
         for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) {
             SwitchImpl testSwitch = new SwitchImpl(testTopology, switchID);
-            testSwitch.addPort(SWITCH_PORT_1);
-            testSwitch.addPort(SWITCH_PORT_2);
             testTopology.putSwitch(testSwitch);
+            testTopology.putPort(new PortImpl(testTopology,
+                    new Dpid(switchID), PORT_NUMBER_1));
+            testTopology.putPort(new PortImpl(testTopology,
+                    new Dpid(switchID), PORT_NUMBER_2));
+            Port hostPort = new PortImpl(testTopology,
+                    new Dpid(switchID), new PortNumber(SWITCH_HOST_PORT.shortValue()));
+            testTopology.putPort(hostPort);
 
             // Create a host for each switch
             MACAddress devMac = MACAddress.valueOf(switchID);
             DeviceImpl testHost = new DeviceImpl(testTopology, devMac);
-            testHost.addAttachmentPoint(testSwitch.addPort(SWITCH_HOST_PORT));
+            testHost.addAttachmentPoint(hostPort);
             testTopology.putDevice(testHost);
         }