Guava: Why CacheBuilder.newBuilder() is not using generic, but using Object?

Created on 13 Mar 2016  路  4Comments  路  Source: google/guava

Such as the following implementation:

  public static CacheBuilder<K, V> newBuilder() {
    return new CacheBuilder<K, V>();
  }

The current implementation:

  public static CacheBuilder<Object, Object> newBuilder() {
    return new CacheBuilder<Object, Object>();
  }
package=cache status=working-as-intended

Most helpful comment

To facilitate reuse (I think):

CacheBuilder<Object, Object> builder = CacheBuilder
        .newBuilder()
        .expireAfterAccess(10, TimeUnit.SECONDS);

Cache<Integer, String> cache1 = builder.build();
Cache<Double, Serializable> cache2 = builder.build();

All 4 comments

To facilitate reuse (I think):

CacheBuilder<Object, Object> builder = CacheBuilder
        .newBuilder()
        .expireAfterAccess(10, TimeUnit.SECONDS);

Cache<Integer, String> cache1 = builder.build();
Cache<Double, Serializable> cache2 = builder.build();

Yes, for reuse. Thanks for @cardamon 馃挴

Duplicate of #738

@lowasser Thanks, I remember to search 'CacheBuilder newBuilder' in 'Pull requests', but not in 'Issues'. So not found, I'm so sorry.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bocete picture Bocete  路  3Comments

gissuebot picture gissuebot  路  5Comments

gissuebot picture gissuebot  路  3Comments

gissuebot picture gissuebot  路  5Comments

cowwoc picture cowwoc  路  3Comments