SampleCollector { static StatMonitorHandler getStatMonitorHandler() { synchronized (SampleCollector.class) { if (instance == null) { throw new IllegalStateException("Statistics sampler is not available"); } synchronized (instance.sampleHandlers) { StatMonitorHandler handler = instance.statMonitorHandler; if (handler == null) { handler = new StatMonitorHandler(); instance.addSampleHandler(handler); instance.statMonitorHandler = handler; } return handler; } } } SampleCollector(StatisticsSampler sampler); @SuppressWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "There is never more than one SampleCollector instance.") void initialize(final StatArchiveHandlerConfig config, final long nanosTimeStamp,
      final RollingFileHandler rollingFileHandler); boolean isInitialized(); void addSampleHandler(SampleHandler handler); void removeSampleHandler(SampleHandler handler); boolean containsSampleHandler(SampleHandler handler); void sample(long nanosTimeStamp); void close(); void changeArchive(File newFile, long nanosTimeStamp); @Override String toString();  }
@Test public void testGetStatMonitorHandler() { StatMonitorHandler handler = SampleCollector.getStatMonitorHandler(); assertNotNull(handler); assertTrue(handler.getMonitorsSnapshot().isEmpty()); assertNull(handler.getStatMonitorNotifier()); }