Modified UI model objects to be backed merely by IDs of the core model objects.
Change-Id: I4ca81fb1c877ee4ce4209d405fd8c6645c8f5d20
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
index ff22116..377dc16 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
@@ -23,14 +23,17 @@
import org.onosproject.net.region.RegionId;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
/**
* Represents an end-station host.
*/
public class UiHost extends UiNode {
+ private static final String HOST_CANNOT_BE_NULL = "Host cannot be null";
+
private final UiTopology topology;
- private final Host host;
+ private final HostId hostId;
// Host location
private DeviceId locDevice;
@@ -46,14 +49,11 @@
* @param host backing host
*/
public UiHost(UiTopology topology, Host host) {
+ checkNotNull(host, HOST_CANNOT_BE_NULL);
this.topology = topology;
- this.host = host;
+ this.hostId = host.id();
}
-// @Override
-// protected void destroy() {
-// }
-
@Override
public String toString() {
return toStringHelper(this)
@@ -69,7 +69,7 @@
* @return host ID
*/
public HostId id() {
- return host.id();
+ return hostId;
}
/**
@@ -113,7 +113,7 @@
* @return the backing host instance
*/
public Host backingHost() {
- return host;
+ return topology.services.host().getHost(hostId);
}
/**