HCOLL-234 as agreeded changed method name to "putWithMapping()"

This commit is contained in:
Rob Austin
2014-12-09 12:07:15 +00:00
parent 91bc848127
commit 2df0426d83
7 changed files with 21 additions and 26 deletions
@@ -204,12 +204,12 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>, ChronicleHash {
* Apply a mutator to the value for a key and return a result. A write lock is assumed. <p> If
* there is no entry for this key it will be created and the value empty.
*
* @param <R> return type.
* @param key to apply the mapping to
* @param mutator to alter the value and calculate a result
* @param <R> return type.
* @return the result of the function.
*/
<R> R updateForKey(K key, @NotNull Mutator<? super V, R> mutator);
<R> R putWithMapping(K key, @NotNull Mutator<? super V, R> mutator);
/**
* exports all the entries to a {@link java.io.File} storing them in JSON format, an attempt is
@@ -490,7 +490,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
@Nullable
@Override
public <R> R updateForKey(@Nullable K key, @NotNull Mutator<? super V, R> mutator) {
public <R> R putWithMapping(@Nullable K key, @NotNull Mutator<? super V, R> mutator) {
if (key == null)
throw keyNotNullNPE();
return fetchObject(UPDATE_FOR_KEY, key, mutator);
@@ -1442,7 +1442,7 @@ class StatelessServerConnector<K, V> {
final K key = keyReaderWithSize.read(reader, null);
final Mutator<V, ?> mutator = (Mutator<V, ?>) reader.readObject();
try {
Object result = map.updateForKey(key, mutator);
Object result = map.putWithMapping(key, mutator);
writer.writeObject(result);
} catch (Throwable e) {
LOG.info("", e);
@@ -559,7 +559,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
}
@Override
public <R> R updateForKey(K key, @NotNull Mutator<? super V, R> mutator) {
public <R> R putWithMapping(K key, @NotNull Mutator<? super V, R> mutator) {
if (!(CharSequence.class.isAssignableFrom(vClass))) {
@@ -573,7 +573,8 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
if (!entry.wasPresent())
return null;
return mutator.update(entry.value());
R result = mutator.update(entry.value());
((MutableLockedEntry) entry).value(result);
}
}