BasicCounters implements Serializable { @SuppressWarnings("unused") private BasicCounters() { cache = null; counterType = null; } @SuppressWarnings("unused") private  BasicCounters();  BasicCounters(@Nonnull Class<T> counterType); @SuppressWarnings("unchecked") synchronized T findCounter(Enum<?> counterKey); synchronized T getCounter(Enum<?> counterKey); synchronized void setCounter(Enum<?> counterKey, T value); synchronized ImmutableMap<Enum<?>, T> getCopy();  }
@Test public void testBasicCounters() throws InstantiationException, IllegalAccessException { BasicCounters<MutableDouble> doubleBasicCounters = new BasicCounters<MutableDouble>(MutableDouble.class); MutableDouble counterA = doubleBasicCounters.findCounter(CounterKeys.A); counterA.increment(); MutableDouble counterAInCounters = doubleBasicCounters.getCounter(CounterKeys.A); Assert.assertNotNull("null", doubleBasicCounters.getCounter(CounterKeys.A)); Assert.assertTrue("equality", counterAInCounters.equals(counterA)); Assert.assertEquals(counterA.doubleValue(), 1.0, 0); }