Added UI_TYPE annotation key, and augmented BasicDeviceConfig and BasicHostConfig to support defining a custom "uiType" value to override the glyph used in rendering on the Topology View.

Change-Id: I615540419bce6e89e3761ef6ed3b9906be64b266
diff --git a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
index 9fb7e33..5345e34 100644
--- a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
+++ b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
@@ -21,7 +21,6 @@
  * Number of the annotation keys have been deprecated as the use of annotations
  * is being phased out and instead network configuration subsystem is being
  * phased-in for majority of model meta-data.
- * </p>
  */
 public final class AnnotationKeys {
 
@@ -43,6 +42,11 @@
     public static final String TYPE = "type";
 
     /**
+     * Annotation key for UI type (the glyph ID for rendering).
+     */
+    public static final String UI_TYPE = "uiType";
+
+    /**
      * Annotation key for latitude (e.g. latitude of device).
      */
     public static final String LATITUDE = "latitude";
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
index 6401ab4..ebcdd82 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
@@ -18,6 +18,7 @@
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.key.DeviceKeyId;
+
 /**
  * Basic configuration for network infrastructure devices.
  */
@@ -34,9 +35,9 @@
 
     @Override
     public boolean isValid() {
-        return hasOnlyFields(ALLOWED, NAME, LATITUDE, LONGITUDE, RACK_ADDRESS, OWNER,
-                             TYPE, DRIVER, MANUFACTURER, HW_VERSION, SW_VERSION, SERIAL,
-                             MANAGEMENT_ADDRESS, DEVICE_KEY_ID);
+        return hasOnlyFields(ALLOWED, NAME, LATITUDE, LONGITUDE, UI_TYPE,
+                RACK_ADDRESS, OWNER, TYPE, DRIVER, MANUFACTURER, HW_VERSION,
+                SW_VERSION, SERIAL, MANAGEMENT_ADDRESS, DEVICE_KEY_ID);
     }
 
     /**
@@ -185,12 +186,12 @@
     /**
      * Sets the device key id.
      *
-     * @param deviceKeyId new device key id; null to clear
+     * @param deviceKeyId the new device key id; null to clear
      * @return self
      */
     public BasicDeviceConfig deviceKeyId(DeviceKeyId deviceKeyId) {
         return (BasicDeviceConfig) setOrClear(DEVICE_KEY_ID,
-                                              deviceKeyId != null ? deviceKeyId.id() : null);
+                deviceKeyId != null ? deviceKeyId.id() : null);
     }
 
     // TODO: device port meta-data to be configured via BasicPortsConfig
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicElementConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicElementConfig.java
index 74257e6..7c2a5b8 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicElementConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicElementConfig.java
@@ -23,6 +23,7 @@
 public abstract class BasicElementConfig<S> extends AllowedEntityConfig<S> {
 
     protected static final String NAME = "name";
+    protected static final String UI_TYPE = "uiType";
 
     protected static final String LATITUDE = "latitude";
     protected static final String LONGITUDE = "longitude";
@@ -52,15 +53,36 @@
         return (BasicElementConfig) setOrClear(NAME, name);
     }
 
-    private static boolean doubleIsZero(double value) {
+    /**
+     * Returns the UI type (glyph image to be used) for the element in
+     * the Topology View.
+     *
+     * @return the UI type
+     */
+    public String uiType() {
+        return get(UI_TYPE, null);
+    }
+
+    /**
+     * Sets the UI type (glyph image to be used) for the element in
+     * the Topology View.
+     *
+     * @param uiType the UI type; null for default
+     * @return self
+     */
+    public BasicElementConfig uiType(String uiType) {
+        return (BasicElementConfig) setOrClear(UI_TYPE, uiType);
+    }
+
+    private boolean doubleIsZero(double value) {
         return value >= -ZERO_THRESHOLD && value <= ZERO_THRESHOLD;
     }
 
     /**
      * Returns true if the geographical coordinates (latitude and longitude)
-     * are set on this element.
+     * are set on this element; false otherwise.
      *
-     * @return true if geo-coordinates are set
+     * @return true if geo-coordinates are set; false otherwise
      */
     public boolean geoCoordsSet() {
         return !doubleIsZero(latitude()) || !doubleIsZero(longitude());
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicHostConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicHostConfig.java
index fe3a3b7..3758c4e 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicHostConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicHostConfig.java
@@ -23,8 +23,6 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import static org.onosproject.net.config.basics.AllowedEntityConfig.ALLOWED;
-
 /**
  * Basic configuration for network end-station hosts.
  */
@@ -38,12 +36,12 @@
         // Location and IP addresses can be absent, but if present must be valid.
         this.location();
         this.ipAddresses();
-        return hasOnlyFields(ALLOWED, NAME, LATITUDE, LONGITUDE, RACK_ADDRESS, OWNER,
-                             IPS, LOCATION);
+        return hasOnlyFields(ALLOWED, NAME, LATITUDE, LONGITUDE, UI_TYPE,
+                RACK_ADDRESS, OWNER, IPS, LOCATION);
     }
 
     /**
-     * Returns location of the host.
+     * Returns the location of the host.
      *
      * @return location of the host or null if not set
      * @throws IllegalArgumentException if not specified with correct format