### Question:
CompositeRegistry implements Registry { @Override public Counter counter(Id id) { return new SwapCounter(this, version::get, id, newCounter(id)); } CompositeRegistry(Clock clock); void add(Registry registry); void remove(Registry registry); void removeAll(); @Override Clock clock(); @Override Id createId(String name); @Override Id createId(String name, Iterable<Tag> tags); @Override void register(Meter meter); @Override ConcurrentMap<Id, Object> state(); @Override Counter counter(Id id); @Override DistributionSummary distributionSummary(Id id); @Override Timer timer(Id id); @Override Gauge gauge(Id id); @Override Gauge maxGauge(Id id); @Override Meter get(Id id); @Override Iterator<Meter> iterator();  }### Answer:
@Test public void testCounter() { Registry r = newRegistry(5, true); Counter c = r.counter(r.createId("foo")); c.increment(); Assertions.assertEquals(c.count(), 1L); Counter c2 = r.counter(r.createId("foo")); Assertions.assertEquals(c.count(), c2.count()); }
@Test public void correctTypeForCountersStream() { Registry r = newRegistry(5, false); r.counter("a").increment(); r.counter("b").increment(); Assertions.assertEquals(2, r.counters().count()); Assertions.assertEquals(2, r.stream().filter(m -> m instanceof Counter).count()); }