commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael A. Smith" <...@apache.org>
Subject Re: [Collections] ReadOnly Collection decorators
Date Mon, 10 Jun 2002 19:02:48 GMT
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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message