Changes related to the "LinkCollectionIntent" type of intents
(e.g., Multipoint-to-singlepoint and Singlepoint-to-multipoint)

* Apply the Intent-defined traffic treatment only on the flowmods
  on the ingress switch with ingress inport for a flowmod.
  Previously, the traffic treatments were applied on each switch,
  and semantically it is not the correct (default) behavior.

* Express the flowmods by explicitly specifying the expected inport
  in the matching conditions for each flowmod.
  Previously, the inport was not included in the matching conditions.

[Merge from branch onos-1.0 - manually]

Change-Id: Ic378b6e8be033a70b016f4ba5550d91fe08ddd9a
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 852e143..55c0cfb 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
@@ -36,16 +36,19 @@
 
     private final Set<Link> links;
 
+    private final Set<ConnectPoint> ingressPoints;
     private final Set<ConnectPoint> egressPoints;
 
     /**
-     * Creates a new actionable intent capable of funneling the selected traffic
-     * along the specified convergent tree and out the given egress point.
+     * Creates a new actionable intent capable of funneling the selected
+     * traffic along the specified convergent tree and out the given egress
+     * point.
      *
      * @param appId       application identifier
      * @param selector    traffic match
      * @param treatment   action
      * @param links       traversed links
+     * @param ingressPoint ingress point
      * @param egressPoint egress point
      * @throws NullPointerException {@code path} is null
      */
@@ -53,19 +56,22 @@
                                 TrafficSelector selector,
                                 TrafficTreatment treatment,
                                 Set<Link> links,
+                                ConnectPoint ingressPoint,
                                 ConnectPoint egressPoint) {
-        this(appId, selector, treatment, links, egressPoint, Collections.emptyList());
+        this(appId, selector, treatment, links, ingressPoint, egressPoint,
+             Collections.emptyList());
     }
 
     /**
      * 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.
+     * traffic along the specified convergent tree and out the given egress
+     * point satisfying the specified constraints.
      *
      * @param appId       application identifier
      * @param selector    traffic match
      * @param treatment   action
      * @param links       traversed links
+     * @param ingressPoint ingress point
      * @param egressPoint egress point
      * @param constraints optional list of constraints
      * @throws NullPointerException {@code path} is null
@@ -74,22 +80,26 @@
                                 TrafficSelector selector,
                                 TrafficTreatment treatment,
                                 Set<Link> links,
+                                ConnectPoint ingressPoint,
                                 ConnectPoint egressPoint,
                                 List<Constraint> constraints) {
         super(appId, resources(links), selector, treatment, constraints);
         this.links = links;
+        this.ingressPoints = ImmutableSet.of(ingressPoint);
         this.egressPoints = ImmutableSet.of(egressPoint);
     }
 
     /**
-     * Creates a new actionable intent capable of funneling the selected traffic
-     * along the specified convergent tree and out the given egress point.
+     * Creates a new actionable intent capable of funneling the selected
+     * traffic along the specified convergent tree and out the given egress
+     * point.
      *
      * @param appId        application identifier
      * @param selector     traffic match
      * @param treatment    action
      * @param links        traversed links
-     * @param egressPoints Set of egress point
+     * @param ingressPoints Set of ingress points
+     * @param egressPoints Set of egress points
      * @param constraints  the constraints
      * @throws NullPointerException {@code path} is null
      */
@@ -97,11 +107,13 @@
                                 TrafficSelector selector,
                                 TrafficTreatment treatment,
                                 Set<Link> links,
+                                Set<ConnectPoint> ingressPoints,
                                 Set<ConnectPoint> egressPoints,
                                 List<Constraint> constraints) {
         super(appId, resources(links), selector, treatment, constraints);
 
         this.links = links;
+        this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
         this.egressPoints = ImmutableSet.copyOf(egressPoints);
     }
 
@@ -111,6 +123,7 @@
     protected LinkCollectionIntent() {
         super();
         this.links = null;
+        this.ingressPoints = null;
         this.egressPoints = null;
     }
 
@@ -125,9 +138,18 @@
     }
 
     /**
-     * Returns the egress point of the intent.
+     * Returns the ingress points of the intent.
      *
-     * @return the egress point
+     * @return the ingress points
+     */
+    public Set<ConnectPoint> ingressPoints() {
+        return ingressPoints;
+    }
+
+    /**
+     * Returns the egress points of the intent.
+     *
+     * @return the egress points
      */
     public Set<ConnectPoint> egressPoints() {
         return egressPoints;
@@ -148,6 +170,7 @@
                 .add("selector", selector())
                 .add("treatment", treatment())
                 .add("links", links())
+                .add("ingress", ingressPoints())
                 .add("egress", egressPoints())
                 .toString();
     }