ONOS-4802 sp2mp intents now apply treatment at the egress switch

Change-Id: Ibdd675f331e522c8b9f1d0e2e9fd5d6b93162fd1
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 f7ca15c..f72354d 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
@@ -39,6 +39,7 @@
 
     private final Set<ConnectPoint> ingressPoints;
     private final Set<ConnectPoint> egressPoints;
+    private final boolean egressTreatmentFlag;
 
     /**
      * Creates a new actionable intent capable of funneling the selected
@@ -54,21 +55,23 @@
      * @param egressPoints 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<ConnectPoint> ingressPoints,
-                                Set<ConnectPoint> egressPoints,
-                                List<Constraint> constraints,
-                                int priority) {
+                                 Key key,
+                                 TrafficSelector selector,
+                                 TrafficTreatment treatment,
+                                 Set<Link> links,
+                                 Set<ConnectPoint> ingressPoints,
+                                 Set<ConnectPoint> egressPoints,
+                                 List<Constraint> constraints,
+                                 int priority, boolean egressTreatment) {
         super(appId, key, resources(links), selector, treatment, constraints, priority);
         this.links = links;
         this.ingressPoints = ingressPoints;
         this.egressPoints = egressPoints;
+        this.egressTreatmentFlag = egressTreatment;
     }
 
     /**
@@ -79,6 +82,7 @@
         this.links = null;
         this.ingressPoints = null;
         this.egressPoints = null;
+        this.egressTreatmentFlag = false;
     }
 
     /**
@@ -100,6 +104,7 @@
         Set<Link> links;
         Set<ConnectPoint> ingressPoints;
         Set<ConnectPoint> egressPoints;
+        boolean egressTreatmentFlag;
 
         private Builder() {
             // Hide constructor
@@ -171,6 +176,17 @@
             return this;
         }
 
+        /**
+         * Sets the intent to apply treatment at the egress rather than the
+         * ingress.
+         *
+         * @param treatmentOnEgress true applies treatment on egress device
+         * @return this builder
+         */
+        public Builder applyTreatmentOnEgress(boolean treatmentOnEgress) {
+            this.egressTreatmentFlag = treatmentOnEgress;
+            return this;
+        }
 
         /**
          * Builds a single point to multi point intent from the
@@ -189,7 +205,8 @@
                     ingressPoints,
                     egressPoints,
                     constraints,
-                    priority
+                    priority,
+                    egressTreatmentFlag
             );
         }
     }
@@ -223,6 +240,15 @@
         return egressPoints;
     }
 
+    /**
+     * Returns whether treatment should be applied on egress.
+     *
+     * @return the egress treatment flag
+     */
+    public boolean applyTreatmentOnEgress() {
+        return egressTreatmentFlag;
+    }
+
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(getClass())
@@ -236,6 +262,7 @@
                 .add("links", links())
                 .add("ingress", ingressPoints())
                 .add("egress", egressPoints())
+                .add("treatementOnEgress", applyTreatmentOnEgress())
                 .toString();
     }
-}
+}
\ No newline at end of file