title: Ready solution for converting raw collections to generic
body: <p>I wonder if there is ready solution, that converts raw collection (List, Set etc.) to generic collection (List, Set etc.). I've wrote my own bicycle for it:</p>
  
  <pre><code>public &lt;T&gt; List&lt;T&gt; filterInstancesOfClass(List list, Class&lt;T&gt; clazz) {
      List&lt;T&gt; generifiedList = new ArrayList&lt;T&gt;();
      for (Object o : list) {
          if (clazz.isInstance(o)) {
              generifiedList.add(clazz.cast(o));
          }
      }
      return generifiedList;
  }
  </code></pre>
  
  <p>But I'm sure, that there should be a ready solution somewhere in popular libraries, that work with collections (Apache, Guava). Do you know one?</p>
  
  <p>UPD. Unfortunately I can't use Java 8 in my case, so I'm looking for a ready solution outside JDK.</p>