WeakKeySet.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:businessworks 作者:
public void add(Key<?> key, State state, Object source) {
  if (backingMap == null) {
    backingMap = Maps.newHashMap();
  }
  // if it's an instanceof Class, it was a JIT binding, which we don't
  // want to retain.
  if (source instanceof Class || source == SourceProvider.UNKNOWN_SOURCE) {
    source = null;
  }
  Multiset<Object> sources = backingMap.get(key);
  if (sources == null) {
    sources = LinkedHashMultiset.create();
    backingMap.put(key, sources);
  }
  Object convertedSource = Errors.convert(source);
  sources.add(convertedSource);

  // Avoid all the extra work if we can.
  if (state.parent() != State.NONE) {
    Set<KeyAndSource> keyAndSources = evictionCache.getIfPresent(state);
    if (keyAndSources == null) {
      evictionCache.put(state, keyAndSources = Sets.newHashSet());
    }
    keyAndSources.add(new KeyAndSource(key, convertedSource));
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号