title: How to make it more generic this for loop with generics?
body: <p>These are classes of my project. 
  The class Bean is a super type of Employe and Computer and not is intanziable.</p>
  
  <pre><code>abstract Class Bean{
     private HashMap&lt;String, String&gt; fields = null;
     protected Bean(Map&lt;String, Object&gt; row) {
          //fill HashMap fields
     }
  }
  public class Employe extends Bean {
      public Employe (Map&lt;String, Object&gt; row) {
          super(row);
     }
  }
  
  public class Computer extends Bean {
      public Computer (Map&lt;String, Object&gt; row) {
          super(row);
      }
  }
  </code></pre>
  
  <p>How to make it more generic this for loop with generics ?</p>
  
  <p>I would write the two cycles below once using generics in a utility method riusable.</p>
  
  <pre><code>//Loop 1
  
  List&lt;Map&lt;String, Object&gt;&gt; employeRows = //from query on database
  
  List&lt;Employe&gt; employList = new ArrayList&lt;Employe&gt;();
  
  for (Map&lt;String, Object&gt; row : employeRows) {
      Employe e = new Employe(row);
      employList .add(e);
  }
  
  //Loop 2
  
  List&lt;Map&lt;String, Object&gt;&gt; computerRows = //from query on database
  
  List&lt;Computer&gt; computerList = new ArrayList&lt;Computer&gt;();
  
  for (Map&lt;String, Object&gt; row : computerRows ) {
      Computer c = new Computer(row);
      computerList.add(c);
  }
  </code></pre>
  
  <p>This pseudo-code is an example of what I want to achieve:</p>
  
  <pre><code>List&lt;Employe&gt; = Utility.toList(employeRows, ...);
  List&lt;Computer&gt; = Utility.toList(computerList, ...);
  </code></pre>