Map from object to a dynamic string
<p>Right now I have about 60 <code>Message</code> types which are passed to a <code>getStuff(Message)</code> method of a class which implements <code>ContainerOfThings</code>. There are multiple variations of an <code>ContainerOfThings</code> such as <code>BoxOfStuff</code> and <code>BagOfTricks</code> both of which realize the <code>getStuff(Message)</code> method which generates a string based on member variables. The result may also have pre-pended or post-pended data such as labels or concatenated data. See code below.</p>

<pre><code>public class BoxOfStuff implements ContainerOfThings
{
    private String var1;
    private String var2;
    private String varN; 

    public String getStuff(Message message)
    {
        if (message.equals(Message.GET_STUFF1))
            return var1;
        else if (message.equals(Message.GET_STUFF2))
            return "Var2 is: " + var2;
        else if (message.equals(Message.GET_STUFFN))
            return varN + "\n";
        // Etc. for each Message.GET_*
    }
    // getters and setters for each var*
}

public class Message
{
    private String id = null;

    private Message(String id)
    {       this.id = id;   }

    public final String toString()
    {       return this.id; }

    public static final Message GET_STUFF1 = new Message("V1");
    public static final Message GET_STUFF2 = new Message("V2");
    public static final Message GET_STUFFN = new Message("VN");

}
</code></pre>

<p>I am trying to find a design that meets the following objectives. (1) The string returned from getStuf() needs to reflect the current state of the implementing class's member fields. (2) Also I would prefer to get away from an incredibly long series of <code>if / else if</code> blocks. One concern is ease of potentially changing to a persistent data-driven configurable object approach which a <code>Map</code> lends well towards. (3) Design should allow for simple maintenance and/or edits. </p>

<p>One design that could work but is a little messy is to create a Map with all key/values initialized in the constructor and also reset any key/value pair inside each setter method. In this way, the response to <code>getStuff(Message)</code> is updated to the new content after changes (ie: in a <code>setVar*()</code> method). Any other thoughts?</p>
