ONOS-3460 - Link provider that enforces strict configuration

This provider uses the "links" configuration of the network
config and only allows discovery of links that are in
the config.

Refactoring will be done in a subsequent patch set - the DiscoveryContext and
LinkDiscovery classes are duplicates, they need to be refactored so the
LLDP provider and the Network Config provider can share them.

Change-Id: I4de12fc1c4ffa05e3cac7767b8a31f48ba379f6c
diff --git a/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java b/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java
index 4252695..1c74513 100644
--- a/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/link/DefaultLinkDescription.java
@@ -31,6 +31,30 @@
     private final ConnectPoint src;
     private final ConnectPoint dst;
     private final Link.Type type;
+    private final boolean isExpected;
+
+    public static final boolean EXPECTED = true;
+    public static final boolean NOT_EXPECTED = false;
+
+    /**
+     * Creates a link description using the supplied information.
+     *
+     * @param src         link source
+     * @param dst         link destination
+     * @param type        link type
+     * @param isExpected  is the link expected to be part of this configuration
+     * @param annotations optional key/value annotations
+     */
+    public DefaultLinkDescription(ConnectPoint src, ConnectPoint dst,
+                                  Link.Type type,
+                                  boolean isExpected,
+                                  SparseAnnotations... annotations) {
+        super(annotations);
+        this.src = src;
+        this.dst = dst;
+        this.type = type;
+        this.isExpected = isExpected;
+    }
 
     /**
      * Creates a link description using the supplied information.
@@ -41,11 +65,9 @@
      * @param annotations optional key/value annotations
      */
     public DefaultLinkDescription(ConnectPoint src, ConnectPoint dst,
-                                  Link.Type type, SparseAnnotations... annotations) {
-        super(annotations);
-        this.src = src;
-        this.dst = dst;
-        this.type = type;
+                                  Link.Type type,
+                                  SparseAnnotations... annotations) {
+        this(src, dst, type, EXPECTED, annotations);
     }
 
     @Override
@@ -64,18 +86,24 @@
     }
 
     @Override
+    public boolean isExpected() {
+        return isExpected;
+    }
+
+    @Override
     public String toString() {
         return MoreObjects.toStringHelper(this)
                 .add("src", src())
                 .add("dst", dst())
                 .add("type", type())
+                .add("isExpected", isExpected())
                 .add("annotations", annotations())
                 .toString();
     }
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(super.hashCode(), src, dst, type);
+        return Objects.hashCode(super.hashCode(), src, dst, type, isExpected);
     }
 
     @Override
@@ -87,7 +115,8 @@
             DefaultLinkDescription that = (DefaultLinkDescription) object;
             return Objects.equal(this.src, that.src)
                     && Objects.equal(this.dst, that.dst)
-                    && Objects.equal(this.type, that.type);
+                    && Objects.equal(this.type, that.type)
+                    && Objects.equal(this.isExpected, that.isExpected);
         }
         return false;
     }