title: JCache create cache that holds a list of items per key (Generics)
body: <p>I want to have a cache that holds a list of items. This is my bean definition:</p>
  
  <pre><code>public Cache&lt;Integer, List&lt;Application&gt;&gt; getMyCacheManager(CacheManager manager) {
      Cache&lt;Integer, List&lt;Application&gt;&gt; cache = manager.getCache("myCache");
      if (Objects.isNull(cache)) {
          var config = new MutableConfiguration&lt;Integer, List&lt;Application&gt;&gt;()
                  .setTypes(Integer.class, List.class)
                  .setStoreByValue(false)
                  .setStatisticsEnabled(true)
                  .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, myCacheExpiry)));
          cache = manager.createCache("myCache", config);
      }
      return cache;
  }
  </code></pre>
  
  <p>The problem is the <code>.setTypes</code> line. Here you have to specify the key and value types of the cache. The key is straight forward, but the value is a <code>List&lt;Application&gt;</code> type. You can't just say: <code>List&lt;Application&gt;.class</code>, because that is not allowed. And you also can't use <code>List.class</code>, because the compiler complaints the types are not compatible. </p>
  
  <p>I would really like to keep the specific type (eg <code>List&lt;Application&gt;</code>) because else I have to cast the value every time from <code>Object</code> to the right type.</p>
  
  <p>Any ideas? </p>