@Test public void testCache() throws Exception { final GuavaHashCache c = new GuavaHashCache(); final HashParameters p1 = new TestParams(); final Hash h1 = new TestHash(); assertEquals(h1, c.get(p1, EnumSet.of(INT_SIZED), new HashLoader(h1))); assertEquals(h1, c.get(p1, EnumSet.of(INT_SIZED), new HashLoader(new TestHash()))); final Hash h1n = new TestHash(); assertEquals(h1n, c.get(p1, EnumSet.of(INT_SIZED, NATIVE), new HashLoader(h1n))); assertEquals(h1n, c.get(p1, EnumSet.of(NATIVE), new HashLoader(new TestHash()))); final HashParameters p2 = new TestParams(); final Hash h2 = new TestHash(); assertEquals(h2, c.get(p2, EnumSet.of(INT_SIZED), new HashLoader(h2))); assertEquals(h2, c.get(p2, EnumSet.of(INT_SIZED), new HashLoader(new TestHash()))); }
@Override public Hash get(HashParameters params, EnumSet<HashSupport> required, Callable<Hash> loader) throws ExecutionException { final Hash hash = cache.getIfPresent(new SearchKey(params, required)); return hash != null ? hash : cache.get(new Key(params, required), loader); }
GuavaHashCache implements HashCache { @Override public Hash get(HashParameters params, EnumSet<HashSupport> required, Callable<Hash> loader) throws ExecutionException { final Hash hash = cache.getIfPresent(new SearchKey(params, required)); return hash != null ? hash : cache.get(new Key(params, required), loader); } }
GuavaHashCache implements HashCache { @Override public Hash get(HashParameters params, EnumSet<HashSupport> required, Callable<Hash> loader) throws ExecutionException { final Hash hash = cache.getIfPresent(new SearchKey(params, required)); return hash != null ? hash : cache.get(new Key(params, required), loader); } GuavaHashCache(); }
GuavaHashCache implements HashCache { @Override public Hash get(HashParameters params, EnumSet<HashSupport> required, Callable<Hash> loader) throws ExecutionException { final Hash hash = cache.getIfPresent(new SearchKey(params, required)); return hash != null ? hash : cache.get(new Key(params, required), loader); } GuavaHashCache(); @Override Hash get(HashParameters params, EnumSet<HashSupport> required, Callable<Hash> loader); }
GuavaHashCache implements HashCache { @Override public Hash get(HashParameters params, EnumSet<HashSupport> required, Callable<Hash> loader) throws ExecutionException { final Hash hash = cache.getIfPresent(new SearchKey(params, required)); return hash != null ? hash : cache.get(new Key(params, required), loader); } GuavaHashCache(); @Override Hash get(HashParameters params, EnumSet<HashSupport> required, Callable<Hash> loader);  }