title: I need to get a List of generic lazy loaders that will instantiate instances of their inferred type
body: <p>Sorry for the cryptic title, but this is difficult to explain. The general rule is that I need a lazy loader that will give me <em>N</em> instances of a bound wildcard type. I'm calling the lazy loader a storage unit.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  public class StorageUnit&lt;T extends MyInterface&gt; implements Storable&lt;T&gt; {
  
      private int count;
  
      public StorageUnit(int count) {
          this.count = count;
      }
  
      private List&lt;T&gt; storables = new ArrayList&lt;T&gt;();
  
      public List&lt;T&gt; getInstances(Class&lt;T&gt; c) {
          try {
              if (storables.size() == 0) {
                  for (int i = 0; i &lt; count; i++) {
                      storables.add(c.newInstance());
                  }
              } else {
                  return storables;
              }
          }catch (IllegalAccessException illegalAccessException) {
              illegalAccessException.printStackTrace();
          } catch (InstantiationException instantiationException) {
              instantiationException.printStackTrace();
          }
  
          return storables;
      }
  }
  </code></pre>
  
  <p>Elsewhere in my application I have another class that has a reference to several of these storage units. I need to get instances of the storage unit type, and then I will do something with that type.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  public class MyStorageUnitContainer {
  
      private List&lt;StorageUnit&lt;? extends MyInterface&gt;&gt; storageUnits;
  
      public MyStorageUnitContainer(List&lt;StorageUnit&lt;? extends MyInterface&gt;&gt; storageUnits) {
          this.storageUnits = storageUnits;
      }
  
      public List&lt;StorageUnit&lt;? extends MyInterface&gt;&gt; getInstances() {
          List&lt;StorageUnit&lt;? extends MyInterface&gt;&gt; instances = new ArrayList&lt;StorageUnit&lt;? extends MyInterface&gt;&gt;();
          for (StorageUnit&lt;? extends MyInterface&gt; storageUnit : storageUnits) {
  
              storageUnit.getInstances(/* I can't get the bound wildcard... */);
              // Now loop through those instances and do something with them...
  
          }
          return instances;
      }
  }
  </code></pre>
  
  <p>That code sucks, so the best analogy I can think of is an actual storage unit container. That storage unit container has several individual storage units (think boxes). Each one of those boxes contains items of a certain type (think baseball cards). I know that a box contains 100 baseball cards, but until I open the box I don't know anything about the details of each baseball card. I'm basically trying to treat each box as a lazy loader. Opening the box loads <em>N</em> implementations if they don't exist already.</p>