title: Correct Typing for a map of functional interfaces (Java 8)
body: <p>I'm trying to store a mapping of strings to functions in a HashMap and I'm struggling with getting the typing right. How do I store functions of varying types as defined by a generic functional interface?</p>
  
  <p>Here is the relevant code.</p>
  
  <pre><code>@FunctionalInterface
  public interface Converter&lt;F,T&gt; {
      T convert(F from);
  }
  
   HashMap&lt;String, Converter&lt;?, ?&gt;&gt; fooMapping= new HashMap&lt;String, Converter&lt;?, ?&gt;&gt;();
  
   fooMapping.put("name", (someString) -&gt; someString);
   fooMapping.put("flavor", (someInt) -&gt; someAge + 1);
  </code></pre>
  
  <p>The last two lines don't compile with the following (obvious) errors:</p>
  
  <p>-The method length() is undefined for the type Object<br>
  -The operator + is undefined for the argument type(s) Object, int</p>
  
  <p>So my question is how do I specify the TYPES F and T of Converter when I'm storing the lamda in my hashmap so I'm not forced to cast everything from Object?</p>