本文整理匯總了Java中com.google.common.cache.LoadingCache.getUnchecked方法的典型用法代碼示例。如果您正苦於以下問題:Java LoadingCache.getUnchecked方法的具體用法?Java LoadingCache.getUnchecked怎麽用?Java LoadingCache.getUnchecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.cache.LoadingCache
的用法示例。
在下文中一共展示了LoadingCache.getUnchecked方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import com.google.common.cache.LoadingCache; //導入方法依賴的package包/類
@Override
public synchronized Optional<V> get(@NonNull String key)
{
checkNotNull(key);
LoadingCache<String, Optional<ExpiringValue<V>>> c = cache.getIfPresent(CurrentInstitution.get());
if( c != null )
{
Optional<ExpiringValue<V>> op = c.getUnchecked(key);
if( op.isPresent() )
{
V ev = op.get().getValue();
return Optional.fromNullable(ev);
}
}
return Optional.absent();
}
示例2: createProxyConstructor
import com.google.common.cache.LoadingCache; //導入方法依賴的package包/類
private static <T> Constructor<T> createProxyConstructor(@Nullable LoadingCache<CacheKey, ClassLoader> cache, Class<T> interfaceClass,
Class<?>... otherInterfaceClasses) {
Class<?>[] interfaceClasses = new Class[1 + otherInterfaceClasses.length];
interfaceClasses[0] = interfaceClass;
ClassLoader classLoader;
if (otherInterfaceClasses.length == 0) {
classLoader = interfaceClass.getClassLoader();
} else {
System.arraycopy(otherInterfaceClasses, 0, interfaceClasses, 1, otherInterfaceClasses.length);
List<ClassLoader> classLoaders = extractClassloaderList(interfaceClasses);
if (classLoaders.size() == 1) {
classLoader = classLoaders.get(0);
} else if (cache != null) {
classLoader = cache.getUnchecked(new CacheKey(classLoaders));
} else {
classLoader = createClassLoader(classLoaders);
}
}
Class<?> uncheckedProxyClass = Proxy.getProxyClass(classLoader, interfaceClasses);
Class<T> proxyClass = interfaceClass.getClass().cast(uncheckedProxyClass);
try {
return proxyClass.getConstructor(InvocationHandler.class);
} catch (NoSuchMethodException e) {
throw new StoreException(e);
}
}