title: How to cast Generic parameters from another generic class argument?
body: <p>I would like to cast Object T to T2 when a specific type of T2 is passed. T2 is a class from interface T, so there can be multiple implementations of T2. 
  As far as casting, it's happening properly. But I am unable to access the functions of the typecasted function. Am I doing anything wrong?</p>
  
  <pre><code>protected &lt;T, T2&gt; SortedMap&lt;Integer, T2&gt; noNameFunction(List&lt;T&gt; things, T2 ts) {
      SortedMap&lt;Integer, Object&gt; sortedMap = new TreeMap &lt;&gt; (  );
      for (T t: things) {
          T2 as = ( (T2) ts );
          sortedMap.put ( as.getSequence(), as.getFunctionsFromCastedIbjectA() );
      }
      return sortedMap;
  }
  </code></pre>
  
  <p>Am I wrong conceptually somewhere? 
  How do I solve this problem?</p>