You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:55:53 UTC
svn commit: r815071 -
/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractMapDecorator.java
Author: bayard
Date: Tue Sep 15 05:55:53 2009
New Revision: 815071
URL: http://svn.apache.org/viewvc?rev=815071&view=rev
Log:
Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956.
Also see the following revisions:
------------------------------------------------------------------------
r740155 | mbenson | 2009-02-02 15:42:27 -0800 (Mon, 02 Feb 2009) | 1 line
remove unnecessarily overridden method
------------------------------------------------------------------------
r740150 | mbenson | 2009-02-02 15:24:00 -0800 (Mon, 02 Feb 2009) | 1 line
make all [collections] maps implement IterableMap
------------------------------------------------------------------------
r471189 | scolebourne | 2006-11-04 05:57:57 -0800 (Sat, 04 Nov 2006) | 1 line
Remove getMap(), getOrderedMap() and getSortedMap() - use decorated()
------------------------------------------------------------------------
r471180 | scolebourne | 2006-11-04 05:27:44 -0800 (Sat, 04 Nov 2006) | 1 line
Abstract*Decorator - Generify and use covariant return types
------------------------------------------------------------------------
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractMapDecorator.java
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractMapDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractMapDecorator.java?rev=815071&r1=815070&r2=815071&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractMapDecorator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractMapDecorator.java Tue Sep 15 05:55:53 2009
@@ -33,16 +33,18 @@
* implementation it would provide a loophole around the validation.
* But, you might want that loophole, so this class is kept simple.
*
+ * @param <K> the type of the keys in the map
+ * @param <V> the type of the values in the map
* @since Commons Collections 3.0
* @version $Revision$ $Date$
*
* @author Daniel Rall
* @author Stephen Colebourne
*/
-public abstract class AbstractMapDecorator implements Map {
+public abstract class AbstractMapDecorator<K, V> extends AbstractIterableMap<K, V> {
/** The map to decorate */
- protected transient Map map;
+ protected transient Map<K, V> map;
/**
* Constructor only used in deserialization, do not use otherwise.
@@ -58,7 +60,7 @@
* @param map the map to decorate, must not be null
* @throws IllegalArgumentException if the collection is null
*/
- public AbstractMapDecorator(Map map) {
+ protected AbstractMapDecorator(Map<K, V> map) {
if (map == null) {
throw new IllegalArgumentException("Map must not be null");
}
@@ -70,72 +72,72 @@
*
* @return the decorated map
*/
- protected Map getMap() {
+ protected Map<K, V> decorated() {
return map;
}
//-----------------------------------------------------------------------
public void clear() {
- map.clear();
+ decorated().clear();
}
public boolean containsKey(Object key) {
- return map.containsKey(key);
+ return decorated().containsKey(key);
}
public boolean containsValue(Object value) {
- return map.containsValue(value);
+ return decorated().containsValue(value);
}
- public Set entrySet() {
- return map.entrySet();
+ public Set<Map.Entry<K, V>> entrySet() {
+ return decorated().entrySet();
}
- public Object get(Object key) {
- return map.get(key);
+ public V get(Object key) {
+ return decorated().get(key);
}
public boolean isEmpty() {
- return map.isEmpty();
+ return decorated().isEmpty();
}
- public Set keySet() {
- return map.keySet();
+ public Set<K> keySet() {
+ return decorated().keySet();
}
- public Object put(Object key, Object value) {
- return map.put(key, value);
+ public V put(K key, V value) {
+ return decorated().put(key, value);
}
- public void putAll(Map mapToCopy) {
- map.putAll(mapToCopy);
+ public void putAll(Map<? extends K, ? extends V> mapToCopy) {
+ decorated().putAll(mapToCopy);
}
- public Object remove(Object key) {
- return map.remove(key);
+ public V remove(Object key) {
+ return decorated().remove(key);
}
public int size() {
- return map.size();
+ return decorated().size();
}
- public Collection values() {
- return map.values();
+ public Collection<V> values() {
+ return decorated().values();
}
public boolean equals(Object object) {
if (object == this) {
return true;
}
- return map.equals(object);
+ return decorated().equals(object);
}
public int hashCode() {
- return map.hashCode();
+ return decorated().hashCode();
}
public String toString() {
- return map.toString();
+ return decorated().toString();
}
}