title: Enum constants implementing generic interfaces in Java
body: <p>Suppose you have a generic interface:</p>
  
  <pre><code>public interface MyInterface&lt;T&gt; {
      T doSomething();
  }
  </code></pre>
  
  <p>Is it possible to declare an enum that implements <code>MyInterface&lt;T&gt;</code>, but for which which every enum constant implements it for a different value of <code>T</code>?  That is, given this enum:</p>
  
  <pre><code>public enum MyEnum {
      FOO,
      BAR,
      BAZ;
  }
  </code></pre>
  
  <p>can we change it so that <code>FOO</code> implements <code>MyInterface&lt;Integer&gt;</code>, <code>BAR</code> implements <code>MyInterface&lt;String&gt;</code>, and <code>BAZ</code> implements <code>MyInterface&lt;List&lt;MyOtherType&gt;&gt;</code>, and make it so that <code>MyEnum</code> overall implements <code>MyInterface&lt;?&gt;</code>?  It seems entirely feasible doing this raw, so it may be the case that it can be done in a typesafe manner.</p>