Remove getMap(), getOrderedMap() and getSortedMap() - use decorated()
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/branches/collections_jdk5_branch@471189 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f38f7bfd62
commit
0992eec7a2
|
@ -67,16 +67,6 @@ public abstract class AbstractMapDecorator<K, V> implements Map<K, V> {
|
|||
this.map = map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map being decorated.
|
||||
*
|
||||
* @return the decorated map
|
||||
* @deprecated use decorated()
|
||||
*/
|
||||
protected Map<K, V> getMap() {
|
||||
return decorated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map being decorated.
|
||||
*
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.collections.map;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.MapIterator;
|
||||
import org.apache.commons.collections.OrderedMap;
|
||||
import org.apache.commons.collections.OrderedMapIterator;
|
||||
|
@ -61,16 +59,6 @@ public abstract class AbstractOrderedMapDecorator
|
|||
super(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map being decorated.
|
||||
*
|
||||
* @return the decorated map
|
||||
* @deprecated use decorated()
|
||||
*/
|
||||
protected OrderedMap getOrderedMap() {
|
||||
return decorated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map being decorated.
|
||||
*
|
||||
|
|
|
@ -60,16 +60,6 @@ public abstract class AbstractSortedMapDecorator<K, V>
|
|||
super(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map being decorated.
|
||||
*
|
||||
* @return the decorated map
|
||||
* @deprecated use decorated()
|
||||
*/
|
||||
protected SortedMap<K, V> getSortedMap() {
|
||||
return decorated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map being decorated.
|
||||
*
|
||||
|
|
|
@ -109,7 +109,7 @@ public class ListOrderedMap
|
|||
*/
|
||||
protected ListOrderedMap(Map map) {
|
||||
super(map);
|
||||
insertOrder.addAll(getMap().keySet());
|
||||
insertOrder.addAll(decorated().keySet());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -206,12 +206,12 @@ public class ListOrderedMap
|
|||
|
||||
//-----------------------------------------------------------------------
|
||||
public Object put(Object key, Object value) {
|
||||
if (getMap().containsKey(key)) {
|
||||
if (decorated().containsKey(key)) {
|
||||
// re-adding doesn't change order
|
||||
return getMap().put(key, value);
|
||||
return decorated().put(key, value);
|
||||
} else {
|
||||
// first add, so add to both map and list
|
||||
Object result = getMap().put(key, value);
|
||||
Object result = decorated().put(key, value);
|
||||
insertOrder.add(key);
|
||||
return result;
|
||||
}
|
||||
|
@ -225,13 +225,13 @@ public class ListOrderedMap
|
|||
}
|
||||
|
||||
public Object remove(Object key) {
|
||||
Object result = getMap().remove(key);
|
||||
Object result = decorated().remove(key);
|
||||
insertOrder.remove(key);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
getMap().clear();
|
||||
decorated().clear();
|
||||
insertOrder.clear();
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ public class ListOrderedMap
|
|||
* @since Commons Collections 3.2
|
||||
*/
|
||||
public Object put(int index, Object key, Object value) {
|
||||
Map m = getMap();
|
||||
Map m = decorated();
|
||||
if (m.containsKey(key)) {
|
||||
Object result = m.remove(key);
|
||||
int pos = insertOrder.indexOf(key);
|
||||
|
@ -535,7 +535,7 @@ public class ListOrderedMap
|
|||
|
||||
private Set getEntrySet() {
|
||||
if (entrySet == null) {
|
||||
entrySet = parent.getMap().entrySet();
|
||||
entrySet = parent.decorated().entrySet();
|
||||
}
|
||||
return entrySet;
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ public class ListOrderedMap
|
|||
|
||||
public void remove() {
|
||||
super.remove();
|
||||
parent.getMap().remove(last);
|
||||
parent.decorated().remove(last);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -626,7 +626,7 @@ public class ListOrderedMap
|
|||
}
|
||||
|
||||
public Object setValue(Object value) {
|
||||
return parent.getMap().put(key, value);
|
||||
return parent.decorated().put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||
// Collection coll = (Collection) keyValuePair.getValue();
|
||||
// coll.clear();
|
||||
// }
|
||||
getMap().clear();
|
||||
decorated().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,7 +177,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||
* @return true if the map contains the value
|
||||
*/
|
||||
public boolean containsValue(Object value) {
|
||||
Set pairs = getMap().entrySet();
|
||||
Set pairs = decorated().entrySet();
|
||||
if (pairs == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||
coll.add(value);
|
||||
if (coll.size() > 0) {
|
||||
// only add if non-zero size to maintain class state
|
||||
getMap().put(key, coll);
|
||||
decorated().put(key, coll);
|
||||
result = true; // map definitely changed
|
||||
}
|
||||
} else {
|
||||
|
@ -279,7 +279,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||
* @return the collection mapped to the key, null if no mapping
|
||||
*/
|
||||
public Collection getCollection(Object key) {
|
||||
return (Collection) getMap().get(key);
|
||||
return (Collection) decorated().get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -315,7 +315,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||
coll.addAll(values);
|
||||
if (coll.size() > 0) {
|
||||
// only add if non-zero size to maintain class state
|
||||
getMap().put(key, coll);
|
||||
decorated().put(key, coll);
|
||||
result = true; // map definitely changed
|
||||
}
|
||||
} else {
|
||||
|
@ -345,7 +345,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||
*/
|
||||
public int totalSize() {
|
||||
int total = 0;
|
||||
Collection values = getMap().values();
|
||||
Collection values = decorated().values();
|
||||
for (Iterator it = values.iterator(); it.hasNext();) {
|
||||
Collection coll = (Collection) it.next();
|
||||
total += coll.size();
|
||||
|
|
|
@ -93,7 +93,7 @@ public class TransformedMap
|
|||
if (map.size() > 0) {
|
||||
Map transformed = decorated.transformMap(map);
|
||||
decorated.clear();
|
||||
decorated.getMap().putAll(transformed); // avoids double transformation
|
||||
decorated.decorated().putAll(transformed); // avoids double transformation
|
||||
}
|
||||
return decorated;
|
||||
}
|
||||
|
@ -218,12 +218,12 @@ public class TransformedMap
|
|||
public Object put(Object key, Object value) {
|
||||
key = transformKey(key);
|
||||
value = transformValue(value);
|
||||
return getMap().put(key, value);
|
||||
return decorated().put(key, value);
|
||||
}
|
||||
|
||||
public void putAll(Map mapToCopy) {
|
||||
mapToCopy = transformMap(mapToCopy);
|
||||
getMap().putAll(mapToCopy);
|
||||
decorated().putAll(mapToCopy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class TransformedSortedMap
|
|||
if (map.size() > 0) {
|
||||
Map transformed = decorated.transformMap(map);
|
||||
decorated.clear();
|
||||
decorated.getMap().putAll(transformed); // avoids double transformation
|
||||
decorated.decorated().putAll(transformed); // avoids double transformation
|
||||
}
|
||||
return decorated;
|
||||
}
|
||||
|
|
|
@ -102,12 +102,12 @@ public final class UnmodifiableOrderedMap
|
|||
|
||||
//-----------------------------------------------------------------------
|
||||
public MapIterator mapIterator() {
|
||||
MapIterator it = getOrderedMap().mapIterator();
|
||||
MapIterator it = decorated().mapIterator();
|
||||
return UnmodifiableMapIterator.decorate(it);
|
||||
}
|
||||
|
||||
public OrderedMapIterator orderedMapIterator() {
|
||||
OrderedMapIterator it = getOrderedMap().orderedMapIterator();
|
||||
OrderedMapIterator it = decorated().orderedMapIterator();
|
||||
return UnmodifiableOrderedMapIterator.decorate(it);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,29 +131,29 @@ public final class UnmodifiableSortedMap
|
|||
|
||||
//-----------------------------------------------------------------------
|
||||
public Object firstKey() {
|
||||
return getSortedMap().firstKey();
|
||||
return decorated().firstKey();
|
||||
}
|
||||
|
||||
public Object lastKey() {
|
||||
return getSortedMap().lastKey();
|
||||
return decorated().lastKey();
|
||||
}
|
||||
|
||||
public Comparator comparator() {
|
||||
return getSortedMap().comparator();
|
||||
return decorated().comparator();
|
||||
}
|
||||
|
||||
public SortedMap subMap(Object fromKey, Object toKey) {
|
||||
SortedMap map = getSortedMap().subMap(fromKey, toKey);
|
||||
SortedMap map = decorated().subMap(fromKey, toKey);
|
||||
return new UnmodifiableSortedMap(map);
|
||||
}
|
||||
|
||||
public SortedMap headMap(Object toKey) {
|
||||
SortedMap map = getSortedMap().headMap(toKey);
|
||||
SortedMap map = decorated().headMap(toKey);
|
||||
return new UnmodifiableSortedMap(map);
|
||||
}
|
||||
|
||||
public SortedMap tailMap(Object fromKey) {
|
||||
SortedMap map = getSortedMap().tailMap(fromKey);
|
||||
SortedMap map = decorated().tailMap(fromKey);
|
||||
return new UnmodifiableSortedMap(map);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue