title: Creating an EnumMap with a generic type Enum
body: <p>If I have a bunch of classes that all contain an Enum and EnumMap and I want to create a superclass for those classes.</p>
  
  <pre><code>public interface ColorEnum {
  }
  
  class ColorMarbles extends Toy {
      enum MARBLE implements ColorEnum
          { BLUE, GREEN }
      EnumMap&lt;MARBLE, String&gt; names = new EnumMap&lt;MARBLE, String&gt;(MARBLE.class);
      //stuff
      // fields
  
      public void populate(ArrayList&lt;String&gt; designer) {
          int i = 0;
          for(MARBLE marble : MARBLE.values()) {
              marble.name = designer.get(i);
              i++;
          }
      }
  }
  
  class ColorBalloons extends Toy {
      enum BALLOON implements ColorEnum
          { YELLOW, RED }
      EnumMap&lt;BALLOON, String&gt; names = new EnumMap&lt;BALLOON, String&gt;(BALLOON.class);
      //stuff
      // fields
  
      public void populate(ArrayList&lt;String&gt; designer) {
          int i = 0;
          for(BALLOON balloon : BALLOON.values()) {
              balloon.name = designer.get(i);
              i++;
          }
      }
  }
  </code></pre>
  
  <p>How do I make create a superclass to have a generic EnumMap that contains an enum of type ColorEnum like this?</p>
  
  <pre><code>public abstract class Toy {
      EnumMap&lt;ColorEnum, String&gt; names;
  }
  </code></pre>
  
  <p>eidt: I realize that I was too vague with my example. Dogs are probably a bad example. I change it to something hopefully more clear.</p>
  
  <p>What I have is a bunch of classes with methods like populate which populates the EnumMap. The names are in a predefined order. Instead of defining populate in every class, I'm hoping to be able to bring it to the Toy superclass so I don't have to keep copy-pasting in each new class type Toy.</p>
  
  <p>Hopefully this will explain more what I'm looking for.</p>