CacheStats extends AbstractCacheStats { @Override public long estimateCurrentWeight() { if (weigher == null) { return -1; } long size = 0; for (Map.Entry<?, ?> e : cache.asMap().entrySet()) { Object k = e.getKey(); Object v = e.getValue(); size += weigher.weigh(k, v); } return size; } @SuppressWarnings("unchecked")  CacheStats(
            @NotNull Cache<?, ?> cache,
            @NotNull String name,
            @Nullable Weigher<?, ?> weigher,
            long maxWeight); @Override long getElementCount(); @Override long estimateCurrentWeight(); @Override long getMaxTotalWeight();  }
@Test public void estimateCurrentWeight() { assertEquals(KEYS + misses, cacheStats.estimateCurrentWeight()); }