@Test public void testSingleThread() throws Exception { CreatingCache<String, String> cache = new CreatingCache<String, String>(new FakeFactory()); String value1 = cache.get("key"); assertEquals("key", value1); String value2 = cache.get("key"); assertEquals("key", value2); assertTrue("repetitive calls give same instance", value1 == value2); }
@Nullable public V get(@NonNull K key) { return get(key, null); }
CreatingCache { @Nullable public V get(@NonNull K key) { return get(key, null); } }
CreatingCache { @Nullable public V get(@NonNull K key) { return get(key, null); } CreatingCache(@NonNull ValueFactory<K, V> valueFactory); }
CreatingCache { @Nullable public V get(@NonNull K key) { return get(key, null); } CreatingCache(@NonNull ValueFactory<K, V> valueFactory); @Nullable V get(@NonNull K key); synchronized void clear(); }
CreatingCache { @Nullable public V get(@NonNull K key) { return get(key, null); } CreatingCache(@NonNull ValueFactory<K, V> valueFactory); @Nullable V get(@NonNull K key); synchronized void clear();  }