In-memory object should hold reference to other objects when possible.
Change-Id: I8974eed07b546bd3521c727cb3c79297687a34a7
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/FloodlightToOnosMappers.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/FloodlightToOnosMappers.java
index 0619087..9bd8051 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/FloodlightToOnosMappers.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/FloodlightToOnosMappers.java
@@ -9,29 +9,32 @@
public static Switch map(NetworkGraph graph, IOFSwitch sw) {
SwitchImpl onosSwitch = new SwitchImpl(graph);
onosSwitch.setDpid(sw.getId());
-
+
for (OFPhysicalPort port : sw.getPorts()) {
onosSwitch.addPort(map(graph, port));
}
-
+
return onosSwitch;
}
-
+
public static Port map(NetworkGraph graph, OFPhysicalPort port) {
PortImpl onosPort = new PortImpl(graph);
onosPort.setPortNumber(port.getPortNumber());
return onosPort;
}
-
+
public static Link map(NetworkGraph graph, net.floodlightcontroller.routing.Link link) {
LinkImpl onosLink = new LinkImpl(graph);
-
- onosLink.setSrcSwitch(link.getSrc());
- onosLink.setSrcPort(link.getSrcPort());
- onosLink.setDstSwitch(link.getDst());
- onosLink.setDstPort(link.getDstPort());
-
+
+ Switch srcSw = graph.getSwitch(link.getSrc());
+ onosLink.setSrcSwitch(srcSw);
+ onosLink.setSrcPort(srcSw.getPort(link.getSrcPort()));
+
+ Switch dstSw = graph.getSwitch(link.getDst());
+ onosLink.setDstSwitch(dstSw);
+ onosLink.setDstPort(dstSw.getPort(link.getDstPort()));
+
return onosLink;
-
+
}
}