Java 类com.intellij.util.containers.WeakInterner 实例源码

项目:intellij-ce-playground    文件:DynamicGenericInfo.java   
private static <T extends DomChildDescriptionImpl> ChildrenDescriptionsHolder<T> internChildrenHolder(XmlFile file, ChildrenDescriptionsHolder<T> holder) {
  SoftReference<WeakInterner<ChildrenDescriptionsHolder>> ref = file.getUserData(HOLDERS_CACHE);
  WeakInterner<ChildrenDescriptionsHolder> cache = SoftReference.dereference(ref);
  if (cache == null) {
    cache = new WeakInterner<ChildrenDescriptionsHolder>();
    file.putUserData(HOLDERS_CACHE, new SoftReference<WeakInterner<ChildrenDescriptionsHolder>>(cache));
  }
  //noinspection unchecked
  return cache.intern(holder);
}