title: How to compare instances of Type for equality
body: <p>Given two instances of <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Type.html" rel="nofollow">Type</a>:</p>
  
  <pre><code>Type type1;
  Type type2;
  </code></pre>
  
  <p>How to can I check if they are <code>equal</code>?</p>
  
  <p>I'm calling <code>toString</code> and comparing their values, as such:</p>
  
  <pre><code>if (type1.toString().equals(type2.toString())) {
      ....
  }
  </code></pre>
  
  <p>I tested it with multiple and nested parameterized types and so far it seems to be consistent. But I would like to know if there is a formal way to do it.</p>