ONOS-2186 - GUI Topo Overlay - (WIP)
- Showing traffic on selected intent now subdues other elements.
- Augmented Highlights to allow for retrieval by ID.
- Reparented HostHighlight and DeviceHighlight to NodeHighlight.
- Added a few extra highlight unit tests.

Change-Id: I0de1cefdcfda58a6fec6e90be5fe898d35aa1b37
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java b/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java
index fe1ecb2..2985d3d 100644
--- a/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java
+++ b/core/api/src/main/java/org/onosproject/ui/topo/DeviceHighlight.java
@@ -20,7 +20,7 @@
 /**
  * Denotes the highlighting to apply to a device.
  */
-public class DeviceHighlight extends AbstractHighlight {
+public class DeviceHighlight extends NodeHighlight {
 
     public DeviceHighlight(String deviceId) {
         super(TopoElementType.DEVICE, deviceId);
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java b/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java
index 0700173..be59c26 100644
--- a/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java
+++ b/core/api/src/main/java/org/onosproject/ui/topo/Highlights.java
@@ -17,9 +17,10 @@
 
 package org.onosproject.ui.topo;
 
+import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -53,9 +54,9 @@
         }
     }
 
-    private final Set<DeviceHighlight> devices = new HashSet<>();
-    private final Set<HostHighlight> hosts = new HashSet<>();
-    private final Set<LinkHighlight> links = new HashSet<>();
+    private final Map<String, DeviceHighlight> devices = new HashMap<>();
+    private final Map<String, HostHighlight> hosts = new HashMap<>();
+    private final Map<String, LinkHighlight> links = new HashMap<>();
 
     private Amount subdueLevel = Amount.ZERO;
 
@@ -67,7 +68,7 @@
      * @return self, for chaining
      */
     public Highlights add(DeviceHighlight dh) {
-        devices.add(dh);
+        devices.put(dh.elementId(), dh);
         return this;
     }
 
@@ -78,7 +79,7 @@
      * @return self, for chaining
      */
     public Highlights add(HostHighlight hh) {
-        hosts.add(hh);
+        hosts.put(hh.elementId(), hh);
         return this;
     }
 
@@ -89,7 +90,7 @@
      * @return self, for chaining
      */
     public Highlights add(LinkHighlight lh) {
-        links.add(lh);
+        links.put(lh.elementId(), lh);
         return this;
     }
 
@@ -106,30 +107,30 @@
     }
 
     /**
-     * Returns the set of device highlights.
+     * Returns the collection of device highlights.
      *
      * @return device highlights
      */
-    public Set<DeviceHighlight> devices() {
-        return Collections.unmodifiableSet(devices);
+    public Collection<DeviceHighlight> devices() {
+        return Collections.unmodifiableCollection(devices.values());
     }
 
     /**
-     * Returns the set of host highlights.
+     * Returns the collection of host highlights.
      *
      * @return host highlights
      */
-    public Set<HostHighlight> hosts() {
-        return Collections.unmodifiableSet(hosts);
+    public Collection<HostHighlight> hosts() {
+        return Collections.unmodifiableCollection(hosts.values());
     }
 
     /**
-     * Returns the set of link highlights.
+     * Returns the collection of link highlights.
      *
      * @return link highlights
      */
-    public Set<LinkHighlight> links() {
-        return Collections.unmodifiableSet(links);
+    public Collection<LinkHighlight> links() {
+        return Collections.unmodifiableCollection(links.values());
     }
 
     /**
@@ -141,4 +142,49 @@
     public Amount subdueLevel() {
         return subdueLevel;
     }
+
+    /**
+     * Returns the node highlight (device or host) for the given element
+     * identifier, or null if no match.
+     *
+     * @param id element identifier
+     * @return corresponding node highlight
+     */
+    public NodeHighlight getNode(String id) {
+        NodeHighlight nh = devices.get(id);
+        return nh != null ? nh : hosts.get(id);
+    }
+
+    /**
+     * Returns the device highlight for the given device identifier,
+     * or null if no match.
+     *
+     * @param id device identifier
+     * @return corresponding device highlight
+     */
+    public DeviceHighlight getDevice(String id) {
+        return devices.get(id);
+    }
+
+    /**
+     * Returns the host highlight for the given host identifier,
+     * or null if no match.
+     *
+     * @param id host identifier
+     * @return corresponding host highlight
+     */
+    public HostHighlight getHost(String id) {
+        return hosts.get(id);
+    }
+
+    /**
+     * Returns the link highlight for the given link identifier,
+     * or null if no match.
+     *
+     * @param id link identifier
+     * @return corresponding link highlight
+     */
+    public LinkHighlight getLink(String id) {
+        return links.get(id);
+    }
 }
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java b/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java
index cb64e07..76669a8 100644
--- a/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java
+++ b/core/api/src/main/java/org/onosproject/ui/topo/HostHighlight.java
@@ -20,7 +20,7 @@
 /**
  * Denotes the highlighting to apply to a host.
  */
-public class HostHighlight extends AbstractHighlight {
+public class HostHighlight extends NodeHighlight {
 
     public HostHighlight(String hostId) {
         super(TopoElementType.HOST, hostId);
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java b/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java
new file mode 100644
index 0000000..735f816
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/ui/topo/NodeHighlight.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.onosproject.ui.topo;
+
+/**
+ * Parent class of {@link DeviceHighlight} and {@link HostHighlight}.
+ */
+public abstract class NodeHighlight extends AbstractHighlight {
+    public NodeHighlight(TopoElementType type, String elementId) {
+        super(type, elementId);
+    }
+}