title: Java Generic type flexibility
body: <p>So, lets say I have an enum, "Data".</p>
  
  <pre class="lang-java prettyprint-override"><code>public enum Data {
  
    FIRSTNAME(String.class, "John");
  
    private final Class&lt;?&gt; defaultClass;
    private final Object defaultData;
  
    Data(Class&lt;?&gt; clazz, Object data) {
      this.defaultClass = clazz;
      this.defaultData = data;
    }
  
    public Class&lt;?&gt; getDataClass() {
      return this.defaultClass;
    }
  }
  </code></pre>
  
  <p>Would it be possible to create a method that gets its return type based on the passed Data enum's getDataClass() response? Ie like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>//This code obviously won't work, it's just another way of showing this.
  public [data.getDataClass()] getData(Data data) {
     //Return the data.
  }
  </code></pre>