title: How to check Type in android
body: <p>One of my function getting <strong><a href="http://developer.android.com/reference/java/lang/reflect/Type.html" rel="nofollow noreferrer">Type</a></strong> variable. sometimes it can be <code>java.util.List&lt;Test$MyClass&gt;</code> or <code>java.util.List&lt;java.lang.String&gt;</code> so how can I identify them?</p>
  
  <pre><code>if (type instanceof List) {
  
  }
  </code></pre>
  
  <p>Both are List type but different type. So that above code does not work.
  I want to distinguish between the two list types.</p>
  
  <p>my main issue is <a href="https://stackoverflow.com/questions/15596112/implement-jsondeserializer-more-than-one-in-gson-in-android">https://stackoverflow.com/questions/15596112/implement-jsondeserializer-more-than-one-in-gson-in-android</a></p>
  
  <p>I am using <code>deserializer</code> for that..</p>
  
  <pre><code>public class Data implements JsonDeserializer&lt;ArrayList&lt;MyClass1&gt;&gt; {
  public ArrayList&lt;MyClass1&gt; myList1 = new ArrayList&lt;MyClass1&gt;();
  public ArrayList&lt;MyClass2&gt; myList2 = new ArrayList&lt;MyClass2&gt;();
  
  @Override
  public ArrayList&lt;MyClass1&gt; deserialize(JsonElement json, Type type,
          JsonDeserializationContext context) throws JsonParseException {
  
      Debug.e("", type.toString());
  
      ArrayList&lt;Layoutmap&gt; data = new ArrayList&lt;Layoutmap&gt;();
  
      try {
          if (json.isJsonObject()) {
  
              // my stuff
  
              return data;
          } else {
              return new Gson().fromJson(json, type);
          }
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      return data;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>above code works for <code>public ArrayList&lt;MyClass2&gt; myList2 = new ArrayList&lt;MyClass2&gt;();</code> and <code>myList2</code> is also i want to deserialize..
  It's part of google <a href="https://code.google.com/p/google-gson/" rel="nofollow noreferrer">Gson</a>.</p>