Started fleshing out the UI topo model classes.
If reviewing this, please refer to http://tinyurl.com/onos-ui-topo-model

Change-Id: I4738392bec1a89c37dff15eff6fe04d66fcabd95
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiCluster.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiCluster.java
index 87afc56b..f7879ef 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiCluster.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiCluster.java
@@ -16,8 +16,20 @@
 
 package org.onosproject.ui.model.topo;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Encapsulates the notion of the ONOS cluster.
  */
-public class UiCluster extends UiElement {
+class UiCluster extends UiElement {
+
+    private final List<UiClusterMember> members = new ArrayList<>();
+
+    /**
+     * Removes all cluster members.
+     */
+    void clear() {
+        members.clear();
+    }
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
index f267ca5..78f9d47 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
@@ -16,8 +16,17 @@
 
 package org.onosproject.ui.model.topo;
 
+import org.onosproject.net.Device;
+
 /**
  * Represents a device.
  */
 public class UiDevice extends UiNode {
+
+    private Device device;
+
+    @Override
+    protected void destroy() {
+        device = null;
+    }
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiElement.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiElement.java
index 4f2f9cb..5e6144d 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiElement.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiElement.java
@@ -20,4 +20,12 @@
  * Abstract base class of all elements in the UI topology model.
  */
 public class UiElement {
+
+    /**
+     * Removes all external references, and prepares the instance for
+     * garbage collection. This default implementation does nothing.
+     */
+    protected void destroy() {
+        // does nothing
+    }
 }
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 cd80701..933e469 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
@@ -16,8 +16,17 @@
 
 package org.onosproject.ui.model.topo;
 
+import org.onosproject.net.Host;
+
 /**
  * Represents an end-station host.
  */
 public class UiHost extends UiNode {
+
+    private Host host;
+
+    @Override
+    protected void destroy() {
+        host = null;
+    }
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiLink.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiLink.java
index fe1842e..f45a630 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiLink.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiLink.java
@@ -16,8 +16,42 @@
 
 package org.onosproject.ui.model.topo;
 
+import org.onosproject.net.Device;
+import org.onosproject.net.EdgeLink;
+import org.onosproject.net.Link;
+
+import java.util.Set;
+
 /**
  * Represents a bi-directional link backed by two uni-directional links.
  */
 public class UiLink extends UiElement {
+
+    // devices at either end of this link
+    private Device deviceA;
+    private Device deviceB;
+
+    // two unidirectional links underlying this link...
+    private Link linkAtoB;
+    private Link linkBtoA;
+
+    // ==OR== : private (synthetic) host link
+    private EdgeLink edgeLink;
+
+    // ==OR== : set of underlying UI links that this link aggregates
+    private Set<UiLink> children;
+
+
+    @Override
+    protected void destroy() {
+        deviceA = null;
+        deviceB = null;
+        linkAtoB = null;
+        linkBtoA = null;
+        edgeLink = null;
+        if (children != null) {
+            children.clear();
+            children = null;
+        }
+    }
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiNode.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiNode.java
index 53bdfde..e39a7d2 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiNode.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiNode.java
@@ -19,5 +19,5 @@
 /**
  * Represents a node drawn on the topology view (region, device, host).
  */
-public abstract class UiNode extends UiElement {
+abstract class UiNode extends UiElement {
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
index d933703..9a3d6fb 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
@@ -16,8 +16,34 @@
 
 package org.onosproject.ui.model.topo;
 
+import org.onosproject.net.region.Region;
+
+import java.util.Set;
+import java.util.TreeSet;
+
 /**
  * Represents a region.
  */
 public class UiRegion extends UiNode {
+
+    private final Set<UiDevice> uiDevices = new TreeSet<>();
+    private final Set<UiHost> uiHosts = new TreeSet<>();
+    private final Set<UiLink> uiLinks = new TreeSet<>();
+
+    private Region region;
+
+
+    @Override
+    protected void destroy() {
+        uiDevices.forEach(UiDevice::destroy);
+        uiHosts.forEach(UiHost::destroy);
+        uiLinks.forEach(UiLink::destroy);
+
+        uiDevices.clear();
+        uiHosts.clear();
+        uiLinks.clear();
+
+        region = null;
+    }
+
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopology.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopology.java
index 5f4195e..62293e0 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopology.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopology.java
@@ -16,8 +16,29 @@
 
 package org.onosproject.ui.model.topo;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+import java.util.TreeSet;
+
 /**
  * Represents the overall network topology.
  */
 public class UiTopology extends UiElement {
+
+    private static final Logger log = LoggerFactory.getLogger(UiTopology.class);
+
+    private final UiCluster uiCluster = new UiCluster();
+    private final Set<UiRegion> uiRegions = new TreeSet<>();
+
+    /**
+     * Clears the topology state; that is, drops all regions, devices, hosts,
+     * links, and cluster members.
+     */
+    public void clear() {
+        log.debug("clearing topology model");
+        uiRegions.clear();
+        uiCluster.clear();
+    }
 }