Made BeanMap.values() and BeanMap.keySet() unmodifiable. This brings it more

in line with the Map contract where any modifications will throw
UnsupportedOperationException rather than allow modifications that are not
reflected in the underlying map.  This also keeps values(), keySet() and
entrySet() consistent with each other.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130673 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Smith 2002-03-24 21:53:27 +00:00
parent 302cc6fd28
commit 63cf00bf0e
1 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BeanMap.java,v 1.8 2002/03/21 17:11:01 morgand Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BeanMap.java,v 1.9 2002/03/24 21:53:27 mas Exp $
* $Revision: 1.8 $ * $Revision: 1.9 $
* $Date: 2002/03/21 17:11:01 $ * $Date: 2002/03/24 21:53:27 $
* *
* ==================================================================== * ====================================================================
* *
@ -342,11 +342,11 @@ public class BeanMap extends AbstractMap implements Cloneable {
/** /**
* Get the keys for this BeanMap. * Get the keys for this BeanMap.
* *
* @return BeanMap keys. Modifications to this Set (i.e. removes) * @return BeanMap keys. The Set returned bu this method is not
* <i>will</i> be reflected in the BeanMap. * modifiable.
*/ */
public Set keySet() { public Set keySet() {
return readMethods.keySet(); return Collections.unmodifiableSet(readMethods.keySet());
} }
/** /**
@ -396,7 +396,7 @@ public class BeanMap extends AbstractMap implements Cloneable {
for ( Iterator iter = valueIterator(); iter.hasNext(); ) { for ( Iterator iter = valueIterator(); iter.hasNext(); ) {
answer.add( iter.next() ); answer.add( iter.next() );
} }
return answer; return Collections.unmodifiableList(answer);
} }