Refactored code to consolidate functionality in Database* classes.
Renamed few methods and variables to align with local convention and also to match the description of functionality.
Change-Id: Ib17e73079534c76f76bcb01f14b6496e62275dbd
diff --git a/core/api/src/main/java/org/onosproject/store/service/AsyncConsistentMap.java b/core/api/src/main/java/org/onosproject/store/service/AsyncConsistentMap.java
index 1779256..fee8cfa 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AsyncConsistentMap.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AsyncConsistentMap.java
@@ -18,7 +18,6 @@
import java.util.Collection;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;
@@ -166,17 +165,6 @@
CompletableFuture<Versioned<V>> putAndGet(K key, V value);
/**
- * 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.
- *
- * @param key key with which the specified value is to be associated
- * @param value value to be associated with the specified key
- * @return optional updated value. Will be empty if update did not happen
- */
- CompletableFuture<Optional<Versioned<V>>> putIfAbsentAndGet(K key, V value);
-
- /**
* Removes the mapping for a key from this map if it is present (optional operation).
*
* @param key key whose value is to be removed from the map
@@ -279,17 +267,6 @@
CompletableFuture<Boolean> replace(K key, long oldVersion, V newValue);
/**
- * Replaces the entry for the specified key only if it is currently mapped to the
- * specified version.
- *
- * @param key key key with which the specified value is associated
- * @param oldVersion version expected to be associated with the specified key
- * @param newValue value to be associated with the specified key
- * @return optional updated value. Will be empty if update did not happen.
- */
- CompletableFuture<Optional<Versioned<V>>> replaceAndGet(K key, long oldVersion, V newValue);
-
- /**
* Registers the specified listener to be notified whenever the map is updated.
*
* @param listener listener to notify about map events
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentMap.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentMap.java
index 59f72a9..127a567 100644
--- a/core/api/src/main/java/org/onosproject/store/service/ConsistentMap.java
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentMap.java
@@ -18,7 +18,6 @@
import java.util.Collection;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
@@ -168,17 +167,6 @@
Versioned<V> putAndGet(K key, V value);
/**
- * 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.
- *
- * @param key key with which the specified value is to be associated
- * @param value value to be associated with the specified key
- * @return optional updated value. Will be empty if update did not happen
- */
- Optional<Versioned<V>> putIfAbsentAndGet(K key, V value);
-
- /**
* Removes the mapping for a key from this map if it is present (optional operation).
*
* @param key key whose value is to be removed from the map
@@ -280,17 +268,6 @@
boolean replace(K key, long oldVersion, V newValue);
/**
- * Replaces the entry for the specified key only if it is currently mapped to the
- * specified version.
- *
- * @param key key key with which the specified value is associated
- * @param oldVersion version expected to be associated with the specified key
- * @param newValue value to be associated with the specified key
- * @return optional new value. Will be empty if replace did not happen
- */
- Optional<Versioned<V>> replaceAndGet(K key, long oldVersion, V newValue);
-
- /**
* Registers the specified listener to be notified whenever the map is updated.
*
* @param listener listener to notify about map events
diff --git a/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java b/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java
index fd4373e..8cac596 100644
--- a/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java
+++ b/core/api/src/main/java/org/onosproject/store/service/DatabaseUpdate.java
@@ -68,7 +68,7 @@
}
private Type type;
- private String tableName;
+ private String mapName;
private String key;
private byte[] value;
private byte[] currentValue;
@@ -83,11 +83,11 @@
}
/**
- * Returns the tableName being updated.
- * @return table name.
+ * Returns the name of map being updated.
+ * @return map name.
*/
- public String tableName() {
- return tableName;
+ public String mapName() {
+ return mapName;
}
/**
@@ -126,7 +126,7 @@
public String toString() {
return MoreObjects.toStringHelper(this)
.add("type", type)
- .add("tableName", tableName)
+ .add("mapName", mapName)
.add("key", key)
.add("value", value)
.add("currentValue", currentValue)
@@ -161,8 +161,8 @@
return this;
}
- public Builder withTableName(String tableName) {
- update.tableName = checkNotNull(tableName, "tableName cannot be null");
+ public Builder withMapName(String mapName) {
+ update.mapName = checkNotNull(mapName, "mapName cannot be null");
return this;
}
@@ -189,7 +189,7 @@
private void validateInputs() {
checkNotNull(update.type, "type must be specified");
- checkNotNull(update.tableName, "table name must be specified");
+ checkNotNull(update.mapName, "map name must be specified");
checkNotNull(update.key, "key must be specified");
switch (update.type) {
case PUT: