You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jonathan Carlson <jo...@yahoo.com> on 2002/06/10 20:53:06 UTC

[Collections] ReadOnly Collection decorators

I'd really like to see some ReadOnly Collection decorators
for all of the Collection and Iterator interfaces and
subinterfaces.  

When I return a collection or iterator from a framework I
don't want to trust that no one will modify those
collections if they represent something internal.  Using
these have protected me from even my own carelessness at
least once.

I have written a few already that I could share (Set, List,
Map, Iterator etc) but they don't subclass the commons
collections Proxy* classes (see my previous note on the
naming of these), which they probably should do if they are
to be included.

Thoughts anyone?

Jonathan

=====
Jonathan Carlson
joncrlsn@users.sf.net
Minneapolis, Minnesota

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Collections] ReadOnly Collection decorators

Posted by Christopher Elkins <ch...@scardini.com>.
On Monday, June 10, 2002, at 12:02 PM, Michael A. Smith wrote:

> the only thing missing would be an unmodifiable bag, sorted bag, 
> and iterator.

FWIW, I submitted a patch for the iterator case quite a while ago, 
but it was
never added to CVS.

<http://nagoya.apache.org/eyebrowse/ReadMsg?listName=commons-
dev@jakarta.apache.org&msgId=75558>

--
Christopher Elkins


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Collections] ReadOnly Collection decorators

Posted by "Michael A. Smith" <ma...@apache.org>.
On Mon, 10 Jun 2002, Jonathan Carlson wrote:
> I'd really like to see some ReadOnly Collection decorators
> for all of the Collection and Iterator interfaces and
> subinterfaces.  
> 
> When I return a collection or iterator from a framework I
> don't want to trust that no one will modify those
> collections if they represent something internal.  Using
> these have protected me from even my own carelessness at
> least once.
> 
> I have written a few already that I could share (Set, List,
> Map, Iterator etc) but they don't subclass the commons
> collections Proxy* classes (see my previous note on the
> naming of these), which they probably should do if they are
> to be included.
> 
> Thoughts anyone?

Most of these already exist in the JDK:

java.util.Collections.unmodifiableCollection(Collection)
java.util.Collections.unmodifiableList(List)
java.util.Collections.unmodifiableMap(Map)
java.util.Collections.unmodifiableSet(Set)
java.util.Collections.unmodifiableSortedMap(SortedMap)
java.util.Collections.unmodifiableSortedSet(SortedSet)

the only thing missing would be an unmodifiable bag, sorted bag, and iterator.

regards,
michael



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>