ONOS-4690: containsKey() in TransactionalMap

Change-Id: I13a5eea3871a9a6cc5f808b662584d1892ff19bd
diff --git a/core/api/src/main/java/org/onosproject/store/service/TransactionalMap.java b/core/api/src/main/java/org/onosproject/store/service/TransactionalMap.java
index ff27b8b..79c482d 100644
--- a/core/api/src/main/java/org/onosproject/store/service/TransactionalMap.java
+++ b/core/api/src/main/java/org/onosproject/store/service/TransactionalMap.java
@@ -39,6 +39,13 @@
     V get(K key);
 
     /**
+     * Returns true if this map contains a mapping for the specified key.
+     * @param key key whose presence in this map to be tested
+     * @return true if this map contains a mapping for the specified key
+     */
+    boolean containsKey(K key);
+
+    /**
      * Associates the specified value with the specified key in this map (optional operation).
      * If the map previously contained a mapping for the key, the old value is replaced by the
      * specified value.
@@ -90,4 +97,4 @@
      * @return true if the value was replaced
      */
     boolean replace(K key, V oldValue, V newValue);
-}
\ No newline at end of file
+}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultTransactionalMap.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultTransactionalMap.java
index c96b20a..d138c9b 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultTransactionalMap.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultTransactionalMap.java
@@ -109,6 +109,11 @@
     }
 
     @Override
+    public boolean containsKey(K key) {
+        return get(key) != null;
+    }
+
+    @Override
     public V put(K key, V value) {
         checkState(txContext.isOpen(), TX_CLOSED_ERROR);
         checkNotNull(value, ERROR_NULL_VALUE);