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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]