UploadStagingCache implements Closeable { public static UploadStagingCache build(File dir, File home, int uploadThreads, long size , StagingUploader uploader, @Nullable FileCache cache, StatisticsProvider statisticsProvider, @Nullable ListeningExecutorService executor, @Nullable ScheduledExecutorService scheduledExecutor, int purgeInterval , int retryInterval ) { if (size > 0) { return new UploadStagingCache(dir, home, uploadThreads, size, uploader, cache, statisticsProvider, executor, scheduledExecutor, purgeInterval, retryInterval); } return new UploadStagingCache() { @Override public Optional<SettableFuture<Integer>> put(String id, File input) { return Optional.absent(); } @Override protected void invalidate(String key) { } @Override protected Iterator<String> getAllIdentifiers() { return Collections.emptyIterator(); } @Nullable @Override public File getIfPresent(String key) { return null; } @Override public DataStoreCacheStatsMBean getStats() { return new StagingCacheStats(this, StatisticsProvider.NOOP, 0); } @Override public void close() { } }; } private  UploadStagingCache(File dir, File home, int uploadThreads, long size /* bytes */,
        StagingUploader uploader, @Nullable FileCache cache, StatisticsProvider statisticsProvider,
        @Nullable ListeningExecutorService executor,
        @Nullable ScheduledExecutorService scheduledExecutor,
        int purgeInterval /* secs */, int retryInterval /* secs */); private  UploadStagingCache(); static UploadStagingCache build(File dir, File home, int uploadThreads, long size
        /* bytes */, StagingUploader uploader, @Nullable FileCache cache,
        StatisticsProvider statisticsProvider, @Nullable ListeningExecutorService executor,
        @Nullable ScheduledExecutorService scheduledExecutor, int purgeInterval /* secs */,
        int retryInterval /* secs */); Optional<SettableFuture<Integer>> put(String id, File input); @Nullable File getIfPresent(String key); DataStoreCacheStatsMBean getStats(); @Override void close();  }
@Test public void testBuild() throws Exception { List<ListenableFuture<Integer>> futures = put(folder); closer.close(); init(1); taskLatch.countDown(); callbackLatch.countDown(); afterExecuteLatch.await(); waitFinish(futures); assertNull(stagingCache.getIfPresent(ID_PREFIX + 0)); assertTrue(Files.equal(copyToFile(randomStream(0, 4 * 1024), folder.newFile()), uploader.read(ID_PREFIX + 0))); assertCacheStats(stagingCache, 0, 0, 1, 1); }