Remove newKeyInstance() and newValueInstance() as more confusing than helpful

This commit is contained in:
leventov
2015-11-25 01:03:07 +03:00
parent 582560ed15
commit 114d2840f1
12 changed files with 86 additions and 260 deletions
@@ -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;