title: Java generics: How to specify exact method signature
body: <p>I have a class with various constructors:</p>
  
  <pre><code>public class SomeClass {
  
      public SomeClass(Object obj) {
          Log.d("x", "SomeClass(Object)");
      }
  
      public SomeClass(Integer num) {
          Log.d("x", "SomeClass(Integer)");
      }
  
      public SomeClass(String str) {
          Log.d("x", "SomeClass(String)");
      }
  
      public &lt;K, V&gt; SomeClass(Map&lt;K, V&gt; map) {
          Log.d("x", "SomeClass(List)");
          for (K key : map.keySet()) {
              new SomeClass(key);
              new SomeClass(map.get(key));
          }
      }
  }
  </code></pre>
  
  <p>...and some code which uses it in following way:</p>
  
  <pre><code>HashMap&lt;String, Integer&gt; map = new HashMap&lt;&gt;();
  map.put("key", 100);
  new SomeClass(map);
  </code></pre>
  
  <p>In the result I have such output:</p>
  
  <pre><code>"SomeClass(List)"
  "SomeClass(Object)"
  "SomeClass(Object)"
  </code></pre>
  
  <p>instead of required</p>
  
  <pre><code>"SomeClass(List)"
  "SomeClass(String)"
  "SomeClass(Integer)"
  </code></pre>
  
  <p>I suppose that because of Java Type Erasure the nested calls of SomeClass constructors falls to the most general one.</p>
  
  <p><strong>The Question:</strong> any ideas how to overcome this Java behavior and force it to call constructor with required parameter type? (Static wrappers and Fabric pattern is not accepted here)</p>