HCOLL-81 make it clear that mapForKey is read only as it uses a Function and updateForKey is read/write and takes a mutator.

This commit is contained in:
Peter Lawrey
2014-11-15 12:56:37 +00:00
parent 80ba83a669
commit 3750bc4f8e
7 changed files with 120 additions and 35 deletions
@@ -345,8 +345,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
}
enum LockType {READ_LOCK, WRITE_LOCK}
@Override
@@ -375,6 +373,14 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
}
}
@Override
public <R> R updateForKey(K key, @NotNull Mutator<? super V, R> mutator) {
try (Context<K, V> entry = lookupUsing(key, null,
LockType.WRITE_LOCK, false)) {
return mutator.update(entry.value());
}
}
@NotNull
@Override
public WriteContext<K, V> acquireUsingLocked(@NotNull K key, @NotNull V usingValue) {
@@ -1102,7 +1108,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
/**
* Removes a key (or key-value pair) from the Segment.
*
* <p/>
* <p>The entry will only be removed if {@code expectedValue} equals to {@code null} or the value
* previously corresponding to the specified key.
*