Passing current and previous config value in NetworkConfigEvent

Change-Id: I4ed16f17b5fc991594d1b83b6c0ffca7aa2130fa
diff --git a/core/api/src/main/java/org/onosproject/net/config/Config.java b/core/api/src/main/java/org/onosproject/net/config/Config.java
index 1e2ee12..58219d2 100644
--- a/core/api/src/main/java/org/onosproject/net/config/Config.java
+++ b/core/api/src/main/java/org/onosproject/net/config/Config.java
@@ -32,6 +32,7 @@
 import java.util.function.Function;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
 
 /**
  * Base abstraction of a configuration facade for a specific subject. Derived
@@ -77,17 +78,17 @@
      * @param key      configuration key
      * @param node     JSON node where configuration data is stored
      * @param mapper   JSON object mapper
-     * @param delegate delegate context
+     * @param delegate delegate context, or null for detached configs.
      */
-    public void init(S subject, String key, JsonNode node, ObjectMapper mapper,
+    public final void init(S subject, String key, JsonNode node, ObjectMapper mapper,
                      ConfigApplyDelegate delegate) {
-        this.subject = checkNotNull(subject);
+        this.subject = checkNotNull(subject, "Subject cannot be null");
         this.key = key;
-        this.node = checkNotNull(node);
+        this.node = checkNotNull(node, "Node cannot be null");
         this.object = node instanceof ObjectNode ? (ObjectNode) node : null;
         this.array = node instanceof ArrayNode ? (ArrayNode) node : null;
-        this.mapper = checkNotNull(mapper);
-        this.delegate = checkNotNull(delegate);
+        this.mapper = checkNotNull(mapper, "Mapper cannot be null");
+        this.delegate = delegate;
     }
 
     /**
@@ -144,12 +145,14 @@
 
     /**
      * Applies any configuration changes made via this configuration.
+     *
+     * Not effective for detached configs.
      */
     public void apply() {
+        checkState(delegate != null, "Cannot apply detached config");
         delegate.onApply(this);
     }
 
-
     // Miscellaneous helpers for interacting with JSON
 
     /**