[ONOS-4387] Support for multiple selectors in mp2sp intents

Changes:
- Adds extension to mp2sp intents;
- Adds extension to linkcollection intents;
- Adds extension to mp2sp compiler;
- Adds extension to linkcollection compiler;
- Adds unit tests for both mp2sp and linkcollection intents;

Change-Id: I673c2b660d2364c510b1b3050ed3626ad2f37bda
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 f72354d..5a5345b 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
@@ -13,12 +13,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.onosproject.net.intent;
 
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableMap;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.Link;
@@ -39,6 +43,11 @@
 
     private final Set<ConnectPoint> ingressPoints;
     private final Set<ConnectPoint> egressPoints;
+    /**
+     * To manage multiple selectors use case.
+     */
+    private final Map<ConnectPoint, TrafficSelector> ingressSelectors;
+
     private final boolean egressTreatmentFlag;
 
     /**
@@ -56,6 +65,7 @@
      * @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
+     * @param ingressSelectors map to store the association ingress to selector
      * @throws NullPointerException {@code path} is null
      */
     private LinkCollectionIntent(ApplicationId appId,
@@ -66,12 +76,15 @@
                                  Set<ConnectPoint> ingressPoints,
                                  Set<ConnectPoint> egressPoints,
                                  List<Constraint> constraints,
-                                 int priority, boolean egressTreatment) {
+                                 int priority,
+                                 boolean egressTreatment,
+                                 Map<ConnectPoint, TrafficSelector> ingressSelectors) {
         super(appId, key, resources(links), selector, treatment, constraints, priority);
         this.links = links;
         this.ingressPoints = ingressPoints;
         this.egressPoints = egressPoints;
         this.egressTreatmentFlag = egressTreatment;
+        this.ingressSelectors = ingressSelectors;
     }
 
     /**
@@ -83,6 +96,7 @@
         this.ingressPoints = null;
         this.egressPoints = null;
         this.egressTreatmentFlag = false;
+        this.ingressSelectors = null;
     }
 
     /**
@@ -104,6 +118,7 @@
         Set<Link> links;
         Set<ConnectPoint> ingressPoints;
         Set<ConnectPoint> egressPoints;
+        Map<ConnectPoint, TrafficSelector> ingressSelectors = Collections.emptyMap();
         boolean egressTreatmentFlag;
 
         private Builder() {
@@ -165,6 +180,17 @@
         }
 
         /**
+         * Sets the map ingress selectors to connection points of the intent.
+         *
+         * @param ingressSelectors maps connection point to traffic selector
+         * @return this builder
+         */
+        public Builder ingressSelectors(Map<ConnectPoint, TrafficSelector> ingressSelectors) {
+            this.ingressSelectors = ImmutableMap.copyOf(ingressSelectors);
+            return this;
+        }
+
+        /**
          * Sets the links of the link collection intent
          * that will be built.
          *
@@ -206,7 +232,8 @@
                     egressPoints,
                     constraints,
                     priority,
-                    egressTreatmentFlag
+                    egressTreatmentFlag,
+                    ingressSelectors
             );
         }
     }
@@ -241,6 +268,14 @@
     }
 
     /**
+     * Returns the multiple selectors jointly with their connection points.
+     * @return multiple selectors
+     */
+    public Map<ConnectPoint, TrafficSelector> ingressSelectors() {
+        return ingressSelectors;
+    }
+
+    /**
      * Returns whether treatment should be applied on egress.
      *
      * @return the egress treatment flag
@@ -262,7 +297,8 @@
                 .add("links", links())
                 .add("ingress", ingressPoints())
                 .add("egress", egressPoints())
-                .add("treatementOnEgress", applyTreatmentOnEgress())
+                .add("selectors", ingressSelectors())
+                .add("treatmentOnEgress", applyTreatmentOnEgress())
                 .toString();
     }
-}
\ No newline at end of file
+}