Sho SHIMIZU
Committed by Gerrit Code Review

ONOS-4690: containsKey() in TransactionalMap

Change-Id: I13a5eea3871a9a6cc5f808b662584d1892ff19bd
......@@ -39,6 +39,13 @@ public interface TransactionalMap<K, V> {
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 @@ public interface TransactionalMap<K, V> {
* @return true if the value was replaced
*/
boolean replace(K key, V oldValue, V newValue);
}
\ No newline at end of file
}
......
......@@ -109,6 +109,11 @@ public class DefaultTransactionalMap<K, V> implements TransactionalMap<K, V>, Tr
}
@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);
......