title: cannot select Parameterized Type
body: <p>I want to create a rest to communicate between server and client.</p>
  
  <p>The constructor given below: </p>
  
  <pre><code>public class RestHelper&lt;I, R&gt; {
      public RestHelper(String url, I input, Class&lt;R&gt; output){
          ResponseEntity&lt;R&gt; responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, output );
      }
  }
  </code></pre>
  
  <p>For normal type, I can do:</p>
  
  <pre><code>RestHelper&lt;User, Result&gt; helper = new RestHelper&lt;&gt;(url, user, Result.class);
  </code></pre>
  
  <p>How can I pass a generic type, like:</p>
  
  <pre><code>ResultContainData&lt;Boolean&gt;
  </code></pre>
  
  <p>The code below is not working:</p>
  
  <pre><code>    ResultContainData&lt;Boolean&gt; result = new ResultContainData&lt;&gt;();
      RestHelper&lt;User, ResultContainData&lt;Boolean&gt;&gt; helper = new RestHelper&lt;&gt;(url, user, (Class&lt;ResultContainData&lt;Boolean&gt;&gt;) ((ParameterizedType) result.getClass().getGenericSuperclass()).getActualTypeArguments()[0]);
  </code></pre>
  
  <p>I got a runtime error: cannot cast to ParameterizedType.</p>