Refactoring putAll to _putAll so the constructor can call the copying in code without running through a subclass' implementation of putAll. Reported in COLLECTIONS-317
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@776542 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f7a7f8145d
commit
46f3c54c56
|
@ -161,7 +161,7 @@ public class AbstractHashedMap extends AbstractMap implements IterableMap {
|
|||
*/
|
||||
protected AbstractHashedMap(Map map) {
|
||||
this(Math.max(2 * map.size(), DEFAULT_CAPACITY), DEFAULT_LOAD_FACTOR);
|
||||
putAll(map);
|
||||
_putAll(map);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,6 +295,22 @@ public class AbstractHashedMap extends AbstractMap implements IterableMap {
|
|||
* @throws NullPointerException if the map is null
|
||||
*/
|
||||
public void putAll(Map map) {
|
||||
_putAll(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts all the values from the specified map into this map.
|
||||
* <p>
|
||||
* This implementation iterates around the specified map and
|
||||
* uses {@link #put(Object, Object)}.
|
||||
* <p>
|
||||
* It is private to allow the constructor to still call it
|
||||
* even when putAll is overriden.
|
||||
*
|
||||
* @param map the map to add
|
||||
* @throws NullPointerException if the map is null
|
||||
*/
|
||||
private void _putAll(Map map) {
|
||||
int mapSize = map.size();
|
||||
if (mapSize == 0) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue