title: Pattern for an enum-like class with many different types / constructors
body: <p>I am working with a communication standard (over which I have no control) that defines data items to be sent/received in various packets. </p>
  
  <p><strong>Each item is defined by a custom type, and <em>type-dependent</em> information. These items will rarely change.  I'd like to be able to limit the scope of item constructors to one place, and define all items there once as <code>public static</code> (similar to an enum)</strong>.</p>
  
  <p>Currently, I have an enum for the types, and a class for the items.  </p>
  
  <pre><code>enum Type {TYPE_A, TYPE_B, ...}
  
  public class Item {
      public static Item ITEM_1 = new Item(TYPE_A, someNumber);
      public static Item ITEM_2 = new Item(TYPE_B, someNumber, someMap);
      public static Item ITEM_3 = new Item(TYPE_A, someNumber);
      ...
  
      // Constructor for type A
      private Item(Type type, int param1) {...}
  
      // Constructor for type B
      private Item(Type type, int param1, Map param2) {...}
  
      ...
  
      // Type-dependent methods
      public String decode(byte[] data) {
          switch(this.type) {
          case TYPE_A:
              ...
          }
          case TYPE_B:
              ...
          }
          ...
      }
  }
  </code></pre>
  
  <p><strong>This has become unmanageable, and I am looking for a better pattern / structure.</strong></p>
  
  <p>I could have an abstract Item class, and subclass for each type.  With this setup, I don't know how I could define all the items in one place without making all the constructors public. </p>