1 16 17 package com.google.inject.util; 18 19 import static com.google.inject.util.ReferenceType.STRONG; 20 21 27 public abstract class ReferenceCache<K, V> 28 extends AbstractReferenceCache<K, V> { 29 30 private static final long serialVersionUID = 0; 31 32 public ReferenceCache(ReferenceType keyReferenceType, 33 ReferenceType valueReferenceType) { 34 super(keyReferenceType, valueReferenceType); 35 } 36 37 40 public ReferenceCache() { 41 super(STRONG, STRONG); 42 } 43 44 50 protected abstract V create(K key); 51 52 V create(FutureValue<V> futureValue, K key) { 53 return create(key); 54 } 55 56 60 public static <K, V> ReferenceCache<K, V> of( 61 ReferenceType keyReferenceType, 62 ReferenceType valueReferenceType, 63 final Function<? super K, ? extends V> function) { 64 ensureNotNull(function); 65 return new ReferenceCache<K, V>(keyReferenceType, valueReferenceType) { 66 protected V create(K key) { 67 return function.apply(key); 68 } 69 private static final long serialVersionUID = 0; 70 }; 71 } 72 } | Popular Tags |