title: Java map with values limited by key's type parameter
body: <p>Is there a way in Java to have a map where the type parameter of a value is tied to the type parameter of a key? What I want to write is something like the following:</p>
  
  <pre><code>public class Foo {
      // This declaration won't compile - what should it be?
      private static Map&lt;Class&lt;T&gt;, T&gt; defaultValues;
  
      // These two methods are just fine
      public static &lt;T&gt; void setDefaultValue(Class&lt;T&gt; clazz, T value) {
          defaultValues.put(clazz, value);
      }
  
      public static &lt;T&gt; T getDefaultValue(Class&lt;T&gt; clazz) {
          return defaultValues.get(clazz);
      }
  }
  </code></pre>
  
  <p>That is, I can store any default value against a Class object, provided the value's type matches that of the Class object. I don't see why this shouldn't be allowed since I can ensure when setting/getting values that the types are correct.</p>
  
  <p>EDIT: Thanks to cletus for his answer. I don't actually need the type parameters on the map itself since I can ensure consistency in the methods which get/set values, even if it means using some slightly ugly casts.</p>