commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Colebourne <scolebou...@btopenworld.com>
Subject Re: [collections] Decorator suggestion
Date Thu, 15 Jun 2006 23:13:19 GMT
Eric Jablow wrote:
> Brian Goetz, in an article last year for IBM DeveloperWorks,
> suggested writing a set wrapper that would allow initialization
> code like:
> 
>     private final static Set COMMANDS =
>         new UnmodifiableSetBuilder(new HashSet())
>             .append("Save")
>             .append("Revert")
>             .append("Close")
>             .unmodifiableSet();
> 
> instead of the wordier but normal
> 
>     private final static Set COMMANDS; // Blank final
>     static {
>         Set tempCommands = new HashSet();
>         tempCommands.add("Save");
>         tempCommands.add("Revert");
>         tempCommands.add("Close");
>         COMMANDS = Collections.unmodifiableSet(tempCommands);
>     }

This is an interesting idea. I would have thought that a single 
SetBuilder that could produce a modifiable as well as an unmodifiable 
set would make more sense.

My concern is whether this is too specific for commons-collections, or 
whether it is in fact exactly the kind of feature that we should 
provide. Opinions?

Stephen

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message