mirror of
https://github.com/apache/commons-collections.git
synced 2025-02-08 19:15:14 +00:00
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;
|
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.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.commons.collections.map;
|
package org.apache.commons.collections.map;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.collections.MapIterator;
|
import org.apache.commons.collections.MapIterator;
|
||||||
import org.apache.commons.collections.OrderedMap;
|
import org.apache.commons.collections.OrderedMap;
|
||||||
import org.apache.commons.collections.OrderedMapIterator;
|
import org.apache.commons.collections.OrderedMapIterator;
|
||||||
@ -61,16 +59,6 @@ public abstract class AbstractOrderedMapDecorator
|
|||||||
super(map);
|
super(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the map being decorated.
|
|
||||||
*
|
|
||||||
* @return the decorated map
|
|
||||||
* @deprecated use decorated()
|
|
||||||
*/
|
|
||||||
protected OrderedMap getOrderedMap() {
|
|
||||||
return decorated();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
|
@ -60,16 +60,6 @@ public abstract class AbstractSortedMapDecorator<K, V>
|
|||||||
super(map);
|
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.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
|
@ -109,7 +109,7 @@ public class ListOrderedMap
|
|||||||
*/
|
*/
|
||||||
protected ListOrderedMap(Map map) {
|
protected ListOrderedMap(Map map) {
|
||||||
super(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) {
|
public Object put(Object key, Object value) {
|
||||||
if (getMap().containsKey(key)) {
|
if (decorated().containsKey(key)) {
|
||||||
// re-adding doesn't change order
|
// re-adding doesn't change order
|
||||||
return getMap().put(key, value);
|
return decorated().put(key, value);
|
||||||
} else {
|
} else {
|
||||||
// first add, so add to both map and list
|
// first add, so add to both map and list
|
||||||
Object result = getMap().put(key, value);
|
Object result = decorated().put(key, value);
|
||||||
insertOrder.add(key);
|
insertOrder.add(key);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -225,13 +225,13 @@ public class ListOrderedMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Object remove(Object key) {
|
public Object remove(Object key) {
|
||||||
Object result = getMap().remove(key);
|
Object result = decorated().remove(key);
|
||||||
insertOrder.remove(key);
|
insertOrder.remove(key);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
getMap().clear();
|
decorated().clear();
|
||||||
insertOrder.clear();
|
insertOrder.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ public class ListOrderedMap
|
|||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public Object put(int index, Object key, Object value) {
|
public Object put(int index, Object key, Object value) {
|
||||||
Map m = getMap();
|
Map m = decorated();
|
||||||
if (m.containsKey(key)) {
|
if (m.containsKey(key)) {
|
||||||
Object result = m.remove(key);
|
Object result = m.remove(key);
|
||||||
int pos = insertOrder.indexOf(key);
|
int pos = insertOrder.indexOf(key);
|
||||||
@ -535,7 +535,7 @@ public class ListOrderedMap
|
|||||||
|
|
||||||
private Set getEntrySet() {
|
private Set getEntrySet() {
|
||||||
if (entrySet == null) {
|
if (entrySet == null) {
|
||||||
entrySet = parent.getMap().entrySet();
|
entrySet = parent.decorated().entrySet();
|
||||||
}
|
}
|
||||||
return entrySet;
|
return entrySet;
|
||||||
}
|
}
|
||||||
@ -608,7 +608,7 @@ public class ListOrderedMap
|
|||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
super.remove();
|
super.remove();
|
||||||
parent.getMap().remove(last);
|
parent.decorated().remove(last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,7 +626,7 @@ public class ListOrderedMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Object setValue(Object value) {
|
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();
|
// Collection coll = (Collection) keyValuePair.getValue();
|
||||||
// coll.clear();
|
// 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
|
* @return true if the map contains the value
|
||||||
*/
|
*/
|
||||||
public boolean containsValue(Object value) {
|
public boolean containsValue(Object value) {
|
||||||
Set pairs = getMap().entrySet();
|
Set pairs = decorated().entrySet();
|
||||||
if (pairs == null) {
|
if (pairs == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||||||
coll.add(value);
|
coll.add(value);
|
||||||
if (coll.size() > 0) {
|
if (coll.size() > 0) {
|
||||||
// only add if non-zero size to maintain class state
|
// only add if non-zero size to maintain class state
|
||||||
getMap().put(key, coll);
|
decorated().put(key, coll);
|
||||||
result = true; // map definitely changed
|
result = true; // map definitely changed
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -279,7 +279,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||||||
* @return the collection mapped to the key, null if no mapping
|
* @return the collection mapped to the key, null if no mapping
|
||||||
*/
|
*/
|
||||||
public Collection getCollection(Object key) {
|
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);
|
coll.addAll(values);
|
||||||
if (coll.size() > 0) {
|
if (coll.size() > 0) {
|
||||||
// only add if non-zero size to maintain class state
|
// only add if non-zero size to maintain class state
|
||||||
getMap().put(key, coll);
|
decorated().put(key, coll);
|
||||||
result = true; // map definitely changed
|
result = true; // map definitely changed
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -345,7 +345,7 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
|
|||||||
*/
|
*/
|
||||||
public int totalSize() {
|
public int totalSize() {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
Collection values = getMap().values();
|
Collection values = decorated().values();
|
||||||
for (Iterator it = values.iterator(); it.hasNext();) {
|
for (Iterator it = values.iterator(); it.hasNext();) {
|
||||||
Collection coll = (Collection) it.next();
|
Collection coll = (Collection) it.next();
|
||||||
total += coll.size();
|
total += coll.size();
|
||||||
|
@ -93,7 +93,7 @@ public class TransformedMap
|
|||||||
if (map.size() > 0) {
|
if (map.size() > 0) {
|
||||||
Map transformed = decorated.transformMap(map);
|
Map transformed = decorated.transformMap(map);
|
||||||
decorated.clear();
|
decorated.clear();
|
||||||
decorated.getMap().putAll(transformed); // avoids double transformation
|
decorated.decorated().putAll(transformed); // avoids double transformation
|
||||||
}
|
}
|
||||||
return decorated;
|
return decorated;
|
||||||
}
|
}
|
||||||
@ -218,12 +218,12 @@ public class TransformedMap
|
|||||||
public Object put(Object key, Object value) {
|
public Object put(Object key, Object value) {
|
||||||
key = transformKey(key);
|
key = transformKey(key);
|
||||||
value = transformValue(value);
|
value = transformValue(value);
|
||||||
return getMap().put(key, value);
|
return decorated().put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putAll(Map mapToCopy) {
|
public void putAll(Map mapToCopy) {
|
||||||
mapToCopy = transformMap(mapToCopy);
|
mapToCopy = transformMap(mapToCopy);
|
||||||
getMap().putAll(mapToCopy);
|
decorated().putAll(mapToCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class TransformedSortedMap
|
|||||||
if (map.size() > 0) {
|
if (map.size() > 0) {
|
||||||
Map transformed = decorated.transformMap(map);
|
Map transformed = decorated.transformMap(map);
|
||||||
decorated.clear();
|
decorated.clear();
|
||||||
decorated.getMap().putAll(transformed); // avoids double transformation
|
decorated.decorated().putAll(transformed); // avoids double transformation
|
||||||
}
|
}
|
||||||
return decorated;
|
return decorated;
|
||||||
}
|
}
|
||||||
|
@ -102,12 +102,12 @@ public final class UnmodifiableOrderedMap
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public MapIterator mapIterator() {
|
public MapIterator mapIterator() {
|
||||||
MapIterator it = getOrderedMap().mapIterator();
|
MapIterator it = decorated().mapIterator();
|
||||||
return UnmodifiableMapIterator.decorate(it);
|
return UnmodifiableMapIterator.decorate(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderedMapIterator orderedMapIterator() {
|
public OrderedMapIterator orderedMapIterator() {
|
||||||
OrderedMapIterator it = getOrderedMap().orderedMapIterator();
|
OrderedMapIterator it = decorated().orderedMapIterator();
|
||||||
return UnmodifiableOrderedMapIterator.decorate(it);
|
return UnmodifiableOrderedMapIterator.decorate(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,29 +131,29 @@ public final class UnmodifiableSortedMap
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public Object firstKey() {
|
public Object firstKey() {
|
||||||
return getSortedMap().firstKey();
|
return decorated().firstKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object lastKey() {
|
public Object lastKey() {
|
||||||
return getSortedMap().lastKey();
|
return decorated().lastKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Comparator comparator() {
|
public Comparator comparator() {
|
||||||
return getSortedMap().comparator();
|
return decorated().comparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedMap subMap(Object fromKey, Object toKey) {
|
public SortedMap subMap(Object fromKey, Object toKey) {
|
||||||
SortedMap map = getSortedMap().subMap(fromKey, toKey);
|
SortedMap map = decorated().subMap(fromKey, toKey);
|
||||||
return new UnmodifiableSortedMap(map);
|
return new UnmodifiableSortedMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedMap headMap(Object toKey) {
|
public SortedMap headMap(Object toKey) {
|
||||||
SortedMap map = getSortedMap().headMap(toKey);
|
SortedMap map = decorated().headMap(toKey);
|
||||||
return new UnmodifiableSortedMap(map);
|
return new UnmodifiableSortedMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedMap tailMap(Object fromKey) {
|
public SortedMap tailMap(Object fromKey) {
|
||||||
SortedMap map = getSortedMap().tailMap(fromKey);
|
SortedMap map = decorated().tailMap(fromKey);
|
||||||
return new UnmodifiableSortedMap(map);
|
return new UnmodifiableSortedMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user