How to build a complex, hierarchic immutable data structure in Java?
<p>I'm building a Java library for a customer, and one of the things they want is a data representation of a particular set of standards they work with.  I don't want to reveal my customer's interests, but if he were an alchemist, he might want the following:</p>

<pre><code>Elements
  Fire
    Name="Fire"
    Physical
      Temperature=451
      Color="Orange"
    Magical
      Domain="Strength"
  Water
    Name="Water"
    Physical
      Color="Blue"
  Earth
    Name="Earth"
    Magical
      Domain="Stability"
      Ordinality=1
</code></pre>

<p>I need to be able to access various data elements by name, such as:</p>

<pre><code>  Elements.Earth.Name
  Elements.Water.Physical.Color
</code></pre>

<p>I also need to be able to iterate through attributes, as:</p>

<pre><code>  for (MagicalType attrib : Elements.Fire.Magical)
  {
    ...
  }
</code></pre>

<p>I have actually been able to create this data structure, and I can do everything I've asked for above -- though I had to create separate arrays for the iteration, so really what I do looks more like:</p>

<pre><code>  for (MagicalType attrib : Elements.Fire.MagicalAuxArray)
</code></pre>

<p>Unfortunately I haven't been able to meet my last requirement: the entire data structure must be immutable.  I have tried repeatedly, and scoured the web looking for examples, but so far I haven't been able to accomplish this in any reasonable manner.  Note that the final data structure will be quite large; I'm really hoping to avoid a solution that is too repetitious or creates too many public symbols.</p>

<p>I am a very experienced programmer, less experienced with Java.  Can anyone suggest how I might represent the above data to meet all my requirements?</p>
