mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Remove newKeyInstance() and newValueInstance() as more confusing than helpful
This commit is contained in:
@@ -199,58 +199,6 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>,
|
||||
*/
|
||||
void putAll(File fromFile) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates an empty value instance, which can be used with the
|
||||
* following methods :
|
||||
*
|
||||
* {@link ChronicleMap#getUsing(Object, Object) }
|
||||
* {@link ChronicleMap#acquireUsing(Object, Object) }
|
||||
* {@link ChronicleMap#acquireContext(Object, Object)}
|
||||
*
|
||||
* for example like this :
|
||||
*
|
||||
* <pre>{@code
|
||||
* V value = map.newValueInstance();
|
||||
* try (ReadMapContext rc = map.getUsingLocked(key, value)) {
|
||||
* // add your logic here
|
||||
* } // the read lock is released here
|
||||
* }</pre>
|
||||
*
|
||||
*
|
||||
* @return a new empty instance based on the Value type
|
||||
* @see ChronicleMap#getUsing(Object, Object)
|
||||
* @see ChronicleMap#acquireUsing(Object, Object)
|
||||
* @see ChronicleMap#acquireContext(Object, Object)
|
||||
*/
|
||||
V newValueInstance();
|
||||
|
||||
/**
|
||||
* Creates an empty value instance, which can be used with the
|
||||
* following methods :
|
||||
*
|
||||
* {@link ChronicleMap#getUsing(Object, Object) }
|
||||
* {@link ChronicleMap#acquireUsing(Object, Object)}
|
||||
* {@link ChronicleMap#acquireContext(Object, Object)}
|
||||
*
|
||||
* for example like this :
|
||||
*
|
||||
* <pre>{@code
|
||||
* K key = map.newKeyInstance();
|
||||
* key.setMyStringField("some key");
|
||||
*
|
||||
* try (ReadMapContext rc = map.getUsingLocked(key, value)) {
|
||||
* // add your logic here
|
||||
* } // the read lock is released here
|
||||
* }</pre>
|
||||
*
|
||||
*
|
||||
* @return a new empty instance based on the Key type
|
||||
* @see ChronicleMap#getUsing(Object, Object)
|
||||
* @see ChronicleMap#acquireUsing(Object, Object)
|
||||
* @see ChronicleMap#acquireContext(Object, Object)
|
||||
*/
|
||||
K newKeyInstance();
|
||||
|
||||
/**
|
||||
* @return the class of {@code <V>}
|
||||
*/
|
||||
|
||||
@@ -142,18 +142,6 @@ public class VanillaChronicleMap<K, V, R>
|
||||
return (V) value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V newValueInstance() {
|
||||
if (vClass == CharSequence.class || vClass == StringBuilder.class)
|
||||
return (V) new StringBuilder();
|
||||
return newInstance(vClass, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public K newKeyInstance() {
|
||||
return newInstance(kClass, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<K> keyClass() {
|
||||
return kClass;
|
||||
|
||||
Reference in New Issue
Block a user