Extend EncapsulationConstraint to include a suggested value of the Identifier.
The suggested identifier is used on each link, if available.
In case it is not available on one or more links, the identifier is selected with the active policy.

Patch 2: addressed comments by Pier.

Patch 3: addressed comments by Pier.

Tested with VLAN ids and MPLS labels.

Change-Id: Icdf901ef8d0786b2061d6be4db511cb89d26ddfd
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
index 3dd9ec5..f5be3ed 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
@@ -17,10 +17,13 @@
 package org.onosproject.net.intent.constraint;
 
 
+import org.onlab.util.Identifier;
 import org.onosproject.net.EncapsulationType;
 import org.onosproject.net.Link;
 import org.onosproject.net.intent.ResourceContext;
 
+import java.util.Optional;
+
 import static com.google.common.base.MoreObjects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -30,6 +33,7 @@
 public class EncapsulationConstraint extends BooleanConstraint {
 
     private EncapsulationType encapType;
+    private Optional<Identifier<?>> suggestedIdentifier;
 
     /**
      * Creates a new encapsulation constraint.
@@ -39,8 +43,20 @@
     public EncapsulationConstraint(EncapsulationType encapType) {
         checkNotNull(encapType, "EncapsulationType cannot be null");
         this.encapType = encapType;
+        this.suggestedIdentifier = Optional.empty();
     }
 
+    /**
+     * Creates a new encapsulation constraint with suggested identifier.
+     *
+     * @param encapType the encapsulation type {@link EncapsulationType}
+     * @param identifier the suggested identifier
+     */
+    public EncapsulationConstraint(EncapsulationType encapType, Identifier<?> identifier) {
+        checkNotNull(encapType, "EncapsulationType cannot be null");
+        this.encapType = encapType;
+        this.suggestedIdentifier = Optional.of(identifier);
+    }
 
     // doesn't use LinkResourceService
     @Override
@@ -60,6 +76,18 @@
         return encapType;
     }
 
+    /**
+     * Returns the suggested identifier.
+     *
+     * @return suggestedIdentifier
+     */
+    public Optional<Identifier<?>> suggestedIdentifier() {
+        if (suggestedIdentifier.isPresent()) {
+            return suggestedIdentifier;
+        }
+        return Optional.empty();
+    }
+
     @Override
     public int hashCode() {
         return encapType.hashCode();