title: Spring RestTemplate get generic object
body: <p>I gave this model</p>
  
  <pre><code>public class ResponseMessage&lt;T&gt; {
  
      private T result;
      private ResultCode resultCode;
      private String details;
  
      public ResponseMessage(T result, ResultCode resultCode, String details) {
          this.result = result;
          this.resultCode = resultCode;
          this.details = details;
      }
  //getters and setters
  </code></pre>
  
  <p>and when I get this model from server I conwert it</p>
  
  <pre><code>RestTemplate restTemplate = new RestTemplate();
          String result = restTemplate.getForObject(lkAuthListUrl, String.class);
          Type listType = new TypeToken&lt;ResponseMessage&lt;LkAuth[]&gt;&gt;() {
          }.getType();
          ResponseMessage&lt;LkAuth[]&gt; model = Converter.me().getModel(result, listType);
  </code></pre>
  
  <p>and in Converter I do it</p>
  
  <pre><code>public &lt;T&gt; T getModel(String jsonStr, Type type) {
          T t = null;
          try {
              t = gson.fromJson(jsonStr, type);
          } catch (Exception e) {
              System.out.print(e);
          }
          return t;
      }
  </code></pre>
  
  <p>Can I to avoid convertation in my method and move this duty to <code>RestTemplate</code>?</p>
  
  <p>something lile this</p>
  
  <pre><code>ResponseMessage&lt;LkAuth[]&gt; model = restTemplate.getForObject(lkAuthListUrl, ResponseMessage&lt;LkAuth[]&gt;.class);
  </code></pre>