Add keys to intents

- use Key class rather than String for intent keys
- add CLI option to specify a string key
- add key field to constructors for connectivity intents
- translate id into a key if no key is specified

Change-Id: I69ffbad93bc3daddf06a67cb0cffa2130e781b37
diff --git a/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java b/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
index 50f639c..305d103 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
@@ -61,7 +61,57 @@
                                  Collection<NetworkResource> resources,
                                  TrafficSelector selector,
                                  TrafficTreatment treatment) {
-        this(appId, resources, selector, treatment, Collections.emptyList());
+        this(appId, null, resources, selector, treatment, Collections.emptyList());
+    }
+
+    /**
+     * Creates a connectivity intent that matches on the specified selector
+     * and applies the specified treatment.
+     * <p>
+     * Path will be chosen without any constraints.
+     * </p>
+     *
+     * @param appId     application identifier
+     * @param key       intent key
+     * @param resources required network resources (optional)
+     * @param selector  traffic selector
+     * @param treatment treatment
+     * @throws NullPointerException if the selector or treatment is null
+     */
+    protected ConnectivityIntent(ApplicationId appId,
+                                 Key key,
+                                 Collection<NetworkResource> resources,
+                                 TrafficSelector selector,
+                                 TrafficTreatment treatment) {
+        this(appId, key, resources, selector, treatment, Collections.emptyList());
+    }
+
+    /**
+     * Creates a connectivity intent that matches on the specified selector
+     * and applies the specified treatment.
+     * <p>
+     * Path will be optimized based on the first constraint if one is given.
+     * </p>
+     *
+     * @param appId       application identifier
+     * @param key         explicit key to use for intent
+     * @param resources   required network resources (optional)
+     * @param selector    traffic selector
+     * @param treatment   treatment
+     * @param constraints optional prioritized list of constraints
+     * @throws NullPointerException if the selector or treatment is null
+     */
+
+    protected ConnectivityIntent(ApplicationId appId,
+                                 Key key,
+                                 Collection<NetworkResource> resources,
+                                 TrafficSelector selector,
+                                 TrafficTreatment treatment,
+                                 List<Constraint> constraints) {
+        super(appId, key, resources);
+        this.selector = checkNotNull(selector);
+        this.treatment = checkNotNull(treatment);
+        this.constraints = checkNotNull(constraints);
     }
 
     /**
@@ -78,12 +128,13 @@
      * @param constraints optional prioritized list of constraints
      * @throws NullPointerException if the selector or treatment is null
      */
+
     protected ConnectivityIntent(ApplicationId appId,
                                  Collection<NetworkResource> resources,
                                  TrafficSelector selector,
                                  TrafficTreatment treatment,
                                  List<Constraint> constraints) {
-        super(appId, resources);
+        super(appId, null, resources);
         this.selector = checkNotNull(selector);
         this.treatment = checkNotNull(treatment);
         this.constraints = checkNotNull(constraints);