PR: COLLECTIONS-332

Documented the dependency of ListOrderedMap on the standard Map contract of using equals() and hashCode().


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/COLLECTIONS_3_2_BRANCH@1079552 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jochen Wiedmann 2011-03-08 21:27:41 +00:00
parent 470db289c3
commit a5f5ec96d1
3 changed files with 20 additions and 2 deletions

View File

@ -46,6 +46,11 @@ import java.util.Map;
* returns <code>"Four".</code> The <code>Set</code> returned by <code>keySet()</code>
* equals <code>{"one", "two", null}.</code>
* <p>
* <strong>This map will violate the detail of various Map and map view contracts.</note>
* As a general rule, don't compare this map to other maps. In particular, you can't
* use decorators like {@link ListOrderedMap} on it, which silently assume that these
* contracts are fulfilled.
* <p>
* <strong>Note that CaseInsensitiveMap is not synchronized and is not thread-safe.</strong>
* If you wish to use this map from multiple threads concurrently, you must use
* appropriate synchronization. The simplest approach is to wrap this map

View File

@ -26,8 +26,10 @@ import java.util.Map;
* A <code>Map</code> implementation that matches keys and values based
* on <code>==</code> not <code>equals()</code>.
* <p>
* This map will violate the detail of various Map and map view contracts.
* As a general rule, don't compare this map to other maps.
* <strong>This map will violate the detail of various Map and map view contracts.</note>
* As a general rule, don't compare this map to other maps. In particular, you can't
* use decorators like {@link ListOrderedMap} on it, which silently assume that these
* contracts are fulfilled.
* <p>
* <strong>Note that IdentityMap is not synchronized and is not thread-safe.</strong>
* If you wish to use this map from multiple threads concurrently, you must use

View File

@ -59,6 +59,17 @@ import org.apache.commons.collections.list.UnmodifiableList;
* using {@link java.util.Collections#synchronizedMap(Map)}. This class may throw
* exceptions when accessed by concurrent threads without synchronization.
* <p>
* <strong>Note that ListOrderedMap doesn't work with {@link IdentityMap},
* {@link CaseInsensitiveMap}, or similar maps that violate the general
* contract of {@link java.util.Map}.</strong> The <code>ListOrderedMap</code>
* (or, more precisely, the underlying <code>List</code>) is relying on
* {@link Object#java.lang.equals(Object) equals()}. This is fine, as long as the
* decorated <code>Map</code> is also based on {@link Object#equals(Object) equals()},
* and {@link Object#hashCode() hashCode()}, which {@link IdentityMap}, and
* {@link CaseInsensitiveMap} don't: The former uses <code>==</code>, and
* the latter uses {@link Object#equals(Object) equals()} on a lowercased
* key.
* <p>
* This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0