title: How to create a generic typesafe HashMap by class type?
body: <p>I'd like to create a <code>HashMap</code> that maps specific class types to one single specific new object.</p>
  
  <p>Later I want to pass the class type and get the reference to that specific object.
  Simple example:</p>
  
  <pre><code>Map&lt;Class&lt;?&gt;, ?&gt; values = new HashMap&lt;&gt;();
  
  public &lt;T&gt; t get(Class&lt;T&gt; type) {
      return values.get(type);
  }
  
  
  //pet and car do not share any interface or parent class
  class Pet;
  class Car;
  
  //error: not applicable for arguments
  values.put(Pet.class, new Pet());
  values.put(Car.class, new Car());
  </code></pre>
  
  <p>usage:</p>
  
  <pre><code>values.get(Pet.class);
  </code></pre>
  
  <p>How can I create such a generic hashmap and lookup function accordingly?</p>