HeapCacheBuilder extends BaseCacheBuilder { @SuppressWarnings("unchecked") public <K, V> HeapCache<K, V> build() { return new HeapCache<>(name, (CacheLoader<K, V>) cacheLoader, (EvictionListener<K, V>) evictionListener, (IndexHandler<K, V>) indexHandler, capacity, expiryUnit, expiry); } HeapCacheBuilder(); HeapCacheBuilder expiryUnit(final TimeUnit expiryUnit); HeapCacheBuilder expiry(final long expiry); HeapCacheBuilder name(final String name); @SuppressWarnings("unchecked") HeapCacheBuilder cacheLoader(final CacheLoader<K, V> cacheLoader); @SuppressWarnings("unchecked") HeapCacheBuilder evictionListener(final EvictionListener<K, V> evictionListener); @SuppressWarnings("unchecked") synchronized HeapCacheBuilder indexHandler(final IndexHandler<K, V> indexHandler); HeapCacheBuilder capacity(final int capacity); synchronized HeapCacheBuilder addIndex(final String attributeName,
      final IndexType indexType); @SuppressWarnings("unchecked") HeapCache<K, V> build(); @SuppressWarnings("unchecked") HeapCache<K, V> build(final String name);  }
@Test public void build() { Cache<Object, Object> cache = CacheBuilder.heapCache() .cacheLoader(BaseCacheBuilder.DEFAULT_CACHE_LOADER) .name("my-heap-cache").expiryUnit(TimeUnit.DAYS).expiry(1) .evictionListener(BaseCacheBuilder.DEFAULT_EVICTION_LISTENER) .indexHandler(DummyIndexHandler.getInstance()) .addIndex("age", IndexType.RANGE_INDEX).capacity(1000).build(); assertTrue(cache instanceof SearchableCache); assertTrue(cache instanceof HeapCache); }