Allow LinkCollectionIntent to accept other types of resources.

Change-Id: I54331506a8e58efa7235da86e604d174fd5a72ec
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 6febfab..113845d 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
@@ -29,7 +29,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-
+import static com.google.common.base.MoreObjects.firstNonNull;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
@@ -195,6 +195,21 @@
     /**
      * Produces a collection of network resources from the given links.
      *
+     * @param resources base resources
+     * @param links collection of links
+     * @return collection of resources
+     */
+    protected static Collection<NetworkResource> resources(Collection<NetworkResource> resources,
+                                                           Collection<Link> links) {
+        return ImmutableSet.<NetworkResource>builder()
+                .addAll(firstNonNull(resources, ImmutableList.of()))
+                .addAll(links)
+                .build();
+    }
+
+    /**
+     * Produces a collection of network resources from the given links.
+     *
      * @param links collection of links
      * @return collection of link resources
      */
diff --git a/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java b/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
index 11f9f77..2b5d663 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
@@ -16,6 +16,7 @@
 
 package org.onosproject.net.intent;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -25,6 +26,7 @@
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.FilteredConnectPoint;
 import org.onosproject.net.Link;
+import org.onosproject.net.NetworkResource;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 
@@ -71,6 +73,7 @@
                                  Key key,
                                  TrafficSelector selector,
                                  TrafficTreatment treatment,
+                                 Collection<NetworkResource> resources,
                                  Set<Link> links,
                                  Set<FilteredConnectPoint> ingressPoints,
                                  Set<FilteredConnectPoint> egressPoints,
@@ -78,7 +81,7 @@
                                  int priority,
                                  boolean egressTreatment,
                                  double cost) {
-        super(appId, key, resources(links), selector, treatment, constraints, priority);
+        super(appId, key, resources(resources, links), selector, treatment, constraints, priority);
         this.links = links;
         this.ingressPoints = ingressPoints;
         this.egressPoints = egressPoints;
@@ -87,37 +90,6 @@
     }
 
     /**
-     * Creates a new actionable intent capable of funneling the selected
-     * traffic along the specified convergent tree and out the given egress
-     * point satisfying the specified constraints.
-     *
-     * @param appId       application identifier
-     * @param key         key to use for the intent
-     * @param selector    traffic match
-     * @param treatment   action
-     * @param links       traversed links
-     * @param ingressPoints filtered ingress points
-     * @param egressPoints filtered egress points
-     * @param constraints optional list of constraints
-     * @param priority    priority to use for the flows generated by this intent
-     * @param egressTreatment true if treatment should be applied by the egress device
-     * @throws NullPointerException {@code path} is null
-     */
-    private LinkCollectionIntent(ApplicationId appId,
-                                 Key key,
-                                 TrafficSelector selector,
-                                 TrafficTreatment treatment,
-                                 Set<Link> links,
-                                 Set<FilteredConnectPoint> ingressPoints,
-                                 Set<FilteredConnectPoint> egressPoints,
-                                 List<Constraint> constraints,
-                                 int priority,
-                                 boolean egressTreatment) {
-        this(appId, key, selector, treatment, links, ingressPoints, egressPoints, constraints,
-                priority, egressTreatment, DEFAULT_COST);
-    }
-
-    /**
      * Constructor for serializer.
      */
     protected LinkCollectionIntent() {
@@ -186,6 +158,11 @@
             return (Builder) super.priority(priority);
         }
 
+        @Override
+        public Builder resources(Collection<NetworkResource> resources) {
+            return (Builder) super.resources(resources);
+        }
+
         /**
          * Sets the ingress point of the single point to multi point intent
          * that will be built.
@@ -296,6 +273,7 @@
                     key,
                     selector,
                     treatment,
+                    resources,
                     links,
                     ingressPoints,
                     egressPoints,