title: Using RoboSpice/Retrofit with Parametrized types for JSON Response
body: <p>Help please T_T been digging for 2 days for a solution to this problem!</p>
  
  <p>I am using Retrofit to make some networking tasks in my app,
  One of the APIs that I am calling returns a different object sometimes, but i know when and what it will return everytime I call it.</p>
  
  <p>In this case the <code>Message</code> is an object</p>
  
  <pre><code>{
    "key": "some key",
    "category": "some category",
    "channel": "some channel",
    "status": "some status",
    "message": {
      "someValue": "54",
      "someOtherValue": "5353"
    }
  }
  </code></pre>
  
  <p>and here the <code>Message</code> is a string</p>
  
  <pre><code>{
    "key": "some key",
    "category": "some category",
    "channel": "some channel",
    "status": "some status",
    "message": "this is a string"
  }
  </code></pre>
  
  <p>so I am trying to achieve a good design of this solution by using generics, 
  I have a generic class like this,</p>
  
  <p><strong>ContentResponse Class</strong></p>
  
  <pre><code>public class ContentResponse&lt;T&gt; {
  
  private List&lt;Content&lt;T&gt;&gt; content = new ArrayList&lt;Content&lt;T&gt;&gt;();
  
  //getters and setters
  }
  </code></pre>
  
  <p><strong>Content Class</strong></p>
  
  <pre><code>public class Content&lt;T&gt;
  {
      private String key;
      private String category;
      private String channel;
      private String status;
      private T message;
  
      //getters and setters
  }
  </code></pre>
  
  <p><strong>ContentInterface Class</strong></p>
  
  <pre><code>public interface ContentInterface&lt;T&gt;
  {
      @GET("/public/content/{category}")
      ContentResponse&lt;T&gt; getContent(@Path(PathParameters.CATEGORY) String category);
  }
  </code></pre>
  
  <p>The issue lies here</p>
  
  <pre><code>public class ContentRequest&lt;T&gt; extends RetrofitSpiceRequest&lt;ContentResponse&lt;T&gt;, ContentInterface&lt;T&gt;&gt;
          {
          String category;
  
          public ContentRequest(Class&lt;ContentResponse&lt;T&gt;&gt; clazz, Class&lt;ContentInterface&lt;T&gt;&gt; retrofittedInterfaceClass, String category) {
              super(clazz, retrofittedInterfaceClass);
              this.category = category;
          }
  
  
          @Override
          public ContentResponse&lt;T&gt; loadDataFromNetwork() throws Exception {
              return getService().getContent(category);
          }
      }
  </code></pre>
  
  <p>In this context i know that the object returned is a <code>Map&lt;String, String&gt;</code></p>
  
  <pre><code>    contentRequest = new ContentRequest(new Class&lt;ContentResponse&lt;Map&lt;String, String&gt;&gt;&gt;(),
  new Class&lt;ContentInterface&lt;Map&lt;String, String&gt;&gt;&gt;(),
  "appstrings");
  </code></pre>
  
  <p>but i get this !!</p>
  
  <blockquote>
    <p>'class()' is not public in java.lang.Class</p>
  </blockquote>
  
  <p>I cant just call <code>ContentResponse&lt;Map&lt;String,String&gt;&gt;.class</code>, so what can I do here ?</p>