title: Java Enum - Store Type For Later Cast
body: <p>I have an enum representing all column values in a specific table. Now I want to store a type per enum element which is queried for later casting.</p>
  
  <pre><code>public enum Value {
  
      MEMBER1(?...?),
      MEMBER2(?...?);
  
      private final ?...? type;
  
      Value(?...? type) {
          this.type = type;
      }
  
      public ?...? getType() {
          return type;
      }
  
  }
  </code></pre>
  
  <p>I don't now what I have to put instead of <code>?...?</code>. Maybe its <code>MyClassA.class</code> and <code>Class</code> but how can I use this value for this operation:</p>
  
  <pre><code>MEMBER1.getType() instance = (MEMBER1.getType()) object;
  </code></pre>
  
  <p>This is really important for database communication with java, for me.</p>
  
  <p><strong>UPDATE: I mean this operation.</strong></p>
  
  <p>END UPDATE: There was is logic error. If I knew the different types I can simply create multiple methods because I have a api specification.</p>