Support [ONOS-4593] and implement [ONOS-4594]

Changes:
- Adds extension to sp2mp intents;
- Adds extension to linkcollection intents;
- Adds extension to sp2mp compiler;
- Adds extension to linkcollection compiler;
- Adds re-ordering of the actions;
- Adds unit tests for both sp2mp intents and linkcollection intents;

Change-Id: Ib925e9066682e077a0bb4bbfd20a4382623b7541
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 6a58b80..85bd5df 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,19 +16,20 @@
 
 package org.onosproject.net.intent;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.Link;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableSet;
 
 /**
  * Abstraction of a connectivity intent that is implemented by a set of path
@@ -41,12 +42,15 @@
 
     private final Set<ConnectPoint> ingressPoints;
     private final Set<ConnectPoint> egressPoints;
+    private final boolean egressTreatmentFlag;
     /**
      * To manage multiple selectors use case.
      */
     private final Map<ConnectPoint, TrafficSelector> ingressSelectors;
-
-    private final boolean egressTreatmentFlag;
+    /**
+     * To manage multiple treatments use case.
+     */
+    private final Map<ConnectPoint, TrafficTreatment> egressTreatments;
 
     /**
      * Creates a new actionable intent capable of funneling the selected
@@ -64,6 +68,7 @@
      * @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
+     * @param egressTreatments map to store the association egress to treatment
      * @throws NullPointerException {@code path} is null
      */
     private LinkCollectionIntent(ApplicationId appId,
@@ -76,13 +81,15 @@
                                  List<Constraint> constraints,
                                  int priority,
                                  boolean egressTreatment,
-                                 Map<ConnectPoint, TrafficSelector> ingressSelectors) {
+                                 Map<ConnectPoint, TrafficSelector> ingressSelectors,
+                                 Map<ConnectPoint, TrafficTreatment> egressTreatments) {
         super(appId, key, resources(links), selector, treatment, constraints, priority);
         this.links = links;
         this.ingressPoints = ingressPoints;
         this.egressPoints = egressPoints;
         this.egressTreatmentFlag = egressTreatment;
         this.ingressSelectors = ingressSelectors;
+        this.egressTreatments = egressTreatments;
     }
 
     /**
@@ -95,6 +102,7 @@
         this.egressPoints = null;
         this.egressTreatmentFlag = false;
         this.ingressSelectors = null;
+        this.egressTreatments = null;
     }
 
     /**
@@ -117,6 +125,7 @@
         Set<ConnectPoint> ingressPoints;
         Set<ConnectPoint> egressPoints;
         Map<ConnectPoint, TrafficSelector> ingressSelectors = ImmutableMap.of();
+        Map<ConnectPoint, TrafficTreatment> egressTreatments = ImmutableMap.of();
         boolean egressTreatmentFlag;
 
         private Builder() {
@@ -189,6 +198,17 @@
         }
 
         /**
+         * Sets the map egress treatments to connection points of the intent.
+         *
+         * @param egressTreatments maps connection point to traffic treatment
+         * @return this builder
+         */
+        public Builder egressTreatments(Map<ConnectPoint, TrafficTreatment> egressTreatments) {
+            this.egressTreatments = ImmutableMap.copyOf(egressTreatments);
+            return this;
+        }
+
+        /**
          * Sets the links of the link collection intent
          * that will be built.
          *
@@ -231,12 +251,12 @@
                     constraints,
                     priority,
                     egressTreatmentFlag,
-                    ingressSelectors
+                    ingressSelectors,
+                    egressTreatments
             );
         }
     }
 
-
     /**
      * Returns the set of links that represent the network connections needed
      * by this intent.
@@ -274,6 +294,14 @@
     }
 
     /**
+     * Returns the multiple treatments jointly with their connection points.
+     * @return multiple treatments
+     */
+    public Map<ConnectPoint, TrafficTreatment> egressTreatments() {
+        return egressTreatments;
+    }
+
+    /**
      * Returns whether treatment should be applied on egress.
      *
      * @return the egress treatment flag
@@ -296,7 +324,8 @@
                 .add("ingress", ingressPoints())
                 .add("egress", egressPoints())
                 .add("selectors", ingressSelectors())
-                .add("treatmentOnEgress", applyTreatmentOnEgress())
+                .add("treatments", egressTreatments())
+                .add("treatementOnEgress", applyTreatmentOnEgress())
                 .toString();
     }
 }