/** * Removes the mapping for this key from this map if present. * * @param key key whose mapping is to be removed from the map. * @return previous value associated with specified key, or {@code null} if there was no entry for key. */ @Override public V remove(final Object key) { return intern(key, null, true); }
/** * Removes the mapping for this key from this map if present. * * @param key key whose mapping is to be removed from the map. * @return previous value associated with specified key, or {@code null} if there was no entry for key. */ @Override public V remove(final Object key) { return intern(key, null, true); }
/** * Associates the specified value with the specified key in this map. * The value is associated using a {@link WeakReference}. * * @param key key with which the specified value is to be associated. * @param value value to be associated with the specified key. * @return the previous value associated with specified key, or {@code null} if there was no mapping for key. * * @throws NullArgumentException if the key or the value is {@code null}. */ @Override public V put(final K key, final V value) throws NullArgumentException { if (key == null || value == null) { throw new NullArgumentException(Errors.format(key == null ? Errors.Keys.NullMapKey : Errors.Keys.NullMapValue)); } return intern(key, value, true); }
/** * Associates the specified value with the specified key in this map. * The value is associated using a {@link WeakReference}. * * @param key key with which the specified value is to be associated. * @param value value to be associated with the specified key. * @return the previous value associated with specified key, or {@code null} if there was no mapping for key. * * @throws NullArgumentException if the key or the value is {@code null}. */ @Override public V put(final K key, final V value) throws NullArgumentException { if (key == null || value == null) { throw new NullArgumentException(Errors.format(key == null ? Errors.Keys.NullMapKey : Errors.Keys.NullMapValue)); } return intern(key, value, true); }
/** * Associates the specified value with the specified key in this map if no value were previously associated. * If an other value is already associated to the given key, then the map is left unchanged and the current * value is returned. Otherwise the specified value is associated to the key using a {@link WeakReference} * and {@code null} is returned. * * @param key key with which the specified value is to be associated. * @param value value to be associated with the specified key. * @return the current value associated with specified key, or {@code null} if there was no mapping for key. * * @throws NullArgumentException if the key or the value is {@code null}. * * @since 0.7 */ public V putIfAbsent(final K key, final V value) throws NullArgumentException { if (key == null || value == null) { throw new NullArgumentException(Errors.format(key == null ? Errors.Keys.NullMapKey : Errors.Keys.NullMapValue)); } return intern(key, value, false); }
/** * Associates the specified value with the specified key in this map if no value were previously associated. * If an other value is already associated to the given key, then the map is left unchanged and the current * value is returned. Otherwise the specified value is associated to the key using a {@link WeakReference} * and {@code null} is returned. * * @param key key with which the specified value is to be associated. * @param value value to be associated with the specified key. * @return the current value associated with specified key, or {@code null} if there was no mapping for key. * * @throws NullArgumentException if the key or the value is {@code null}. * * @since 0.7 */ @Override public V putIfAbsent(final K key, final V value) throws NullArgumentException { if (key == null || value == null) { throw new NullArgumentException(Errors.format(key == null ? Errors.Keys.NullMapKey : Errors.Keys.NullMapValue)); } return intern(key, value, false); }