commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Jablow" <erjab...@praxiseng.com>
Subject [collections] Decorator suggestion
Date Mon, 15 May 2006 18:15:56 GMT
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);
    }

He did not use any form of JCC in his code, and it
seems to me that it would be useful to have some
wrapper classes available for such uses.  One could
have an AppendableSetDecorator that adds the append(...)
methods, and the UnmodifiableSetBuilder would
inherit from that.

I would be happy to work on this; I'm trying to get people
in my company using the Commons libraries more often.  Too
many people here write their own CLI code and their
own string utilities.

Respectfully,
Eric Jablow
Praxis Engineering Technologies, Inc.


Mime
View raw message